From 7744bd63e739a563becacf5dffa6ac81b61df73e Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 16 Jan 2024 17:11:37 +0100 Subject: [PATCH] ci: rework test pipeline --- .github/workflows/test.yml | 27 ++++-------- .github/workflows/test_e2e.yml | 76 ++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 54 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8774b60..c8631527 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Run tests +name: Test on: push: @@ -9,32 +9,21 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v5 - with: - go-version: "1.21" - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 with: - fetch-depth: 0 - - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + go-version-file: go.mod - name: Run tests - run: | - go vet ./... - go test -v -race -coverprofile=coverage.txt $(go list ./... | grep -v e2e) + run: go test -v -race -coverprofile=coverage.txt ./... - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 deploy-manifests: - name: Check deployment manifests runs-on: ubuntu-latest + steps: - uses: yokawasa/action-setup-kube-tools@v0.9.3 with: @@ -43,6 +32,7 @@ jobs: helm: v3.11.2 - uses: actions/checkout@v4 + - name: Generate manifests from helm chart run: hack/update-deployment-yamls.sh @@ -54,8 +44,8 @@ jobs: run: echo "::error title=Deployment Manifests outdated::Please run hack/update-deployment-yamls.sh and commit the changes to deploy/" helm-chart: - name: Verify Helm Chart runs-on: ubuntu-latest + steps: - uses: yokawasa/action-setup-kube-tools@v0.9.3 with: @@ -70,6 +60,7 @@ jobs: run: | hack/update-helm-snapshots.sh git diff --exit-code -- deploy/ + - name: Show warning if: ${{ failure() }} run: echo "::error title=Helm Snapshots outdated::Please run hack/update-helm-snapshots.sh and commit the changes to chart/.snapshots/" diff --git a/.github/workflows/test_e2e.yml b/.github/workflows/test_e2e.yml index ba3710ef..683da84d 100644 --- a/.github/workflows/test_e2e.yml +++ b/.github/workflows/test_e2e.yml @@ -1,15 +1,20 @@ -name: Run e2e tests +name: Test e2e + on: - pull_request: {} push: branches: [main] -concurrency: ci-${{ github.ref }} + pull_request: + +concurrency: ${{ github.workflow }}-${{ github.ref }} + jobs: test-kubernetes: name: k3s ${{ matrix.k3s }} + runs-on: ubuntu-latest + permissions: id-token: write - runs-on: ubuntu-latest + strategy: # The e2e tests are flaky and often one of the jobs fails. The default setting # causes all other currently running jobs to abort and all need to be restarted. @@ -24,42 +29,41 @@ jobs: k8s-test: v1.28.5 - k3s: v1.29 k8s-test: v1.29.0 + steps: - - uses: actions/setup-go@v5 - with: - go-version: "1.21" - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - uses: hetznercloud/tps-action@main - - uses: hetznercloud/tps-action@main - with: - token: ${{ secrets.HCLOUD_TOKEN }} + - uses: hetznercloud/setup-hcloud@v1 - - uses: hetznercloud/setup-hcloud@v1 - - uses: yokawasa/action-setup-kube-tools@v0.9.3 - with: - setup-tools: | - helm - kubectl - skaffold - helm: v3.11.2 - kubectl: v1.29.0 - skaffold: v2.3.0 + - uses: yokawasa/action-setup-kube-tools@v0.9.3 + with: + setup-tools: | + helm + kubectl + skaffold + helm: v3.11.2 + kubectl: v1.29.0 + skaffold: v2.3.0 - - name: Run tests - env: - K3S_CHANNEL: ${{ matrix.k3s }} - K8S_TEST_VERSION: ${{ matrix.k8s-test }} - SCOPE: gha-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.k3s }} - run: | - curl -sLS https://get.k3sup.dev | sh + - name: Run tests + env: + K3S_CHANNEL: ${{ matrix.k3s }} + K8S_TEST_VERSION: ${{ matrix.k8s-test }} + SCOPE: gha-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.k3s }} + run: | + curl -sLS https://get.k3sup.dev | sh - trap "hack/dev-down.sh" EXIT - source <(hack/dev-up.sh) + trap "hack/dev-down.sh" EXIT + source <(hack/dev-up.sh) - skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}" - tag=$(skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}" --quiet --output="{{ (index .Builds 0).Tag }}") - skaffold deploy --images=docker.io/hetznercloud/hcloud-csi-driver=$tag + skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}" + tag=$(skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}" --quiet --output="{{ (index .Builds 0).Tag }}") + skaffold deploy --images=docker.io/hetznercloud/hcloud-csi-driver=$tag - test/e2e/kubernetes/run-e2e-tests.sh + test/e2e/kubernetes/run-e2e-tests.sh