Ci/optimize GitHub actions #425
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code Check | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| jobs: | |
| build: | |
| name: Build And Test Go code | |
| runs-on: ubuntu-latest | |
| env: | |
| CGO_ENABLED: 0 | |
| GOFLAGS: -buildvcs=false | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: false | |
| - name: Cache go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/go/pkg/mod | |
| ~/.cache/go-build | |
| key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }} | |
| restore-keys: | | |
| ${{ runner.OS }}-go- | |
| - name: Download modules | |
| run: go mod download | |
| # https://stackoverflow.com/questions/76269119/github-actions-go-lambda-project-different-sha256sums | |
| - name: Build | |
| run: go build -v ./... | |
| # Make sure to detect eventual race conditions | |
| # (CGO must be enabled to use -race detector) | |
| - name: Test | |
| # -count=2 ensures that test fixtures cleanup after themselves | |
| # because any leftover state will generally cause the second run to fail. | |
| run: go test -race -p 1 -v -shuffle=on -count=2 ./... | |
| env: | |
| CGO_ENABLED: 1 | |
| - name: Linter | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| version: latest |