| 1 |
on: |
| 2 |
workflow_call: |
| 3 |
name: Tests |
| 4 |
jobs: |
| 5 |
get-go-versions: |
| 6 |
name: Collect available Go versions |
| 7 |
runs-on: ubuntu-latest |
| 8 |
outputs: |
| 9 |
matrix: ${{ steps.versions.outputs.matrix }} |
| 10 |
steps: |
| 11 |
- uses: actions/checkout@v4 |
| 12 |
- uses: arnested/go-version-action@f3c61952b5f4cc7c74fb216df044634f6a59770f |
| 13 |
id: versions |
| 14 |
|
| 15 |
run: |
| 16 |
strategy: |
| 17 |
fail-fast: false # Keep running if one leg fails. |
| 18 |
matrix: |
| 19 |
os: [ubuntu-latest, macos-latest, windows-latest] |
| 20 |
go-version: ${{ fromJSON(needs.get-go-versions.outputs.matrix) }} |
| 21 |
runs-on: ${{ matrix.os }} |
| 22 |
needs: get-go-versions |
| 23 |
steps: |
| 24 |
- name: Checkout code |
| 25 |
uses: actions/checkout@v4 |
| 26 |
|
| 27 |
- name: Setup - Go ${{ matrix.go-version }} |
| 28 |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe |
| 29 |
with: |
| 30 |
go-version: ${{ matrix.go-version }} |
| 31 |
|
| 32 |
- name: Setup - Python |
| 33 |
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 |
| 34 |
with: |
| 35 |
python-version: "3.10" |
| 36 |
cache: "pip" |
| 37 |
cache-dependency-path: "requirements-test.txt" |
| 38 |
|
| 39 |
- name: Install Python dependencies |
| 40 |
run: | |
| 41 |
python3 -m pip install --upgrade pip |
| 42 |
python3 -m pip install --upgrade -r requirements-test.txt |
| 43 |
|
| 44 |
- name: Run tests |
| 45 |
run: go test -race -covermode atomic -coverprofile='profile.cov' ./... |
| 46 |
|
| 47 |
- name: Send coverage |
| 48 |
uses: shogo82148/actions-goveralls@7b1bd2871942af030d707d6574e5f684f9891fb2 |
| 49 |
with: |
| 50 |
path-to-profile: profile.cov |
| 51 |
flag-name: Go-${{ matrix.go-version }} |
| 52 |
parallel: true |
| 53 |
|
| 54 |
checks: |
| 55 |
strategy: |
| 56 |
matrix: |
| 57 |
go-version: ${{ fromJSON(needs.get-go-versions.outputs.matrix) }} |
| 58 |
runs-on: ubuntu-latest |
| 59 |
needs: get-go-versions |
| 60 |
steps: |
| 61 |
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe |
| 62 |
with: |
| 63 |
go-version: ${{ matrix.go-version }} |
| 64 |
- uses: actions/checkout@v4 |
| 65 |
- name: golangci-lint |
| 66 |
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc |
| 67 |
with: |
| 68 |
version: v1.51 # has to be pinned and thus manually updated due to https://github.com/golangci/golangci-lint-action/blob/6a290f7d5d488e1e423b0b37fe802c822ca2c08c/README.md?plain=1#L108 |
| 69 |
args: --timeout 5m --verbose |
| 70 |
- name: govulncheck |
| 71 |
uses: golang/govulncheck-action@v1 |
| 72 |
with: |
| 73 |
go-version-input: ${{ matrix.go-version }} |
| 74 |
go-package: -json ./... |