From 7074ba29546cb1ed6cf92e7ab8d68f5c461616ad Mon Sep 17 00:00:00 2001 From: Popov Aleksey Date: Tue, 16 May 2023 05:19:33 +0300 Subject: [PATCH] test: added test workflow for NA (#2892) * test: added test workflow for NA * fix: handled review comments * fix --- .github/workflows/deploy-to-artifacts.yml | 3 +- ...-functional-testcafe-native-automation.yml | 19 ++++++++ .../test-functional-testcafe-proxy.yml | 19 ++++++++ .../workflows/test-functional-testcafe.yml | 45 ++++++++++++------- Gulpfile.js | 11 ++++- .../run-testcafe-functional-tests.sh | 5 --- 6 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/test-functional-testcafe-native-automation.yml create mode 100644 .github/workflows/test-functional-testcafe-proxy.yml diff --git a/.github/workflows/deploy-to-artifacts.yml b/.github/workflows/deploy-to-artifacts.yml index cf1f176f0..a8e5a87ae 100644 --- a/.github/workflows/deploy-to-artifacts.yml +++ b/.github/workflows/deploy-to-artifacts.yml @@ -107,7 +107,8 @@ jobs: tasks.push('test-client-cloud.yml'); - tasks.push('test-functional-testcafe.yml'); + tasks.push('test-functional-testcafe-proxy.yml'); + tasks.push('test-functional-testcafe-native-automation.yml'); tasks.push('test-server-minimum.yml'); tasks.push('test-server-latest.yml'); diff --git a/.github/workflows/test-functional-testcafe-native-automation.yml b/.github/workflows/test-functional-testcafe-native-automation.yml new file mode 100644 index 000000000..f3007afb4 --- /dev/null +++ b/.github/workflows/test-functional-testcafe-native-automation.yml @@ -0,0 +1,19 @@ +name: Test Functional Native Automation (TestCafe) + +on: + workflow_dispatch: + inputs: + sha: + description: 'The test commit SHA or ref' + required: true + default: 'master' + merged_sha: + description: 'The merge commit SHA' + deploy_run_id: + description: 'The ID of a deployment workspace run with artifacts' +jobs: + test: + uses: ./.github/workflows/test-functional-testcafe.yml + with: + test-script: 'npx gulp test-functional-testcafe-native-automation --no-build' + testcafe-gulp-task: 'test-functional-local-native-automation' \ No newline at end of file diff --git a/.github/workflows/test-functional-testcafe-proxy.yml b/.github/workflows/test-functional-testcafe-proxy.yml new file mode 100644 index 000000000..709b6b186 --- /dev/null +++ b/.github/workflows/test-functional-testcafe-proxy.yml @@ -0,0 +1,19 @@ +name: Test Functional Proxy (TestCafe) + +on: + workflow_dispatch: + inputs: + sha: + description: 'The test commit SHA or ref' + required: true + default: 'master' + merged_sha: + description: 'The merge commit SHA' + deploy_run_id: + description: 'The ID of a deployment workspace run with artifacts' +jobs: + test: + uses: ./.github/workflows/test-functional-testcafe.yml + with: + test-script: 'npx gulp test-functional-testcafe-proxy --no-build' + testcafe-gulp-task: 'test-functional-local-headless-chrome' \ No newline at end of file diff --git a/.github/workflows/test-functional-testcafe.yml b/.github/workflows/test-functional-testcafe.yml index bf3e510cd..37d378890 100644 --- a/.github/workflows/test-functional-testcafe.yml +++ b/.github/workflows/test-functional-testcafe.yml @@ -1,22 +1,33 @@ -name: Test Functional (TestCafe) +name: Test Functional Proxy (TestCafe) on: - workflow_dispatch: + workflow_call: inputs: - sha: - description: 'The test commit SHA or ref' + test-script: required: true - default: 'master' - merged_sha: - description: 'The merge commit SHA' - deploy_run_id: - description: 'The ID of a deployment workspace run with artifacts' - test-groups-count: + type: string + testcafe-gulp-task: + required: true + type: string + node-version: + required: false + type: number + default: 16 + matrix-jobs-count: required: false type: number default: 3 + retry_failed_tests: + required: false + type: boolean + default: true + timeout: + required: false + type: number + default: 25 env: NO_CACHE: ${{ secrets.NO_CACHE }} + GULP_TASK: ${{ inputs.testcafe-gulp-task }} jobs: prepare-matrix: @@ -28,7 +39,7 @@ jobs: id: generate-matrix with: script: | - return Array.from({length: ${{ github.event.inputs.test-groups-count }}}, (_, i) => i + 1) + return Array.from({length: ${{ inputs.matrix-jobs-count }}}, (_, i) => i + 1) test: needs: prepare-matrix @@ -39,8 +50,8 @@ jobs: matrix: test-group: ${{ fromJSON(needs.prepare-matrix.outputs.matrix) }} env: - RETRY_FAILED_TESTS: true - TEST_GROUPS_COUNT: ${{ github.event.inputs.test-groups-count }} + RETRY_FAILED_TESTS: ${{ inputs.retry_failed_tests }} + TEST_GROUPS_COUNT: ${{ inputs.matrix-jobs-count }} TEST_GROUP_NUMBER: ${{ matrix.test-group }} outputs: # Matrix jobs cannot collect outputs about each of them automatically. It rewrites the same outputs. Improve it once it will be possible. @@ -57,7 +68,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: ${{ inputs.node-version }} - uses: DevExpress/testcafe-build-system/actions/read-artifacts@main with: @@ -76,8 +87,8 @@ jobs: restore-keys: | ${{ runner.os }}-node- - run: npm ci - - run: npx gulp test-functional-testcafe --no-build - timeout-minutes: 60 + - run: ${{ inputs.test-script }} + timeout-minutes: ${{ inputs.timeout }} - name: Save result id: save-result if: always() @@ -96,7 +107,7 @@ jobs: result-encoding: string script: | const statuses = ${{ toJSON(needs.test.outputs.*) }}; - for (let i = 0; i < ${{ github.event.inputs.test-groups-count }}; i++) { + for (let i = 0; i < ${{ inputs.matrix-jobs-count }}; i++) { if (statuses[i] !== 'success') return 'failure'; } diff --git a/Gulpfile.js b/Gulpfile.js index 619bccd1f..639d97bf0 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -220,10 +220,17 @@ gulp.step('cached-http-playground-server', () => { gulp.task('cached-http-playground', gulp.series(BUILD_TASK, 'cached-http-playground-server')); -gulp.step('test-functional-testcafe-run', gulpRunCommand([ +gulp.step('test-functional-testcafe-proxy-run', gulpRunCommand([ 'chmod +x ./test/functional/run-testcafe-functional-tests.sh', './test/functional/run-testcafe-functional-tests.sh', ])); -gulp.task('test-functional-testcafe', gulp.series(BUILD_TASK, 'test-functional-testcafe-run')); +gulp.task('test-functional-testcafe-proxy', gulp.series(BUILD_TASK, 'test-functional-testcafe-proxy-run')); + +gulp.step('test-functional-testcafe-native-automation-run', gulpRunCommand([ + 'chmod +x ./test/functional/run-testcafe-functional-tests.sh', + './test/functional/run-testcafe-functional-tests.sh', +])); + +gulp.task('test-functional-testcafe-native-automation', gulp.series(BUILD_TASK, 'test-functional-testcafe-native-automation-run')); diff --git a/test/functional/run-testcafe-functional-tests.sh b/test/functional/run-testcafe-functional-tests.sh index 584b7a08d..5e9ef9192 100644 --- a/test/functional/run-testcafe-functional-tests.sh +++ b/test/functional/run-testcafe-functional-tests.sh @@ -4,11 +4,6 @@ mkdir ../testcafe cd ../testcafe git clone https://github.com/DevExpress/testcafe . -# NOTE: testcafe's Gulpfile.js tries to alias the 'travis' task to the value of GULP_TASK -# We should define a valid testcafe's task in GULP_TASK before running 'npm install', -# which automatically builds testcafe with Gulp. -export GULP_TASK="test-functional-local-headless-chrome" - npm install testcafe-hammerhead ../testcafe-hammerhead --save npm i --loglevel error