gha: skip modules on unsupported Go versions, test against 1.18.x, oldstable, stable #696
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
| on: [push, pull_request] | |
| name: Test | |
| jobs: | |
| test: | |
| strategy: | |
| matrix: | |
| go-version: [1.18.x, oldstable, stable] | |
| platform: [ubuntu-22.04, ubuntu-24.04, windows-latest, macos-13, macos-14, macos-15] | |
| runs-on: ${{ matrix.platform }} | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| # Disable caching as we don't have top-level go.sum needed for | |
| # the cache key, and specifying multiple go.sums is not trivial | |
| # (see https://github.com/moby/sys/pull/160 for details). | |
| cache: false | |
| - name: Set PACKAGES env | |
| if: ${{ matrix.go-version == '1.18.x' }} | |
| run: | | |
| # Check if the module supports this version of Go. | |
| go_version="$(go env GOVERSION)" | |
| go_version="${go_version#go}" | |
| packages="" | |
| for p in */; do | |
| [ -f "$p/go.mod" ] || continue | |
| if ! (cd "$p" && go list -m -f "{{if gt .GoVersion \"$go_version\"}}ko{{end}}" | grep -q ko); then | |
| packages+="${p%/} " | |
| else | |
| echo "::notice::SKIP: github.com/moby/sys/${p%/} requires a more recent version of Go" | |
| fi | |
| done | |
| echo "PACKAGES=${packages}" >> "$GITHUB_ENV" | |
| - name: go mod tidy | |
| run: | | |
| make foreach CMD="go mod tidy" | |
| git diff --exit-code | |
| - name: go fix | |
| run: | | |
| make foreach CMD="go fix" | |
| git diff --exit-code | |
| - name: Lint | |
| run: make lint | |
| - name: Cross build | |
| if: ${{ runner.os == 'Linux' }} | |
| run: make cross | |
| - name: Test | |
| run: | | |
| uname -a | |
| make test | |
| - name: Send to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533 | |
| codespell: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: pip install --break-system-packages codespell==v2.3.0 | |
| - run: codespell |