From b2a1fb6facb437e28f1db469f0fcd83d8089c041 Mon Sep 17 00:00:00 2001 From: Daniel Roux Date: Wed, 24 Apr 2024 22:40:22 +0200 Subject: [PATCH] Adapt smoke test job configuration --- .github/dependabot.yml | 6 +- .github/workflows/.dependabot_misc.yml | 4 +- .github/workflows/docker.yml | 33 ++++++++- .github/workflows/k8s-test.yml | 2 +- ci/ui_smoke_tests.sh | 15 +++++ testdata/cypress-job.yml | 92 ++++++++++++-------------- 6 files changed, 93 insertions(+), 59 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 42931e1..7bf33e3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,7 +13,7 @@ updates: prefix: "npm deps:" include: "scope" open-pull-requests-limit: 10 - assignees: + reviewers: - "danroux" - package-ecosystem: "github-actions" directory: "/" @@ -28,7 +28,7 @@ updates: prefix: "gha deps:" include: "scope" open-pull-requests-limit: 10 - assignees: + reviewers: - "danroux" - package-ecosystem: "docker" directory: "/" @@ -43,5 +43,5 @@ updates: prefix: "docker deps:" include: "scope" open-pull-requests-limit: 10 - assignees: + reviewers: - "danroux" diff --git a/.github/workflows/.dependabot_misc.yml b/.github/workflows/.dependabot_misc.yml index 47a9566..12795e9 100644 --- a/.github/workflows/.dependabot_misc.yml +++ b/.github/workflows/.dependabot_misc.yml @@ -42,5 +42,5 @@ jobs: git config --local user.email "dependabot[bot]@users.noreply.github.com" git config --local user.name "dependabot[bot]" git add .changelog - git commit -m "Add .changelog entry #${{ github.event.pull_request.number }}" - git push "https://x-access-token:$GITHUB_TOKEN@github.com/${{ github.repository }}.git" HEAD:${{ github.event.pull_request.head.ref }} + git commit --amend --no-edit + git push --force "https://x-access-token:$GITHUB_TOKEN@github.com/${{ github.repository }}.git" HEAD:${{ github.event.pull_request.head.ref }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 684ba63..6481c79 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,7 +1,6 @@ name: Build & Push images on: - pull_request: workflow_dispatch: workflow_call: inputs: @@ -55,10 +54,38 @@ jobs: cache-to: type=gha,mode=max push: true tags: | - ${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev - ${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev-${{ github.sha }} ${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev-${{ inputs.image_tag }} ${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev-${{ inputs.pull_request_number }} + sk8l-ui-dev-main-img: + runs-on: ubuntu-latest + name: sk8l-ui:dev-main@${{ github.sha }} + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + with: + fetch-depth: 0 + submodules: recursive + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 + - name: Login to ghcr.io + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push dev version + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 + with: + context: . + file: Dockerfile + cache-from: type=gha + cache-to: type=gha,mode=max + push: true + tags: | + ${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev + ${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev-${{ github.sha }} sk8l-ui-pre-main-img: runs-on: ubuntu-latest name: sk8l-ui:pre-main@${{ github.sha }} diff --git a/.github/workflows/k8s-test.yml b/.github/workflows/k8s-test.yml index 875196e..5547a22 100644 --- a/.github/workflows/k8s-test.yml +++ b/.github/workflows/k8s-test.yml @@ -66,7 +66,7 @@ jobs: - name: ui smoke tests id: ui_smoke_tests run: | - ./ci/ui_smoke_tests.sh + ./ci/ui_smoke_tests.sh ghcr.io/danroux/sk8l-ui:ui-test-${{ inputs.image_tag }} - name: ui smoke tests error output if: ${{ failure() && steps.ui_smoke_tests.conclusion == 'failure' }} run: | diff --git a/ci/ui_smoke_tests.sh b/ci/ui_smoke_tests.sh index c9850e4..dc9eab2 100755 --- a/ci/ui_smoke_tests.sh +++ b/ci/ui_smoke_tests.sh @@ -2,9 +2,24 @@ set -e +pr_image_tag="$1" + kubectl apply -f https://raw.githubusercontent.com/danroux/sk8l-api/main/testdata/sk8l-cronjobs.yml -n sk8l > /dev/null kubectl wait -n sk8l --for=condition=ready pod -l app.kubernetes.io/pod=sk8l-ui --timeout=300s sleep 10 +cp testdata/cypress-job.yml testdata/cypress-job.yml.bak +yq e -i ".spec.template.spec.containers[0].image = \"$pr_image_tag\"" testdata/cypress-job.yml + +set +e +echo "after" +diff -C3 testdata/cypress-job.yml.bak testdata/cypress-job.yml +diff_status=$? +set -e +if [ $diff_status -eq 0 ]; then + echo "No differences found between the files." + exit 1 +fi + kubectl apply -f testdata/cypress-job.yml -n sk8l kubectl wait --for=condition=complete job.batch/cypress-job -n sk8l --timeout=600s diff --git a/testdata/cypress-job.yml b/testdata/cypress-job.yml index 4f3a2df..e2d51ce 100644 --- a/testdata/cypress-job.yml +++ b/testdata/cypress-job.yml @@ -6,37 +6,29 @@ spec: template: spec: containers: - - name: cypress - image: ghcr.io/danroux/sk8l-ui:ui-test - imagePullPolicy: Always - command: [ - "cypress" - ] - args: [ - "run", - "--browser", - "firefox:stable", - "--headless", - "--config-file=cypress.config.ts" - ] - # command: ["/bin/sh"] - # args: ["-c", "while true; do echo hello; sleep 120;done"] - workingDir: /e2e - volumeMounts: - - name: tls-certs - mountPath: /e2e/testdata/sk8l-certs - readOnly: true - - name: xapp - mountPath: /e2e/cypress/screenshots - - name: ca-certificate-only - mountPath: /usr/lib/mozilla/certificates - readOnly: true - - name: ca-certificate-only - mountPath: /usr/lib64/mozilla/certificates - readOnly: true - - name: ca-certificate-only - mountPath: ~/.mozilla/certificates - readOnly: true + - name: cypress + image: ghcr.io/danroux/sk8l-ui:ui-test + imagePullPolicy: Always + command: ["cypress"] + args: ["run", "--browser", "firefox:stable", "--headless", "--config-file=cypress.config.ts"] + # command: ["/bin/sh"] + # args: ["-c", "while true; do echo hello; sleep 120;done"] + workingDir: /e2e + volumeMounts: + - name: tls-certs + mountPath: /e2e/testdata/sk8l-certs + readOnly: true + - name: xapp + mountPath: /e2e/cypress/screenshots + - name: ca-certificate-only + mountPath: /usr/lib/mozilla/certificates + readOnly: true + - name: ca-certificate-only + mountPath: /usr/lib64/mozilla/certificates + readOnly: true + - name: ca-certificate-only + mountPath: ~/.mozilla/certificates + readOnly: true restartPolicy: Never volumes: - name: xapp @@ -46,26 +38,26 @@ spec: - name: tls-certs projected: sources: - - secret: - name: sk8l-tls-server-cert - items: - - key: tls.crt - path: server-cert.pem - - key: tls.key - path: server-key.pem - - key: ca.crt - path: ca-cert.pem - - configMap: - name: sk8l - items: - - key: trust-bundle.crt - path: ca-certificates.crt + - secret: + name: sk8l-server-cert-secret + items: + - key: tls.crt + path: server-cert.pem + - key: tls.key + path: server-key.pem + - key: ca.crt + path: ca-cert.pem + - configMap: + name: sk8l-ca-cert-cm + items: + - key: trust-bundle.crt + path: ca-certificates.crt - name: ca-certificate-only projected: sources: - - configMap: - name: sk8l - items: - - key: trust-bundle.crt - path: ca-certificates.crt + - configMap: + name: sk8l-ca-cert-cm + items: + - key: trust-bundle.crt + path: ca-certificates.crt backoffLimit: 1