From 745ec9620f8ce059d133db31ed0f34069c5d46e6 Mon Sep 17 00:00:00 2001 From: Roman Zabaluev Date: Thu, 11 Apr 2024 14:23:24 +0700 Subject: [PATCH] Refactor e2e workflows --- .github/workflows/branch-deploy.yml | 1 + .github/workflows/e2e-automation.yml | 76 +------- .github/workflows/e2e-manual.yml | 42 ----- .github/workflows/e2e-run.yml | 163 ++++++++++++++++++ .github/workflows/e2e-tests.yml | 77 +-------- .github/workflows/e2e-weekly.yml | 76 +------- e2e-tests/pom.xml | 119 +------------ ...{browsers-github.json => browsers-ci.json} | 0 ...{selenoid-github.yaml => selenoid-ci.yaml} | 2 +- e2e-tests/src/test/resources/regression.xml | 2 +- e2e-tests/src/test/resources/sanity.xml | 2 +- e2e-tests/src/test/resources/smoke.xml | 2 +- 12 files changed, 192 insertions(+), 370 deletions(-) delete mode 100644 .github/workflows/e2e-manual.yml create mode 100644 .github/workflows/e2e-run.yml rename e2e-tests/selenoid/config/{browsers-github.json => browsers-ci.json} (100%) rename e2e-tests/selenoid/{selenoid-github.yaml => selenoid-ci.yaml} (85%) diff --git a/.github/workflows/branch-deploy.yml b/.github/workflows/branch-deploy.yml index 107a93116..6969bd2c6 100644 --- a/.github/workflows/branch-deploy.yml +++ b/.github/workflows/branch-deploy.yml @@ -8,6 +8,7 @@ on: permissions: contents: read + statuses: write jobs: build: diff --git a/.github/workflows/e2e-automation.yml b/.github/workflows/e2e-automation.yml index fe763e98f..610695a49 100644 --- a/.github/workflows/e2e-automation.yml +++ b/.github/workflows/e2e-automation.yml @@ -14,75 +14,13 @@ on: permissions: contents: read + checks: write + statuses: write jobs: build-and-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - token: ${{ github.token }} - ref: ${{ github.sha }} - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 - - name: Set up environment - id: set_env_values - run: | - cat "./e2e-tests/.env.ci" >> "./e2e-tests/.env" - - name: Pull with Docker - id: pull_chrome - run: | - docker pull selenoid/vnc_chrome:103.0 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'zulu' - cache: 'maven' - - name: Build with Maven - id: build_app - run: | - ./mvnw -B -ntp versions:set -DnewVersion=${{ github.sha }} - ./mvnw -B -V -ntp clean install -Pprod -Dmaven.test.skip=true ${{ github.event.inputs.extraMavenOptions }} - - name: Compose with Docker - id: compose_app - # use the following command until #819 will be fixed - run: | - docker-compose -f e2e-tests/docker/selenoid-git.yaml up -d - docker-compose -f ./documentation/compose/e2e-tests.yaml up -d - - name: Run test suite - run: | - ./mvnw -B -ntp versions:set -DnewVersion=${{ github.sha }} - ./mvnw -B -V -ntp -Dsurefire.suiteXmlFiles='src/test/resources/${{ github.event.inputs.test_suite }}.xml' -Dsuite=${{ github.event.inputs.test_suite }} -f 'e2e-tests' test -Pprod - - name: Generate Allure report - uses: simple-elf/allure-report-action@master - if: always() - id: allure-report - with: - allure_results: ./e2e-tests/allure-results - gh_pages: allure-results - allure_report: allure-report - subfolder: allure-results - report_url: "http://kafkaui-allure-reports.s3-website.eu-central-1.amazonaws.com" - - uses: jakejarvis/s3-sync-action@master - if: always() - env: - AWS_S3_BUCKET: 'kafkaui-allure-reports' - AWS_REGION: 'eu-central-1' - SOURCE_DIR: 'allure-history/allure-results' - - name: Deploy report to Amazon S3 - if: always() - uses: Sibz/github-status-action@v1.1.6 - with: - authToken: ${{secrets.GITHUB_TOKEN}} - context: "Click Details button to open Allure report" - state: "success" - sha: ${{ github.sha }} - target_url: http://kafkaui-allure-reports.s3-website.eu-central-1.amazonaws.com/${{ github.run_number }} - - name: Dump Docker logs on failure - if: failure() - uses: jwalton/gh-docker-logs@v2.2.2 + uses: ./.github/workflows/e2e-run.yml + secrets: inherit + with: + suite_name: ${{ github.event.inputs.test_suite }} + sha: ${{ github.sha }} diff --git a/.github/workflows/e2e-manual.yml b/.github/workflows/e2e-manual.yml deleted file mode 100644 index 49d1ffc51..000000000 --- a/.github/workflows/e2e-manual.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: "E2E: Manual suite" -on: - workflow_dispatch: - inputs: - test_suite: - description: 'Select test suite to run' - default: 'manual' - required: true - type: choice - options: - - manual - -permissions: - contents: read - -jobs: - build-and-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - token: ${{ github.token }} - ref: ${{ github.sha }} - - name: Set up environment - id: set_env_values - run: | - cat "./e2e-tests/.env.ci" >> "./e2e-tests/.env" - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'zulu' - cache: 'maven' - - name: Build with Maven - id: build_app - run: | - ./mvnw -B -ntp versions:set -DnewVersion=${{ github.sha }} - ./mvnw -B -V -ntp clean install -Pprod -Dmaven.test.skip=true ${{ github.event.inputs.extraMavenOptions }} - - name: Run test suite - run: | - ./mvnw -B -ntp versions:set -DnewVersion=${{ github.sha }} - ./mvnw -B -V -ntp -Dsurefire.suiteXmlFiles='src/test/resources/${{ github.event.inputs.test_suite }}.xml' -Dsuite=${{ github.event.inputs.test_suite }} -f 'e2e-tests' test -Pprod diff --git a/.github/workflows/e2e-run.yml b/.github/workflows/e2e-run.yml new file mode 100644 index 000000000..2d4a2a751 --- /dev/null +++ b/.github/workflows/e2e-run.yml @@ -0,0 +1,163 @@ +name: "E2E: Run tests" + +on: + workflow_call: + inputs: + suite_name: + description: 'Test suite name to run' + default: 'regression' + required: true + type: string + sha: + required: true + type: string + +permissions: + contents: read + checks: write + statuses: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ github.token }} + ref: ${{ inputs.sha }} + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'zulu' + cache: 'maven' + + - name: Build with Maven + id: build_app + run: | + ./mvnw -B -ntp versions:set -DnewVersion=${{ inputs.sha }} + ./mvnw -B -V -ntp clean install -Pprod -Dmaven.test.skip=true + + - name: Upload maven artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: ~/.m2/repository/io/kafbat/ui/**/* + retention-days: 7 + + - name: Dump docker image + run: | + docker image save ghcr.io/kafbat/kafka-ui:latest > /tmp/image.tar + + - name: Upload docker image + uses: actions/upload-artifact@v4 + with: + name: image + path: /tmp/image.tar + retention-days: 7 + + tests: + runs-on: ubuntu-latest + needs: build + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ github.token }} + ref: ${{ inputs.sha }} + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'zulu' + cache: 'maven' + + - name: Download maven artifacts + uses: actions/download-artifact@v4 + with: + name: artifacts + path: ~/.m2/repository/io/kafbat/ui + + - name: Download docker image + uses: actions/download-artifact@v4 + with: + name: image + path: /tmp + + - name: Load Docker image + run: | + docker load --input /tmp/image.tar + + - name: Cache Docker images. + uses: ScribeMD/docker-cache@0.5.0 + with: + key: docker-${{ runner.os }}-${{ hashFiles('./e2e-tests/selenoid/selenoid-ci.yaml', './documentation/compose/e2e-tests.yaml') }} + + - name: Compose up + id: compose_app + # use the following command until #819 will be fixed # TODO recheck 819 + run: | + mkdir -p ./e2e-tests/target/selenoid-results/video + mkdir -p ./e2e-tests/target/selenoid-results/logs + docker-compose -f ./e2e-tests/selenoid/selenoid-ci.yaml up -d + docker-compose -f ./documentation/compose/e2e-tests.yaml up -d + + - name: Run test suite + run: | + ./mvnw -B -ntp versions:set -DnewVersion=${{ inputs.sha }} + ./mvnw -B -V -ntp -Dsurefire.suiteXmlFiles='src/test/resources/${{ github.event.inputs.test_suite }}.xml' -f 'e2e-tests' test -Pprod + + - name: Dump Docker logs on failure + if: failure() + uses: jwalton/gh-docker-logs@v2.2.2 + + - name: Upload allure reports artifact + uses: actions/upload-artifact@v4 + with: + name: reports + path: ./e2e-tests/target/allure-results + retention-days: 7 + + reports: + runs-on: ubuntu-latest + needs: tests + if: ${{ github.repository == 'kafbat/kafka-ui' }} + steps: + - name: Download allure reports artifact + uses: actions/download-artifact@v4 + with: + name: reports + path: ./e2e-tests/target/allure-results + + - name: Generate Allure report + uses: simple-elf/allure-report-action@v1.9 + id: allure-report + with: + allure_results: ./e2e-tests/target/allure-results + gh_pages: allure-results + allure_report: allure-report + subfolder: allure-results + report_url: "https://reports.kafbat.dev" + + - name: Upload allure report to R2 + uses: ryand56/r2-upload-action@latest + with: + source-dir: allure-history/allure-results + destination-dir: . + r2-bucket: "reports" + r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} + r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} + r2-secret-access-key: ${{ secrets.R2_ACCESS_SECRET_KEY }} + + - name: Add allure link status check + uses: Sibz/github-status-action@v1.1.6 + with: + authToken: ${{secrets.GITHUB_TOKEN}} + context: "Click Details button to view Allure report" + state: "success" + sha: ${{ inputs.sha }} + target_url: https://reports.kafbat.dev/${{ github.run_number }} diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 72e7c92e1..245586751 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,6 +1,6 @@ name: "E2E: PR healthcheck" on: - pull_request_target: + pull_request: types: [ "opened", "reopened", "synchronize" ] paths: - "pom.xml" @@ -12,76 +12,13 @@ on: permissions: contents: read + checks: write statuses: write jobs: build-and-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - token: ${{ github.token }} - ref: ${{ github.event.pull_request.head.sha }} - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.S3_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.S3_AWS_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 - - name: Set up environment - id: set_env_values - run: | - cat "./e2e-tests/.env.ci" >> "./e2e-tests/.env" - - name: Pull with Docker - id: pull_chrome - run: | - docker pull selenoid/vnc_chrome:103.0 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'zulu' - cache: 'maven' - - name: Build with Maven - id: build_app - run: | - ./mvnw -B -ntp versions:set -DnewVersion=${{ github.event.pull_request.head.sha }} - ./mvnw -B -V -ntp clean install -Pprod -Dmaven.test.skip=true ${{ github.event.inputs.extraMavenOptions }} - - name: Compose with Docker - id: compose_app - # use the following command until #819 will be fixed - run: | - docker-compose -f e2e-tests/docker/selenoid-git.yaml up -d - docker-compose -f ./documentation/compose/e2e-tests.yaml up -d && until [ "$(docker exec kafbat-ui wget --spider --server-response http://localhost:8080/actuator/health 2>&1 | grep -c 'HTTP/1.1 200 OK')" == "1" ]; do echo "Waiting for kafka-ui ..." && sleep 1; done - - name: Run test suite - run: | - ./mvnw -B -ntp versions:set -DnewVersion=${{ github.event.pull_request.head.sha }} - ./mvnw -B -V -ntp -Dsurefire.suiteXmlFiles='src/test/resources/smoke.xml' -f 'e2e-tests' test -Pprod - - name: Generate allure report - uses: simple-elf/allure-report-action@master - if: always() - id: allure-report - with: - allure_results: ./e2e-tests/allure-results - gh_pages: allure-results - allure_report: allure-report - subfolder: allure-results - report_url: "http://kafkaui-allure-reports.s3-website.eu-central-1.amazonaws.com" - - uses: jakejarvis/s3-sync-action@master - if: always() - env: - AWS_S3_BUCKET: 'kafkaui-allure-reports' - AWS_REGION: 'eu-central-1' - SOURCE_DIR: 'allure-history/allure-results' - - name: Deploy report to Amazon S3 - if: always() - uses: Sibz/github-status-action@v1.1.6 - with: - authToken: ${{secrets.GITHUB_TOKEN}} - context: "Click Details button to open Allure report" - state: "success" - sha: ${{ github.event.pull_request.head.sha || github.sha }} - target_url: http://kafkaui-allure-reports.s3-website.eu-central-1.amazonaws.com/${{ github.run_number }} - - name: Dump docker logs on failure - if: failure() - uses: jwalton/gh-docker-logs@v2.2.2 + uses: ./.github/workflows/e2e-run.yml + secrets: inherit + with: + suite_name: "smoke" + sha: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/e2e-weekly.yml b/.github/workflows/e2e-weekly.yml index 0bb6e5bc3..6b25c4679 100644 --- a/.github/workflows/e2e-weekly.yml +++ b/.github/workflows/e2e-weekly.yml @@ -5,75 +5,13 @@ on: permissions: contents: read + checks: write + statuses: write jobs: build-and-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - token: ${{ github.token }} - ref: ${{ github.sha }} - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 - - name: Set up environment - id: set_env_values - run: | - cat "./e2e-tests/.env.ci" >> "./e2e-tests/.env" - - name: Pull with Docker - id: pull_chrome - run: | - docker pull selenoid/vnc_chrome:103.0 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'zulu' - cache: 'maven' - - name: Build with Maven - id: build_app - run: | - ./mvnw -B -ntp versions:set -DnewVersion=${{ github.sha }} - ./mvnw -B -V -ntp clean install -Pprod -Dmaven.test.skip=true ${{ github.event.inputs.extraMavenOptions }} - - name: Compose with Docker - id: compose_app - # use the following command until #819 will be fixed - run: | - docker-compose -f e2e-tests/docker/selenoid-git.yaml up -d - docker-compose -f ./documentation/compose/e2e-tests.yaml up -d - - name: Run test suite - run: | - ./mvnw -B -ntp versions:set -DnewVersion=${{ github.sha }} - ./mvnw -B -V -ntp -Dsurefire.suiteXmlFiles='src/test/resources/sanity.xml' -Dsuite=weekly -f 'e2e-tests' test -Pprod - - name: Generate Allure report - uses: simple-elf/allure-report-action@master - if: always() - id: allure-report - with: - allure_results: ./e2e-tests/allure-results - gh_pages: allure-results - allure_report: allure-report - subfolder: allure-results - report_url: "http://kafkaui-allure-reports.s3-website.eu-central-1.amazonaws.com" - - uses: jakejarvis/s3-sync-action@master - if: always() - env: - AWS_S3_BUCKET: 'kafkaui-allure-reports' - AWS_REGION: 'eu-central-1' - SOURCE_DIR: 'allure-history/allure-results' - - name: Deploy report to Amazon S3 - if: always() - uses: Sibz/github-status-action@v1.1.6 - with: - authToken: ${{secrets.GITHUB_TOKEN}} - context: "Click Details button to open Allure report" - state: "success" - sha: ${{ github.sha }} - target_url: http://kafkaui-allure-reports.s3-website.eu-central-1.amazonaws.com/${{ github.run_number }} - - name: Dump Docker logs on failure - if: failure() - uses: jwalton/gh-docker-logs@v2.2.2 + uses: ./.github/workflows/e2e-run.yml + secrets: inherit + with: + suite_name: "sanity" + sha: ${{ github.sha }} diff --git a/e2e-tests/pom.xml b/e2e-tests/pom.xml index cddcb8c0a..c9b6babba 100644 --- a/e2e-tests/pom.xml +++ b/e2e-tests/pom.xml @@ -26,131 +26,48 @@ org.apache.kafka kafka_2.13 ${kafka.version} - - - io.netty - netty-buffer - - - io.netty - netty-common - - - io.netty - netty-codec - - - io.netty - netty-handler - - - io.netty - netty-resolver - - - io.netty - netty-transport - - - io.netty - netty-transport-native-epoll - - - io.netty - netty-transport-native-unix-common - - io.kafbat.ui contract ${contract} - - - io.netty - netty-buffer - - - io.netty - netty-common - - - io.netty - netty-codec - - - io.netty - netty-handler - - - io.netty - netty-resolver - - - io.netty - netty-transport - - - io.netty - netty-transport-native-epoll - - - io.netty - netty-transport-native-unix-common - - - io.netty - netty-resolver-dns-native-macos - osx-aarch_64 - - org.aspectj aspectjweaver ${aspectj.version} - org.projectlombok lombok ${org.projectlombok.version} - commons-io commons-io 2.16.1 - org.testng testng 7.10.0 - com.codeborne selenide 7.2.3 - io.qameta.allure allure-testng ${allure.version} - io.qameta.allure allure-selenide ${allure.version} - io.github.bonigarcia webdrivermanager @@ -165,44 +82,14 @@ true - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.release} - - true - - - ${headless.state} - - ${selenoid.state} - - ${project.basedir}/target/allure-results - - - - - - org.apache.maven.surefire - surefire-testng - ${maven.surefire-testng} - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - + + true + prod - org.apache.maven.plugins maven-surefire-plugin diff --git a/e2e-tests/selenoid/config/browsers-github.json b/e2e-tests/selenoid/config/browsers-ci.json similarity index 100% rename from e2e-tests/selenoid/config/browsers-github.json rename to e2e-tests/selenoid/config/browsers-ci.json diff --git a/e2e-tests/selenoid/selenoid-github.yaml b/e2e-tests/selenoid/selenoid-ci.yaml similarity index 85% rename from e2e-tests/selenoid/selenoid-github.yaml rename to e2e-tests/selenoid/selenoid-ci.yaml index 94dfb88b1..578e6d621 100644 --- a/e2e-tests/selenoid/selenoid-github.yaml +++ b/e2e-tests/selenoid/selenoid-ci.yaml @@ -16,7 +16,7 @@ services: - OVERRIDE_VIDEO_OUTPUT_DIR=../docker/selenoid/video ports: - "4444:4444" - command: [ "-limit", "5", "-conf", "/etc/selenoid/browsers-github.json", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs" ] + command: [ "-limit", "5", "-conf", "/etc/selenoid/browsers-ci.json", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs" ] # https://github.com/aerokube/selenoid-ui/releases selenoid-ui: diff --git a/e2e-tests/src/test/resources/regression.xml b/e2e-tests/src/test/resources/regression.xml index 3535b5ea6..65977da9f 100644 --- a/e2e-tests/src/test/resources/regression.xml +++ b/e2e-tests/src/test/resources/regression.xml @@ -1,6 +1,6 @@ - + diff --git a/e2e-tests/src/test/resources/sanity.xml b/e2e-tests/src/test/resources/sanity.xml index 0511c18ef..c4c4ac5a2 100644 --- a/e2e-tests/src/test/resources/sanity.xml +++ b/e2e-tests/src/test/resources/sanity.xml @@ -1,6 +1,6 @@ - + diff --git a/e2e-tests/src/test/resources/smoke.xml b/e2e-tests/src/test/resources/smoke.xml index 6e35cf411..0916aa18d 100644 --- a/e2e-tests/src/test/resources/smoke.xml +++ b/e2e-tests/src/test/resources/smoke.xml @@ -1,6 +1,6 @@ - +