Skip to content

Commit

Permalink
ci: target Go version from code, replace cancel by native support
Browse files Browse the repository at this point in the history
  • Loading branch information
pandatix committed Mar 1, 2024
1 parent ecb932b commit 47bc227
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
35 changes: 11 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,21 @@ on: [push, pull_request]
permissions:
contents: read

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Cancel previous
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
unit-tests:
strategy:
matrix:
go-version: [1.x, 1.22.x]
platform: [ubuntu-latest]
include:
- go-version: 1.x
platform: ubuntu-latest
update-coverage: true
runs-on: ${{ matrix.platform }}
needs: [setup]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version-file: go.mod

- name: Cache go modules
uses: actions/cache@v4
Expand All @@ -42,13 +29,13 @@ jobs:
restore-keys: ${{ runner.os }}-go-

- name: Run go test
run: go test -v -race -coverprofile coverage.txt ./...
run: go test -v -race -coverprofile cov.out ./...

- name: Upload coverage to Coveralls
if: ${{ matrix.update-coverage }}
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.txt
path-to-profile: cov.out

go-lint:
runs-on: ubuntu-latest
Expand All @@ -57,7 +44,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version-file: go.mod

- name: go-lint
uses: golangci/golangci-lint-action@v4
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: go.mod

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: "1.22"
check-latest: true
go-version-file: go.mod
- name: Install Syft
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
Expand Down

0 comments on commit 47bc227

Please sign in to comment.