Code quality improvements and Go 1.18+ modernization #9
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
| --- | |
| # Github Actions build for go-mega | |
| # -*- compile-command: "yamllint -f parsable build.yml" -*- | |
| name: build | |
| # Trigger the workflow on push or pull request | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| tags: | |
| - '**' | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| manual: | |
| description: Manual run (bypass default conditions) | |
| type: boolean | |
| default: true | |
| jobs: | |
| build: | |
| if: inputs.manual || (github.repository == 't3rm1n4l/go-mega' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)) | |
| timeout-minutes: 60 | |
| defaults: | |
| run: | |
| shell: bash | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| job_name: ['linux', 'mac_amd64', 'mac_arm64', 'windows', 'go1.24'] | |
| include: | |
| - job_name: linux | |
| os: ubuntu-latest | |
| go: '>=1.25.0-rc.1' | |
| gotags: cmount | |
| - job_name: mac_amd64 | |
| os: macos-latest | |
| go: '>=1.25.0-rc.1' | |
| goarch: amd64 | |
| - job_name: mac_arm64 | |
| os: macos-latest | |
| go: '>=1.25.0-rc.1' | |
| goarch: arm64 | |
| - job_name: windows | |
| os: windows-latest | |
| go: '>=1.25.0-rc.1' | |
| - job_name: go1.24 | |
| os: ubuntu-latest | |
| go: '1.24' | |
| name: ${{ matrix.job_name }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ matrix.go }} | |
| check-latest: true | |
| - name: Set environment variables | |
| run: | | |
| if [[ "${{ matrix.goarch }}" != "" ]]; then echo 'GOARCH=${{ matrix.goarch }}' >> $GITHUB_ENV ; fi | |
| - name: Print Go version and environment | |
| run: | | |
| printf "Using go at: $(which go)\n" | |
| printf "Go version: $(go version)\n" | |
| printf "\n\nGo environment:\n\n" | |
| go env | |
| printf "\n\nSystem environment:\n\n" | |
| env | |
| - name: Build go-mega | |
| run: | | |
| make | |
| - name: Run tests | |
| run: | | |
| make test | |
| lint: | |
| if: inputs.manual || (github.repository == 't3rm1n4l/go-mega' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)) | |
| timeout-minutes: 30 | |
| name: "lint" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get runner parameters | |
| id: get-runner-parameters | |
| run: | | |
| echo "year-week=$(/bin/date -u "+%Y%V")" >> $GITHUB_OUTPUT | |
| echo "runner-os-version=$ImageOS" >> $GITHUB_OUTPUT | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Go | |
| id: setup-go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '>=1.24.0-rc.1' | |
| check-latest: true | |
| cache: false | |
| - name: Cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/go/pkg/mod | |
| ~/.cache/go-build | |
| ~/.cache/golangci-lint | |
| key: golangci-lint-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-${{ steps.get-runner-parameters.outputs.year-week }}-${{ hashFiles('go.sum') }} | |
| restore-keys: golangci-lint-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-${{ steps.get-runner-parameters.outputs.year-week }}- | |
| - name: Code quality test | |
| uses: golangci/golangci-lint-action@v8 | |
| with: | |
| version: latest | |
| skip-cache: true | |
| - name: Install govulncheck | |
| run: go install golang.org/x/vuln/cmd/govulncheck@latest | |
| - name: Scan for vulnerabilities | |
| run: govulncheck ./... |