CI: add tests for different Go versions

Signed-off-by: Sven Anderson <sven@redhat.com>
This commit is contained in:
Sven Anderson 2023-08-04 14:06:36 +02:00 committed by mergify[bot]
parent a495ff9d1c
commit 533a0db386
3 changed files with 40 additions and 7 deletions

View File

@ -15,13 +15,35 @@ on:
- cron: 1 1 * * * - cron: 1 1 * * *
jobs: 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 # Run static/code-quality checks
check: check:
needs: go-versions
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/setup-go@v4 - uses: actions/setup-go@v4
with: with:
go-version: 1.19 go-version: ${{ needs.go-versions.outputs.latest }}
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install revive - name: Install revive
run: go install github.com/mgechev/revive@latest run: go install github.com/mgechev/revive@latest
@ -30,6 +52,8 @@ jobs:
# Run the test suite in a container per-ceph-codename # Run the test suite in a container per-ceph-codename
test-suite: 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 runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
@ -43,16 +67,23 @@ jobs:
- "pre-quincy" - "pre-quincy"
- "pre-reef" - "pre-reef"
- "main" - "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: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Run tests - 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 - name: Clean up test containers
run: make test-containers-clean "CEPH_VERSION=${{ matrix.ceph_version }}" run: make test-containers-clean "CEPH_VERSION=${{ matrix.ceph_version }}"
- name: Archive test results - name: Archive test results
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: "go-ceph-results-${{ matrix.ceph_version }}" name: "go-ceph-results-${{ matrix.ceph_version }}-${{ matrix.go_version }}"
path: | path: |
_results/ _results/
retention-days: 30 retention-days: 30

View File

@ -113,6 +113,9 @@ endif
# Assemble the various build args that will be passed container build command(s) # Assemble the various build args that will be passed container build command(s)
CONTAINER_BUILD_ARGS:=$(DEFAULT_BUILD_ARGS) CONTAINER_BUILD_ARGS:=$(DEFAULT_BUILD_ARGS)
CONTAINER_BUILD_ARGS += --build-arg GOARCH=$(GOARCH) CONTAINER_BUILD_ARGS += --build-arg GOARCH=$(GOARCH)
ifneq ($(GO_VERSION),)
CONTAINER_BUILD_ARGS += --build-arg GO_VERSION=$(GO_VERSION)
endif
ifdef CEPH_IMG ifdef CEPH_IMG
CONTAINER_BUILD_ARGS += --build-arg CEPH_IMG=$(CEPH_IMG) CONTAINER_BUILD_ARGS += --build-arg CEPH_IMG=$(CEPH_IMG)
endif endif

View File

@ -14,9 +14,9 @@ RUN true && \
yum update -y && \ yum update -y && \
cv="$(rpm -q --queryformat '%{version}-%{release}' ceph-common)" && \ cv="$(rpm -q --queryformat '%{version}-%{release}' ceph-common)" && \
yum install -y \ yum install -y \
git wget curl make \ git wget curl make \
/usr/bin/cc /usr/bin/c++ \ /usr/bin/cc /usr/bin/c++ \
"libcephfs-devel-${cv}" "librados-devel-${cv}" "librbd-devel-${cv}" && \ "libcephfs-devel-${cv}" "librados-devel-${cv}" "librbd-devel-${cv}" && \
yum clean all && \ yum clean all && \
true true
@ -38,7 +38,6 @@ ENV PATH="${PATH}:/opt/go/bin"
ENV GOROOT=/opt/go ENV GOROOT=/opt/go
ENV GO111MODULE=on ENV GO111MODULE=on
ENV GOPATH /go ENV GOPATH /go
ENV GODEBUG=cgocheck=2
ENV GOCACHE=/go/cache ENV GOCACHE=/go/cache
WORKDIR /go/src/github.com/ceph/go-ceph WORKDIR /go/src/github.com/ceph/go-ceph
VOLUME /go/src/github.com/ceph/go-ceph VOLUME /go/src/github.com/ceph/go-ceph