@@ -2,79 +2,84 @@ name: Run automated end-to-end tests
22
33on :
44 push :
5- branches : [master ]
5+ branches : [main ]
66
77 pull_request :
8- branches : [master]
8+ branches : [main]
9+
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.ref }}
12+ cancel-in-progress : true
913
1014jobs :
15+ harden-security :
16+ name : Check SHA in GH Actions
17+ runs-on : ubuntu-latest
18+
19+ steps :
20+ - uses : actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
21+ - uses : zgosalvez/github-actions-ensure-sha-pinned-actions@570fff1eb64d52ffae87990c117c2748c317b58c # v2.0.0
22+
1123 test :
12- name : " Automated tests"
24+ # Run job only if it's push to main or PR from web-widgets, don't run for fork PRs
25+ if : >-
26+ ${{ github.event_name == 'push' ||
27+ github.event_name == 'pull_request' &&
28+ github.event.pull_request.head.repo.full_name == 'mendix/web-widgets' }}
29+ name : Automated tests
1330 runs-on : ubuntu-latest
31+ needs : [harden-security]
32+
1433 permissions :
1534 packages : read
1635 contents : read
36+
1737 strategy :
1838 # when one test fails, DO NOT cancel the other
1939 fail-fast : false
2040 matrix :
2141 # run 3 copies of the current job in parallel
22- containers : [0, 1, 2]
42+ index : [0, 1, 2]
2343
2444 steps :
25- - name : " Checking changed files"
26- id : files
27- uses : softprops/diffset@d5947696689a571f7a984a52505e2649eead5c22 # v1
28- if : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
29- with :
30- global_files : |
31- !{packages/**/*,configs/e2e/*.json,detox/**/*,scripts/**/*,data/**/*}
32- not_atlas_native_files : |
33- !packages/theming/atlas/src/**/native/**
34- env :
35- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
36- - name : " Checking-out code"
37- uses : actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2
45+ - name : Checkout
46+ uses : actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
3847 with :
39- submodules : false
40- - name : " Fetching master to compare"
41- if : github.event_name == 'pull_request' && (steps.files.outputs.global_files == '' || github.event.pull_request.head.repo.full_name != github.repository)
42- run : git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
43- - name : " Defining environment variables"
44- id : variables
45- run : echo ::set-output name=arg::$(if [ "${{ steps.files.outputs.global_files }}" = "" ] && ${{ github.event_name == 'pull_request' }}; then echo '--since origin/${{ github.base_ref }}'; else echo ''; fi)
46- - name : " Defining cache"
47- uses : actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v2
48- env :
49- cache-name : cache-node-modules
48+ fetch-depth : 0
49+ - name : Setup pnpm
50+ uses : pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # v2.2.4
5051 with :
51- path : ~/.npm
52- key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
53- - name : " Defining node version"
54- uses : actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v2
52+ version : ^7.13.4
53+ - name : Setup node
54+ uses : actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1
5555 with :
5656 node-version-file : " .nvmrc"
57- - name : " Installing dependencies "
58- run : npm install
59- - name : Login to GitHub Container Registry
60- if : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
61- uses : docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
57+ cache : " pnpm "
58+ - name : Get sha of main
59+ run : echo "main_sha=$(git rev-parse origin/main)" >> ${{ runner.os == 'Windows' && '$env:GITHUB_ENV' || '$GITHUB_ENV' }}
60+ - name : Restore Turbo Cache
61+ uses : actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
6262 with :
63- registry : ghcr.io
64- username : ${{ github.actor }}
65- password : ${{ secrets.GITHUB_TOKEN }}
63+ path : node_modules/.cache/turbo
64+ key : turbo-cache-${{ runner.os }}-e2e-chunk-${{ matrix.index }}-${{ env.main_sha }}
65+ restore-keys : |
66+ turbo-cache-${{ runner.os }}-e2e-chunk-${{ matrix.index }}
67+ - name : Install dependencies
68+ run : pnpm install
6669 - name : " Executing E2E tests"
67- if : github.event_name == 'push' || steps.files.outputs.not_atlas_native_files != '' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
68- run : CIRCLE_NODE_INDEX=${{ matrix.containers }} npm run test:e2e -- ${{ steps.variables.outputs.arg }}
69- env :
70- FORKED : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
70+ run : >-
71+ node
72+ ./automation/run-e2e/bin/run-e2e-in-chunks.mjs
73+ --chunks 3
74+ --index ${{ matrix.index }}
75+ --event-name ${{ github.event_name }}
7176 - name : " Fixing files permissions"
7277 if : failure()
7378 run : |
7479 sudo find ${{ github.workspace }}/packages/* -type d -exec chmod 755 {} \;
7580 sudo find ${{ github.workspace }}/packages/* -type f -exec chmod 644 {} \;
7681 - name : " Archive test screenshot diff results"
77- uses : actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2
82+ uses : actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
7883 if : failure()
7984 with :
8085 name : test-screenshot-results
0 commit comments