|
1 | 1 | name: E2E Tests
|
| 2 | + |
2 | 3 | on:
|
3 | 4 | push:
|
4 |
| - branches: |
5 |
| - - main |
6 | 5 | pull_request:
|
7 |
| - types: [ opened, synchronize, reopened ] |
8 | 6 | merge_group:
|
9 |
| - workflow_dispatch: |
10 |
| - inputs: |
11 |
| - dispatch: |
12 |
| - type: string |
13 |
| - description: "Dispatch contains pr context that want to trigger e2e test" |
14 |
| - required: true |
| 7 | + |
| 8 | +# Ensure that only a single job or workflow using the same concurrency group will run at a time. |
| 9 | +# see https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + # only needs to test the group's latest commit |
| 13 | + cancel-in-progress: true |
15 | 14 |
|
16 | 15 | jobs:
|
17 |
| - dispatch-build: |
18 |
| - if: contains(github.event_name, 'workflow_dispatch') |
19 |
| - runs-on: ubuntu-latest |
20 |
| - outputs: |
21 |
| - output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }} |
| 16 | + e2e-test: |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + # Supported GitHub-hosted runners and hardware resources |
| 20 | + # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources |
| 21 | + os: [ubuntu-22.04] |
| 22 | + fail-fast: false |
| 23 | + runs-on: ${{ matrix.os }} |
| 24 | + |
22 | 25 | steps:
|
23 |
| - - name: Generate axon-bot token |
24 |
| - if: contains(github.event_name, 'workflow_dispatch') && |
25 |
| - github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression' |
26 |
| - id: generate_axon_bot_token |
27 |
| - uses: wow-actions/use-app-token@v2 |
28 |
| - with: |
29 |
| - app_id: ${{ secrets.AXON_BOT_APP_ID }} |
30 |
| - private_key: ${{ secrets.AXON_BOT_PRIVATE_KEY }} |
31 |
| - - name: Event is dispatch |
32 |
| - if: contains(github.event_name, 'workflow_dispatch') && |
33 |
| - github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression' |
34 |
| - uses: actions/github-script@v6 |
35 |
| - id: get_sha |
36 |
| - with: |
37 |
| - github-token: ${{ steps.generate_axon_bot_token.outputs.BOT_TOKEN }} |
38 |
| - script: | |
39 |
| - const dispatch = JSON.parse(`${{ github.event.inputs.dispatch }}`); |
40 |
| - const pr = ( |
41 |
| - await github.rest.pulls.get({ |
42 |
| - owner: dispatch.repo.owner, |
43 |
| - repo: dispatch.repo.repo, |
44 |
| - pull_number: dispatch.issue.number, |
45 |
| - }) |
46 |
| - ).data.head; |
47 |
| - github.rest.repos.createCommitStatus({ |
48 |
| - state: 'pending', |
49 |
| - owner: dispatch.repo.owner, |
50 |
| - repo: dispatch.repo.repo, |
51 |
| - context: '${{ github.workflow }}', |
52 |
| - sha: pr.sha, |
53 |
| - target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
54 |
| - }) |
55 |
| - return pr.sha |
56 |
| - - name: Escape multiple lines test inputs |
57 |
| - if: contains(github.event_name, 'workflow_dispatch') && |
58 |
| - github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression' |
59 |
| - id: escape_multiple_lines_test_inputs |
60 |
| - run: | |
61 |
| - inputs=${{ steps.get_sha.outputs.result}} |
62 |
| - inputs="${inputs//'%'/'%25'}" |
63 |
| - inputs="${inputs//'\n'/'%0A'}" |
64 |
| - inputs="${inputs//'\r'/'%0D'}" |
65 |
| - echo "result=$inputs" >> $GITHUB_OUTPUT |
66 |
| - - name: Git checkout |
67 |
| - uses: actions/checkout@v4 |
68 |
| - with: |
69 |
| - ref: ${{ steps.escape_multiple_lines_test_inputs.outputs.result || 'main' }} |
70 |
| - - uses: lyricwulf/abc@v1 |
71 |
| - with: |
72 |
| - linux: m4 |
| 26 | + - uses: actions/checkout@v4 |
73 | 27 |
|
74 |
| - - name: Use Node.js ${{ matrix.node-version }} |
75 |
| - uses: actions/setup-node@v3 |
| 28 | + - name: Cache of Cargo |
| 29 | + uses: actions/cache@v3 |
76 | 30 | with:
|
77 |
| - node-version: "16" |
78 |
| - cache: "yarn" |
79 |
| - cache-dependency-path: "tests/e2e/yarn.lock" |
80 |
| - |
81 |
| - - name: E2E Tests Linting |
82 |
| - run: make e2e-test-lint |
| 31 | + path: | |
| 32 | + ~/.cargo/bin/ |
| 33 | + ~/.cargo/registry/index/ |
| 34 | + ~/.cargo/registry/cache/ |
| 35 | + ~/.cargo/git/db/ |
| 36 | + target/ |
| 37 | + key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build |
| 40 | + ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo |
83 | 41 |
|
84 |
| - - name: E2E Tests |
85 |
| - run: make e2e-test-ci |
86 |
| - finally: |
87 |
| - name: Finally |
88 |
| - needs: [ dispatch-build ] |
89 |
| - if: always() && contains(github.event_name, 'workflow_dispatch') && |
90 |
| - github.event.inputs.dispatch != 'regression' && github.repository_owner == 'axonweb3' |
91 |
| - runs-on: ubuntu-latest |
92 |
| - steps: |
93 |
| - - name: Generate axon-bot token |
94 |
| - id: generate_axon_bot_token |
95 |
| - uses: wow-actions/use-app-token@v2 |
96 |
| - with: |
97 |
| - app_id: ${{ secrets.AXON_BOT_APP_ID }} |
98 |
| - private_key: ${{ secrets.AXON_BOT_PRIVATE_KEY }} |
99 |
| - - if: contains(join(needs.*.result, ';'), 'failure') || contains(join(needs.*.result, ';'), 'cancelled') |
100 |
| - run: exit 1 |
101 |
| - - uses: actions/github-script@v6 |
102 |
| - if: ${{ always() }} |
103 |
| - with: |
104 |
| - github-token: ${{ steps.generate_axon_bot_token.outputs.BOT_TOKEN }} |
105 |
| - script: | |
106 |
| - github.rest.repos.createCommitStatus({ |
107 |
| - state: '${{ job.status }}', |
108 |
| - owner: context.repo.owner, |
109 |
| - repo: context.repo.repo, |
110 |
| - context: '${{ github.workflow }}', |
111 |
| - sha: '${{ needs.dispatch-build.outputs.output-sha }}', |
112 |
| - target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
113 |
| - }) |
114 |
| - build: |
115 |
| - if: | |
116 |
| - (contains(fromJson('["dependabot[bot]" ]'), github.actor) && github.event_name == 'pull_request') || |
117 |
| - (contains(github.event_name, 'push') && github.ref == 'refs/heads/main' ) |
118 |
| - runs-on: ubuntu-latest |
119 |
| - steps: |
120 |
| - - uses: actions/checkout@v4 |
121 | 42 | - uses: lyricwulf/abc@v1
|
122 | 43 | with:
|
| 44 | + # https://www.gnu.org/software/m4/ |
123 | 45 | linux: m4
|
124 | 46 |
|
125 |
| - - name: Use Node.js ${{ matrix.node-version }} |
| 47 | + # TODO: use Node.js 18 |
| 48 | + - name: Use Node.js 16 |
126 | 49 | uses: actions/setup-node@v3
|
127 | 50 | with:
|
128 | 51 | node-version: "16"
|
129 |
| - cache: "yarn" |
130 |
| - cache-dependency-path: "tests/e2e/yarn.lock" |
| 52 | + - name: Get yarn cache directory |
| 53 | + id: yarn-cache-dir |
| 54 | + run: echo "dir=$(yarn cache dir)" >> ${GITHUB_OUTPUT} |
| 55 | + - name: Get npm cache directory |
| 56 | + id: npm-cache-dir |
| 57 | + shell: bash |
| 58 | + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} |
| 59 | + - name: Node Cache |
| 60 | + uses: actions/cache@v3 |
| 61 | + id: npm-and-yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 62 | + with: |
| 63 | + path: | |
| 64 | + ${{ steps.yarn-cache-dir.outputs.dir }} |
| 65 | + ${{ steps.npm-cache-dir.outputs.dir }} |
| 66 | + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }} |
| 67 | + restore-keys: | |
| 68 | + ${{ runner.os }}-node_modules- |
131 | 69 |
|
132 |
| - - name: E2E Tests Linting |
| 70 | + - name: E2E Tests Linting in tests/e2e |
133 | 71 | run: make e2e-test-lint
|
134 |
| - |
135 |
| - - name: E2E Tests |
| 72 | + - name: E2E Tests in tests/e2e |
136 | 73 | run: make e2e-test-ci
|
0 commit comments