CI: Bump to golang 1.25, just test one version, bump actions (#27) #55
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: CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| go-version: ['1.25'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-${{ matrix.go-version }}- | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Format check | |
| run: | | |
| go fmt ./... | |
| git diff --exit-code | |
| - name: Vet | |
| run: go vet ./... | |
| - name: Run tests | |
| run: go test -v -race -coverprofile=coverage.out ./... | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| file: ./coverage.out | |
| - name: Extract version information | |
| id: version | |
| run: | | |
| VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") | |
| BUILD_DATE=$(date -u +"%Y-%m-%d") | |
| GIT_COMMIT=$(git rev-parse --short HEAD) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT | |
| echo "git_commit=$GIT_COMMIT" >> $GITHUB_OUTPUT | |
| echo "Building with version: $VERSION (commit: $GIT_COMMIT, date: $BUILD_DATE)" | |
| - name: Build | |
| run: | | |
| go build -v \ | |
| -ldflags="-X cloudamqp-cli/cmd.Version=${{ steps.version.outputs.version }} -X cloudamqp-cli/cmd.BuildDate=${{ steps.version.outputs.build_date }} -X cloudamqp-cli/cmd.GitCommit=${{ steps.version.outputs.git_commit }}" \ | |
| -o cloudamqp . | |
| - name: Test binary | |
| run: | | |
| ./cloudamqp --help | |
| ./cloudamqp version |