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 <sven@redhat.com>
  • Loading branch information
ansiwen authored and mergify[bot] committed Aug 8, 2023
1 parent a495ff9 commit 533a0db
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
37 changes: 34 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,8 @@ jobs:

# Run the test suite in a container per-ceph-codename
test-suite:
name: test-suite (${{ matrix.ceph_version }}${{ matrix.go_version != needs.go-versions.outputs.latest && format(', go{0}', matrix.go_version) || '' }})
needs: go-versions
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -43,16 +67,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 }}" "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
7 changes: 3 additions & 4 deletions testing/containers/ceph/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN true && \
yum update -y && \
cv="$(rpm -q --queryformat '%{version}-%{release}' ceph-common)" && \
yum install -y \
git wget curl make \
/usr/bin/cc /usr/bin/c++ \
"libcephfs-devel-${cv}" "librados-devel-${cv}" "librbd-devel-${cv}" && \
git wget curl make \
/usr/bin/cc /usr/bin/c++ \
"libcephfs-devel-${cv}" "librados-devel-${cv}" "librbd-devel-${cv}" && \
yum clean all && \
true

Expand All @@ -38,7 +38,6 @@ ENV PATH="${PATH}:/opt/go/bin"
ENV GOROOT=/opt/go
ENV GO111MODULE=on
ENV GOPATH /go
ENV GODEBUG=cgocheck=2
ENV GOCACHE=/go/cache
WORKDIR /go/src/github.com/ceph/go-ceph
VOLUME /go/src/github.com/ceph/go-ceph
Expand Down

0 comments on commit 533a0db

Please sign in to comment.