Skip to content

Commit

Permalink
test: added test workflow for NA (#2892)
Browse files Browse the repository at this point in the history
* test: added test workflow for NA

* fix: handled review comments

* fix
  • Loading branch information
Aleksey28 committed May 16, 2023
1 parent b10bd8c commit 7074ba2
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-to-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/test-functional-testcafe-native-automation.yml
Original file line number Diff line number Diff line change
@@ -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'
19 changes: 19 additions & 0 deletions .github/workflows/test-functional-testcafe-proxy.yml
Original file line number Diff line number Diff line change
@@ -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'
45 changes: 28 additions & 17 deletions .github/workflows/test-functional-testcafe.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -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';
}
Expand Down
11 changes: 9 additions & 2 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

5 changes: 0 additions & 5 deletions test/functional/run-testcafe-functional-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7074ba2

Please sign in to comment.