|
14 | 14 | type: number |
15 | 15 | required: false |
16 | 16 | default: 5 |
| 17 | + flag_prefix: |
| 18 | + type: string |
| 19 | + default: '' |
17 | 20 | env: |
18 | 21 | AR_REPO: ${{ inputs.repo }} |
19 | 22 |
|
20 | 23 | jobs: |
| 24 | + # Create a list from 1 to `inputs.split` to use as our matrix for `test` |
| 25 | + prepare_groups: |
| 26 | + name: Prepare groups |
| 27 | + runs-on: ubuntu-latest |
| 28 | + outputs: |
| 29 | + groups: ${{ steps.prepare_groups.outputs.groups }} |
| 30 | + # echo {1..5} => 1 2 3 4 5 |
| 31 | + # echo {1..5} | sed 's/ /, /g' => 1, 2, 3, 4, 5 |
| 32 | + # echo '[$(echo {1..5} | sed 's/ /, /g')]' => [1, 2, 3, 4, 5] |
| 33 | + steps: |
| 34 | + - name: Prepare groups |
| 35 | + id: prepare_groups |
| 36 | + run: | |
| 37 | + group_list=$(echo "[$(echo {1..${{ inputs.split }}} | sed 's/ /, /g')]") |
| 38 | + echo "groups=$group_list" >> $GITHUB_OUTPUT |
| 39 | +
|
21 | 40 | test: |
22 | 41 | name: Test |
23 | 42 | runs-on: ubuntu-latest |
| 43 | + needs: [prepare_groups] |
24 | 44 | strategy: |
25 | 45 | matrix: |
26 | | - group: [1, 2, 3, 4, 5] |
| 46 | + # Parse our group list into a JSON object |
| 47 | + group: ${{ fromJSON(needs.prepare_groups.outputs.groups) }} |
27 | 48 | steps: |
28 | 49 | - name: Checkout |
29 | 50 | uses: actions/checkout@v4 |
@@ -59,20 +80,103 @@ jobs: |
59 | 80 | if: inputs.run_integration == true |
60 | 81 | run: | |
61 | 82 | make test_env.run_integration GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }} |
62 | | - ## Don't upload on forks for now. |
63 | | - - name: upload using codecovcli |
64 | | - if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} |
65 | | - run: | |
66 | | - make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_URL }} |
67 | | - - name: upload using codecovcli staging |
68 | | - if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} |
69 | | - run: | |
70 | | - make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN_STAGING }} CODECOV_URL=${{ secrets.CODECOV_STAGING_URL }} |
71 | | - - name: upload using codecovcli qa |
72 | | - if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} |
73 | | - run: | |
74 | | - make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_QA_URL }} |
75 | | - - name: upload using codecovcli public qa |
76 | | - if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} |
77 | | - run: | |
78 | | - make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_PUBLIC_QA_URL }} |
| 83 | +
|
| 84 | + - uses: actions/upload-artifact@v4 |
| 85 | + if: ${{ !cancelled() }} |
| 86 | + with: |
| 87 | + name: coveragefiles-${{ matrix.group }} |
| 88 | + path: ./*.coverage.xml |
| 89 | + |
| 90 | + - uses: actions/upload-artifact@v4 |
| 91 | + if: ${{ !cancelled() }} |
| 92 | + with: |
| 93 | + name: junitfiles-${{ matrix.group }} |
| 94 | + path: ./*junit*.xml |
| 95 | + |
| 96 | + upload: |
| 97 | + name: Upload to Codecov |
| 98 | + runs-on: ubuntu-latest |
| 99 | + needs: [test] |
| 100 | + strategy: |
| 101 | + matrix: |
| 102 | + include: |
| 103 | + - codecov_url_secret: CODECOV_URL |
| 104 | + codecov_token_secret: CODECOV_ORG_TOKEN |
| 105 | + name: prod |
| 106 | + - codecov_url_secret: CODECOV_STAGING_URL |
| 107 | + codecov_token_secret: CODECOV_ORG_TOKEN_STAGING |
| 108 | + name: staging |
| 109 | + - codecov_url_secret: CODECOV_QA_URL |
| 110 | + codecov_token_secret: CODECOV_QA_ORG |
| 111 | + name: qa |
| 112 | + - codecov_url_secret: CODECOV_PUBLIC_QA_URL |
| 113 | + codecov_token_secret: CODECOV_PUBLIC_QA_TOKEN |
| 114 | + name: public qa |
| 115 | + |
| 116 | + steps: |
| 117 | + - name: Checkout |
| 118 | + uses: actions/checkout@v4 |
| 119 | + with: |
| 120 | + fetch-depth: 0 |
| 121 | + |
| 122 | + - name: Download coverage |
| 123 | + uses: actions/download-artifact@v4 |
| 124 | + with: |
| 125 | + pattern: coveragefiles-* |
| 126 | + merge-multiple: true |
| 127 | + |
| 128 | + - name: Download test results |
| 129 | + uses: actions/download-artifact@v4 |
| 130 | + with: |
| 131 | + pattern: junitfiles-* |
| 132 | + merge-multiple: true |
| 133 | + |
| 134 | + - name: Uploading unit test coverage (${{ matrix.name }}) |
| 135 | + uses: codecov/codecov-action@v5 |
| 136 | + with: |
| 137 | + files: ./unit.*.coverage.xml |
| 138 | + flags: ${{ format('{0}unit', inputs.flag_prefix) }} |
| 139 | + disable_search: true |
| 140 | + # Strange workaround: API has a `codecov` directory in the repo root |
| 141 | + # which conflicts with the action's `codecov` binary |
| 142 | + use_pypi: true |
| 143 | + token: ${{ secrets[matrix.codecov_token_secret] }} |
| 144 | + url: ${{ secrets[matrix.codecov_url_secret] }} |
| 145 | + |
| 146 | + - name: Uploading integration test coverage (${{ matrix.name }}) |
| 147 | + if: ${{ inputs.run_integration == true }} |
| 148 | + uses: codecov/codecov-action@v5 |
| 149 | + with: |
| 150 | + files: ./integration.*.coverage.xml |
| 151 | + flags: ${{ format('{0}integration', inputs.flag_prefix) }} |
| 152 | + disable_search: true |
| 153 | + # Strange workaround: API has a `codecov` directory in the repo root |
| 154 | + # which conflicts with the action's `codecov` binary |
| 155 | + use_pypi: true |
| 156 | + token: ${{ secrets[matrix.codecov_token_secret] }} |
| 157 | + url: ${{ secrets[matrix.codecov_url_secret] }} |
| 158 | + |
| 159 | + - name: Uploading unit test results (${{ matrix.name }}) |
| 160 | + uses: codecov/test-results-action@v1 |
| 161 | + with: |
| 162 | + files: ./unit.*.junit.xml |
| 163 | + flags: ${{ format('{0}unit', inputs.flag_prefix) }} |
| 164 | + disable_search: true |
| 165 | + token: ${{ secrets[matrix.codecov_token_secret] }} |
| 166 | + url: ${{ secrets[matrix.codecov_url_secret] }} |
| 167 | + # The coverage action will have installed codecovcli with pip. The |
| 168 | + # actual binary will be found in $PATH. |
| 169 | + binary: codecovcli |
| 170 | + |
| 171 | + - name: Uploading integration test results (${{ matrix.name }}) |
| 172 | + if: ${{ inputs.run_integration == true }} |
| 173 | + uses: codecov/test-results-action@v1 |
| 174 | + with: |
| 175 | + files: ./integration.*.junit.xml |
| 176 | + flags: ${{ format('{0}integration', inputs.flag_prefix) }} |
| 177 | + disable_search: true |
| 178 | + token: ${{ secrets[matrix.codecov_token_secret] }} |
| 179 | + url: ${{ secrets[matrix.codecov_url_secret] }} |
| 180 | + # The coverage action will have installed codecovcli with pip. The |
| 181 | + # actual binary will be found in $PATH. |
| 182 | + binary: codecovcli |
0 commit comments