Skip to content

Commit

Permalink
CI: add tests for different Go versions
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Anderson <[email protected]>
  • Loading branch information
ansiwen committed Aug 4, 2023
1 parent a495ff9 commit cedab89
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
36 changes: 33 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,35 @@ on:
- cron: 1 1 * * *

jobs:
# Determine the latest go versions
go-versions:
runs-on: ubuntu-latest
steps:
- id: go-versions
run: |
curl -s 'https://go.dev/dl/?mode=json' -o go-latest.json
curl -s 'https://go.dev/dl/?mode=json&include=all' -o go-all.json
LATEST=$(jq -r '.[0]|.version' go-latest.json)
PREV=$(jq -r '.[1]|.version' go-latest.json)
UNSTABLE=$(jq -r '.[0]|.version' go-all.json)
echo "latest=${LATEST#go}" >> $GITHUB_OUTPUT
echo "prev=${PREV#go}" >> $GITHUB_OUTPUT
echo "unstable=${UNSTABLE#go}" >> $GITHUB_OUTPUT
outputs:
latest: ${{ steps.go-versions.outputs.latest }}
prev: ${{ steps.go-versions.outputs.prev }}
unstable: ${{ steps.go-versions.outputs.unstable }}

# Run static/code-quality checks
check:
needs: go-versions
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ${{ needs.go-versions.outputs.latest }}
- uses: actions/checkout@v3
- name: Install revive
run: go install github.com/mgechev/revive@latest
Expand All @@ -30,6 +52,7 @@ jobs:

# Run the test suite in a container per-ceph-codename
test-suite:
needs: go-versions
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -43,16 +66,23 @@ jobs:
- "pre-quincy"
- "pre-reef"
- "main"
go_version:
- ${{ needs.go-versions.outputs.latest }}
include:
- ceph_version: "reef"
go_version: ${{ needs.go-versions.outputs.prev }}
- ceph_version: "reef"
go_version: ${{ needs.go-versions.outputs.unstable }}
steps:
- uses: actions/checkout@v3
- name: Run tests
run: make test-containers-test "CEPH_VERSION=${{ matrix.ceph_version }}" "RESULTS_DIR=$PWD/_results"
run: make test-containers-test "CEPH_VERSION=${{ matrix.ceph_version }}" "GO_VERSION=${${{ matrix.go_version }}#go}" "RESULTS_DIR=$PWD/_results"
- name: Clean up test containers
run: make test-containers-clean "CEPH_VERSION=${{ matrix.ceph_version }}"
- name: Archive test results
uses: actions/upload-artifact@v3
with:
name: "go-ceph-results-${{ matrix.ceph_version }}"
name: "go-ceph-results-${{ matrix.ceph_version }}-${{ matrix.go_version }}"
path: |
_results/
retention-days: 30
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ endif
# Assemble the various build args that will be passed container build command(s)
CONTAINER_BUILD_ARGS:=$(DEFAULT_BUILD_ARGS)
CONTAINER_BUILD_ARGS += --build-arg GOARCH=$(GOARCH)
ifneq ($(GO_VERSION),)
CONTAINER_BUILD_ARGS += --build-arg GO_VERSION=$(GO_VERSION)
endif
ifdef CEPH_IMG
CONTAINER_BUILD_ARGS += --build-arg CEPH_IMG=$(CEPH_IMG)
endif
Expand Down

0 comments on commit cedab89

Please sign in to comment.