|
| 1 | +--- |
| 2 | +# Github Actions build for go-mega |
| 3 | +# -*- compile-command: "yamllint -f parsable build.yml" -*- |
| 4 | + |
| 5 | +name: build |
| 6 | + |
| 7 | +# Trigger the workflow on push or pull request |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - '**' |
| 12 | + tags: |
| 13 | + - '**' |
| 14 | + pull_request: |
| 15 | + workflow_dispatch: |
| 16 | + inputs: |
| 17 | + manual: |
| 18 | + description: Manual run (bypass default conditions) |
| 19 | + type: boolean |
| 20 | + default: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + 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)) |
| 25 | + timeout-minutes: 60 |
| 26 | + defaults: |
| 27 | + run: |
| 28 | + shell: bash |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + job_name: ['linux', 'mac_amd64', 'mac_arm64', 'windows', 'go1.24'] |
| 33 | + |
| 34 | + include: |
| 35 | + - job_name: linux |
| 36 | + os: ubuntu-latest |
| 37 | + go: '>=1.25.0-rc.1' |
| 38 | + gotags: cmount |
| 39 | + |
| 40 | + - job_name: mac_amd64 |
| 41 | + os: macos-latest |
| 42 | + go: '>=1.25.0-rc.1' |
| 43 | + goarch: amd64 |
| 44 | + |
| 45 | + - job_name: mac_arm64 |
| 46 | + os: macos-latest |
| 47 | + go: '>=1.25.0-rc.1' |
| 48 | + goarch: arm64 |
| 49 | + |
| 50 | + - job_name: windows |
| 51 | + os: windows-latest |
| 52 | + go: '>=1.25.0-rc.1' |
| 53 | + |
| 54 | + - job_name: go1.24 |
| 55 | + os: ubuntu-latest |
| 56 | + go: '1.24' |
| 57 | + |
| 58 | + name: ${{ matrix.job_name }} |
| 59 | + |
| 60 | + runs-on: ${{ matrix.os }} |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout@v5 |
| 65 | + with: |
| 66 | + fetch-depth: 0 |
| 67 | + |
| 68 | + - name: Install Go |
| 69 | + uses: actions/setup-go@v6 |
| 70 | + with: |
| 71 | + go-version: ${{ matrix.go }} |
| 72 | + check-latest: true |
| 73 | + |
| 74 | + - name: Set environment variables |
| 75 | + run: | |
| 76 | + if [[ "${{ matrix.goarch }}" != "" ]]; then echo 'GOARCH=${{ matrix.goarch }}' >> $GITHUB_ENV ; fi |
| 77 | +
|
| 78 | + - name: Print Go version and environment |
| 79 | + run: | |
| 80 | + printf "Using go at: $(which go)\n" |
| 81 | + printf "Go version: $(go version)\n" |
| 82 | + printf "\n\nGo environment:\n\n" |
| 83 | + go env |
| 84 | + printf "\n\nSystem environment:\n\n" |
| 85 | + env |
| 86 | +
|
| 87 | + - name: Build go-mega |
| 88 | + run: | |
| 89 | + make |
| 90 | +
|
| 91 | + - name: Run tests |
| 92 | + run: | |
| 93 | + make test |
| 94 | +
|
| 95 | + lint: |
| 96 | + 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)) |
| 97 | + timeout-minutes: 30 |
| 98 | + name: "lint" |
| 99 | + runs-on: ubuntu-latest |
| 100 | + |
| 101 | + steps: |
| 102 | + - name: Get runner parameters |
| 103 | + id: get-runner-parameters |
| 104 | + run: | |
| 105 | + echo "year-week=$(/bin/date -u "+%Y%V")" >> $GITHUB_OUTPUT |
| 106 | + echo "runner-os-version=$ImageOS" >> $GITHUB_OUTPUT |
| 107 | +
|
| 108 | + - name: Checkout |
| 109 | + uses: actions/checkout@v5 |
| 110 | + with: |
| 111 | + fetch-depth: 0 |
| 112 | + |
| 113 | + - name: Install Go |
| 114 | + id: setup-go |
| 115 | + uses: actions/setup-go@v6 |
| 116 | + with: |
| 117 | + go-version: '>=1.24.0-rc.1' |
| 118 | + check-latest: true |
| 119 | + cache: false |
| 120 | + |
| 121 | + - name: Cache |
| 122 | + uses: actions/cache@v4 |
| 123 | + with: |
| 124 | + path: | |
| 125 | + ~/go/pkg/mod |
| 126 | + ~/.cache/go-build |
| 127 | + ~/.cache/golangci-lint |
| 128 | + 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') }} |
| 129 | + 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 }}- |
| 130 | + |
| 131 | + - name: Code quality test |
| 132 | + uses: golangci/golangci-lint-action@v8 |
| 133 | + with: |
| 134 | + version: latest |
| 135 | + skip-cache: true |
| 136 | + |
| 137 | + - name: Install govulncheck |
| 138 | + run: go install golang.org/x/vuln/cmd/govulncheck@latest |
| 139 | + |
| 140 | + - name: Scan for vulnerabilities |
| 141 | + run: govulncheck ./... |
0 commit comments