diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 690d07eafdf..35ca6695a71 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -16,7 +16,7 @@ extended test - backstop ``` ``` -extended test - tiger-cypress - integrated +extended test - integrated extended test - isolated extended test - record ``` diff --git a/.github/workflows/pull-request-comment.yaml b/.github/workflows/pull-request-comment.yaml index 75d14f4fba2..4d6a7f983ad 100644 --- a/.github/workflows/pull-request-comment.yaml +++ b/.github/workflows/pull-request-comment.yaml @@ -51,7 +51,7 @@ jobs: env: COMMENT: ${{ github.event.comment.body }} - e2e-run: + e2e-run-isolated: needs: [get-pr-info] if: ${{ github.event.comment.body == 'extended test - isolated' }} permissions: @@ -75,11 +75,22 @@ jobs: source-ref: ${{ needs.get-pr-info.outputs.sha }} secrets: inherit + e2e-integrated: + needs: [guard] + if: ${{ github.event.comment.body == 'extended test - integrated' }} + permissions: + id-token: write + contents: read + pull-requests: read + uses: ./.github/workflows/rw-rush-build-e2e-tests-integrated.yml + with: + source-ref: ${{ needs.get-pr-info.outputs.sha }} + secrets: inherit comment-pr: permissions: pull-requests: write - needs: [e2e-run,e2e-record] + needs: [e2e-run-isolated,e2e-record,e2e-integrated] if: ${{ !cancelled() && startsWith(github.event.comment.body, 'extended test') }} runs-on: group: infra1-runners-arc @@ -92,7 +103,18 @@ jobs: const issue_number = context.issue.number; const repository = context.repo; const url = `https://github.com/${repository.owner}/${repository.repo}/actions/runs/${context.runId}`; - const testResult = process.env.COMMENT === 'extended test - isolated' ? process.env.TEST_RESULT : process.env.TEST_RESULT_RECORD; + + let testResult; + if (process.env.COMMENT === 'extended test - isolated') { + testResult = process.env.TEST_RESULT_ISOLATED; + } + if (process.env.COMMENT === 'extended test - record') { + testResult = process.env.TEST_RESULT_RECORD; + } + if (process.env.COMMENT === 'extended test - integrated') { + testResult = process.env.TEST_RESULT_INTEGRATED; + } + const icon = testResult === 'success' ? '✅' : '❌'; const message = `${icon} "${process.env.COMMENT}" finished with result **${testResult}**. Check the results [here](${url}).`; github.rest.issues.createComment({ @@ -103,5 +125,6 @@ jobs: }); env: COMMENT: ${{ github.event.comment.body }} - TEST_RESULT: ${{ needs.e2e-run.result }} + TEST_RESULT_ISOLATED: ${{ needs.e2e-run-isolated.result }} TEST_RESULT_RECORD: ${{ needs.e2e-record.result }} + TEST_RESULT_INTEGRATED: ${{ needs.e2e-integrated.result }} diff --git a/.github/workflows/rw-rush-build-e2e-tests-integrated.yml b/.github/workflows/rw-rush-build-e2e-tests-integrated.yml new file mode 100644 index 00000000000..d453d6830f7 --- /dev/null +++ b/.github/workflows/rw-rush-build-e2e-tests-integrated.yml @@ -0,0 +1,103 @@ +name: rw ~ rush ~ e2e tests integrated +on: + workflow_call: + inputs: + filter: + required: false + description: "List of spec files to filter" + type: string + source-ref: + required: false + description: "source ref of the current code" + type: string + +jobs: + warm-up-cache: + runs-on: + group: infra1-runners-arc + labels: runners-cxa-xlarge + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.source-ref }} + fetch-depth: 2 + - name: Git config user + uses: snow-actions/git-config-user@v1.0.0 + with: + name: git-action + email: git-action@gooddata.com + - name: Warmup rush + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + uses: ./.github/actions/rush/warm-up-rush + build: + needs: [warm-up-cache] + runs-on: + group: infra1-runners-arc + labels: runners-rxa-xlarge + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.source-ref }} + fetch-depth: 2 + - name: Git config user + uses: snow-actions/git-config-user@v1.0.0 + with: + name: git-action + email: git-action@gooddata.com + - name: Debug + run: git log -1 + - name: Setup rush + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + uses: ./.github/actions/rush/set-up-rush + - name: Rush build + run: node common/scripts/install-run-rush.js build --to @gooddata/sdk-ui-tests-e2e + + e2e: + needs: [warm-up-cache,build] + runs-on: + group: infra1-runners-arc + labels: runners-rxa-xlarge + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.source-ref }} + fetch-depth: 2 + - name: Git config user + uses: snow-actions/git-config-user@v1.0.0 + with: + name: git-action + email: git-action@gooddata.com + - name: Setup rush + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + uses: ./.github/actions/rush/set-up-rush + - name: Rush build + run: | + node common/scripts/install-run-rush.js build --to @gooddata/sdk-ui-tests-e2e + - name: Rush generate dynamic files related to build + run: node common/scripts/install-run-rush.js build-generate-version + - name: Run e2e tests + run: | + export RUN_ON_GH=true + export TEST_BACKEND=https://staging-automation.dev-latest.stg11.panther.intgdc.com + export TIGER_DATASOURCES_NAME=pg_staging-goodsales + export EXECUTOR_NUMBER=$GH_RUN_ID + if [ -n "$USER_FILTER" ]; then + export FILTER=$USER_FILTER + fi + echo "Running with FILTER=$FILTER" + ./common/scripts/ci/run_cypress_integrated_tests.sh + env: + GH_RUN_ID: ${{ github.run_id }} + TIGER_API_TOKEN: ${{ secrets.AWS_STAGING_TEST_API_TOKEN }} + USER_FILTER: ${{ inputs.filter }} + - name: Archive the cypress test artifacts + uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: cypress-test-artifacts + path: | + libs/sdk-ui-tests-e2e/recordings/mappings/**/*.spec.ts.json + libs/sdk-ui-tests-e2e/cypress/videos/**/*.mp4 diff --git a/common/scripts/ci/run_cypress_integrated_tests.sh b/common/scripts/ci/run_cypress_integrated_tests.sh index 20fbf0288d0..fd7c3b89e80 100755 --- a/common/scripts/ci/run_cypress_integrated_tests.sh +++ b/common/scripts/ci/run_cypress_integrated_tests.sh @@ -14,6 +14,7 @@ fi export TEST_BACKEND_NO_PREFIX=$(sed <<< $TEST_BACKEND -E "s#^https?:\/\/##") +if [[ $RUN_ON_GH != "true" ]]; then pushd $E2E_TEST_DIR cat > .env <<-EOF HOST=${TEST_BACKEND:-} @@ -26,16 +27,31 @@ cat >> .env <<-EOF TIGER_API_TOKEN=${TIGER_API_TOKEN:?} TIGER_DATASOURCES_NAME=${TIGER_DATASOURCES_NAME:?} EOF +else + export HOST=${TEST_BACKEND} + export TEST_BACKEND=${TEST_BACKEND:-} + export CYPRESS_TEST_TAGS=post-merge_integrated_tiger + export FIXTURE_TYPE=goodsales + export FILTER=${FILTER:-} + export TIGER_API_TOKEN=${TIGER_API_TOKEN:?} + export TIGER_DATASOURCES_NAME=${TIGER_DATASOURCES_NAME:?} +fi -$_RUSH install -$_RUSH build -t sdk-ui-tests-e2e -$_RUSHX libs/sdk-ui-tests-e2e create-ref-workspace -WORKSPACE_CREATED=true -DELETE_MODE="${DELETE_MODE:-delete_always}" - -$_RUSHX libs/sdk-ui-tests-e2e build-scenarios +if [[ $RUN_ON_GH != "true" ]]; then + $_RUSH install + $_RUSH build -t sdk-ui-tests-e2e + $_RUSHX libs/sdk-ui-tests-e2e create-ref-workspace + WORKSPACE_CREATED=true + DELETE_MODE="${DELETE_MODE:-delete_always}" -export IMAGE_ID=tiger-gooddata-ui-sdk-scenarios-${EXECUTOR_NUMBER} + $_RUSHX libs/sdk-ui-tests-e2e build-scenarios +else + (cd libs/sdk-ui-tests-e2e && node ../../common/scripts/install-run-rushx.js create-ref-workspace) + WORKSPACE_CREATED=true + DELETE_MODE="${DELETE_MODE:-delete_always}" + (cd libs/sdk-ui-tests-e2e && node ../../common/scripts/install-run-rushx.js build-scenarios) +fi +export IMAGE_ID=tiger-gooddata-ui-sdk-scenarios-${EXECUTOR_NUMBER:-default} cleanup() { echo "Executing cleanup before exiting..." @@ -44,7 +60,11 @@ cleanup() { if [ $DELETE_MODE = "delete_never" ]; then echo "DELETE_MODE is delete_never, skip deleting the created workspace" else - $_RUSHX libs/sdk-ui-tests-e2e delete-ref-workspace + if [[ $RUN_ON_GH != "true" ]]; then + $_RUSHX libs/sdk-ui-tests-e2e delete-ref-workspace + else + (node $ROOT_DIR/common/scripts/install-run-rushx.js delete-ref-workspace) + fi fi fi rm -f $E2E_TEST_DIR/.env @@ -53,10 +73,14 @@ cleanup() { trap cleanup EXIT +if [[ $RUN_ON_GH == "true" ]]; then + pushd $E2E_TEST_DIR +fi + # Use Dockerfile_local as scenarios have been build in previous steps docker build --no-cache --file Dockerfile_local -t $IMAGE_ID . || exit 1 -PROJECT_NAME=tiger-sdk-ui-tests-e2e-${EXECUTOR_NUMBER} +PROJECT_NAME=tiger-sdk-ui-tests-e2e-${EXECUTOR_NUMBER:-default} NO_COLOR=1 docker-compose -f docker-compose-integrated.yaml -p "$PROJECT_NAME" up \ --abort-on-container-exit --exit-code-from integrated-tests \ --force-recreate --always-recreate-deps --renew-anon-volumes --no-color diff --git a/common/scripts/ci/run_cypress_isolated_tests.sh b/common/scripts/ci/run_cypress_isolated_tests.sh index 614015c097e..e9b2ede8d14 100755 --- a/common/scripts/ci/run_cypress_isolated_tests.sh +++ b/common/scripts/ci/run_cypress_isolated_tests.sh @@ -18,18 +18,8 @@ CYPRESS_TEST_TAGS=pre-merge_isolated_tiger FILTER=${FILTER:-} EOF -# remove this branch when run only from gh workflow -if [[ $RUN_ON_GH != "true" ]]; then - _RUSH="${DIR}/docker_rush.sh" - _RUSHX="${DIR}/docker_rushx.sh" - $_RUSH install - $_RUSH build -t sdk-ui-tests-e2e - $_RUSHX libs/sdk-ui-tests-e2e prepare-recording-workspace-id - $_RUSHX libs/sdk-ui-tests-e2e build-scenarios -else - (cd $ROOT_DIR/libs/sdk-ui-tests-e2e; npm run prepare-recording-workspace-id) - (cd $ROOT_DIR/libs/sdk-ui-tests-e2e; npm run build-scenarios) -fi +(cd $ROOT_DIR/libs/sdk-ui-tests-e2e; npm run prepare-recording-workspace-id) +(cd $ROOT_DIR/libs/sdk-ui-tests-e2e; npm run build-scenarios) # Use Dockerfile_local as scenarios have been build in previous steps export IMAGE_ID=tiger-gooddata-ui-sdk-scenarios-${EXECUTOR_NUMBER} diff --git a/common/scripts/ci/run_cypress_recording.sh b/common/scripts/ci/run_cypress_recording.sh index d61ae067c10..a2ce3620944 100755 --- a/common/scripts/ci/run_cypress_recording.sh +++ b/common/scripts/ci/run_cypress_recording.sh @@ -6,60 +6,25 @@ CYPRESS_IMAGE='020413372491.dkr.ecr.us-east-1.amazonaws.com/tools/gdc-frontend-c DIR=$(echo $(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P)) ROOT_DIR=$(echo $(cd $(dirname "${BASH_SOURCE[0]}")/../../../ && pwd -P)) E2E_TEST_DIR=$ROOT_DIR/libs/sdk-ui-tests-e2e -_RUSH="${DIR}/docker_rush.sh" -_RUSHX="${DIR}/docker_rushx.sh" -echo "⭐️ 1/8 Preparing .env for recording" +echo "⭐️ Preparing env for recording" if [[ ! "${TEST_BACKEND:?}" =~ 'https://' ]]; then export TEST_BACKEND="https://${TEST_BACKEND}" fi -if [[ $RUN_ON_GH != "true" ]]; then -_env_file='./libs/sdk-ui-tests-e2e/.env' -cat > $_env_file <<-EOF -HOST=$TEST_BACKEND -CYPRESS_TEST_TAGS=pre-merge_isolated_tiger -FIXTURE_TYPE=goodsales -FILTER=${CYPRESS_RECORDED_TEST:-} -EOF - -cat >> $_env_file <<-EOF -TIGER_API_TOKEN=${TIGER_API_TOKEN:?} -TIGER_DATASOURCES_NAME=${TIGER_DATASOURCES_NAME:?} -EOF -else - - export TIGER_DATASOURCES_NAME=vertica_staging-goodsales - export HOST=$TEST_BACKEND - export CYPRESS_TEST_TAGS=pre-merge_isolated_tiger - export FIXTURE_TYPE=goodsales - export FILTER=${FILTER:-} -fi +export TIGER_DATASOURCES_NAME=vertica_staging-goodsales +export HOST=$TEST_BACKEND +export CYPRESS_TEST_TAGS=pre-merge_isolated_tiger +export FIXTURE_TYPE=goodsales +export FILTER=${FILTER:-} +echo "⭐️ Create reference workspace" +(cd libs/sdk-ui-tests-e2e && node ../../common/scripts/install-run-rushx.js create-ref-workspace) -echo "⭐️ 1/8 Preparing .env for recording - Done" +echo "⭐️ Build gooddata-ui-sdk-scenarios" +(cd libs/sdk-ui-tests-e2e && node ../../common/scripts/install-run-rushx.js build-scenarios) -echo "⭐️ 2/8 Run rush install / build" -if [[ $RUN_ON_GH != "true" ]]; then - $_RUSH install - $_RUSH build -t sdk-ui-tests-e2e -fi - -echo "⭐️ 3/8 create reference workspace" -if [[ $RUN_ON_GH != "true" ]]; then - $_RUSHX libs/sdk-ui-tests-e2e create-ref-workspace -else - (cd libs/sdk-ui-tests-e2e && node ../../common/scripts/install-run-rushx.js create-ref-workspace) -fi - -echo "⭐️ 4/8 build gooddata-ui-sdk-scenarios" -if [[ $RUN_ON_GH != "true" ]]; then - $_RUSHX libs/sdk-ui-tests-e2e build-scenarios -else - (cd libs/sdk-ui-tests-e2e && node ../../common/scripts/install-run-rushx.js build-scenarios) -fi - -echo "⭐️ 5/8 build docker container from gooddata-ui-sdk-scenarios" +echo "⭐️ Build docker container from gooddata-ui-sdk-scenarios" export IMAGE_ID=tiger-gooddata-ui-sdk-scenarios-${EXECUTOR_NUMBER:-default} trap "docker rmi --force $IMAGE_ID || true" EXIT pushd $E2E_TEST_DIR @@ -67,7 +32,7 @@ rm -rf ./recordings/mappings mkdir -p ./recordings/mappings/TIGER docker build --no-cache --file Dockerfile_local -t $IMAGE_ID . || exit 1 -echo "⭐️ 6/8 Run isolated recording against TEST_BACKEND=$TEST_BACKEND." +echo "⭐️ Run isolated recording against TEST_BACKEND=$TEST_BACKEND." if [[ $RUN_ON_GH != "true" ]]; then export USER_UID=$(id -u $USER) export USER_GID=$(id -g $USER) @@ -77,9 +42,5 @@ MODE=record NO_COLOR=1 docker-compose -f docker-compose-isolated.yaml -p "$PROJE --abort-on-container-exit --exit-code-from isolated-tests \ --force-recreate --always-recreate-deps --renew-anon-volumes --no-color -echo "⭐️ 7/8 delete reference workspace on the host" -if [[ $RUN_ON_GH != "true" ]]; then - $_RUSHX libs/sdk-ui-tests-e2e delete-ref-workspace -else - node ../../common/scripts/install-run-rushx.js delete-ref-workspace -fi +echo "⭐️ Delete reference workspace on the host" +node $ROOT_DIR/common/scripts/install-run-rushx.js delete-ref-workspace diff --git a/libs/sdk-ui-tests-e2e/docker-compose-integrated.yaml b/libs/sdk-ui-tests-e2e/docker-compose-integrated.yaml index bf18cf9fd44..e6b2a3774c8 100644 --- a/libs/sdk-ui-tests-e2e/docker-compose-integrated.yaml +++ b/libs/sdk-ui-tests-e2e/docker-compose-integrated.yaml @@ -28,5 +28,7 @@ services: - TIGER_API_TOKEN - VISUAL_MODE=false - CYPRESS_TEST_TAGS + - FIXTURE_TYPE + - TIGER_DATASOURCES_NAME - NO_COLOR - EXECUTION_ENV=$EXECUTION_ENV