Skip to content

Commit

Permalink
Merge pull request #5646 from gooddata/pb-pr-integrated
Browse files Browse the repository at this point in the history
feat: integrated tests from pull-request comment
  • Loading branch information
pbenes authored Dec 3, 2024
2 parents 65a4627 + d59cdbd commit 9a77519
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extended test - backstop
```

```
extended test - tiger-cypress - integrated
extended test - integrated
extended test - isolated
extended test - record
```
31 changes: 27 additions & 4 deletions .github/workflows/pull-request-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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({
Expand All @@ -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 }}
103 changes: 103 additions & 0 deletions .github/workflows/rw-rush-build-e2e-tests-integrated.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
name: git-action
email: [email protected]
- 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/[email protected]
with:
name: git-action
email: [email protected]
- 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/[email protected]
with:
name: git-action
email: [email protected]
- 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
44 changes: 34 additions & 10 deletions common/scripts/ci/run_cypress_integrated_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:-}
Expand All @@ -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..."
Expand All @@ -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
Expand All @@ -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
14 changes: 2 additions & 12 deletions common/scripts/ci/run_cypress_isolated_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
67 changes: 14 additions & 53 deletions common/scripts/ci/run_cypress_recording.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,33 @@ 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
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)
Expand All @@ -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
2 changes: 2 additions & 0 deletions libs/sdk-ui-tests-e2e/docker-compose-integrated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9a77519

Please sign in to comment.