use codecov actions to upload instead of the cli #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run Tests Split | |
| on: | |
| workflow_call: | |
| inputs: | |
| run_integration: | |
| required: false | |
| type: boolean | |
| default: true | |
| repo: | |
| type: string | |
| required: true | |
| split: | |
| type: number | |
| required: false | |
| default: 5 | |
| env: | |
| AR_REPO: ${{ inputs.repo }} | |
| jobs: | |
| # Create a list from 1 to `inputs.split` to use as our matrix for `test` | |
| prepare_groups: | |
| name: Prepare groups | |
| id: prepare_groups | |
| runs-on: ubuntu-latest | |
| # echo {1..5} => 1 2 3 4 5 | |
| # echo {1..5} | sed 's/ /, /g' => 1, 2, 3, 4, 5 | |
| # echo '[$(echo {1..5} | sed 's/ /, /g')]' => [1, 2, 3, 4, 5] | |
| steps: | |
| - id: prepare_groups | |
| runs: | | |
| group_list=$(echo "[$(echo {1..${{ inputs.split }}} | sed 's/ /, /g')]") | |
| echo "groups='$group_list'" >> $GITHUB_OUTPUT | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| needs: [prepare_groups] | |
| strategy: | |
| matrix: | |
| # Parse our group list into a JSON object | |
| group: ${{ fromJSON(needs.prepare_groups.outputs.groups) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Cache App | |
| id: cache-app | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-app | |
| with: | |
| path: | | |
| app.tar | |
| key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }} | |
| - name: Load built image | |
| run: | | |
| docker load --input app.tar | |
| - name: Install docker compose | |
| run: | | |
| sudo curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose | |
| sudo chmod +x /usr/local/bin/docker-compose | |
| - name: Bring test env up | |
| run: | | |
| make test_env.up | |
| - name: Prepare for tests | |
| run: | | |
| make test_env.prepare | |
| make test_env.check_db | |
| - name: Run unit tests | |
| run: | | |
| make test_env.run_unit GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }} | |
| - name: Run integration tests | |
| if: inputs.run_integration == true | |
| run: | | |
| make test_env.run_integration GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }} | |
| - uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: coveragefiles-${{ matrix.group }} | |
| path: ./*.coverage.xml | |
| - uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: junitfiles-${{ matrix.group }} | |
| path: ./*junit*.xml | |
| upload: | |
| name: Upload to Codecov | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| strategy: | |
| matrix: | |
| include: | |
| - codecov_url_secret: CODECOV_URL | |
| codecov_token_secret: CODECOV_ORG_TOKEN | |
| name: prod | |
| - codecov_url_secret: CODECOV_STAGING_URL | |
| codecov_token_secret: CODECOV_ORG_TOKEN_STAGING | |
| name: staging | |
| - codecov_url_secret: CODECOV_QA_URL | |
| codecov_token_secret: CODECOV_QA_ORG | |
| name: qa | |
| - codecov_url_secret: CODECOV_PUBLIC_QA_URL | |
| codecov_token_secret: CODECOV_PUBLIC_QA_TOKEN | |
| name: public qa | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download coverage | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: coveragefiles-* | |
| merge_multiple: true | |
| - name: Download test results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: junitfiles-* | |
| merge_multiple: true | |
| - name: Uploading unit test coverage (${{ matrix.name }}) | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./unit.*.coverage.xml | |
| flags: ${{ format('{0}unit', inputs.flag_prefix) }} | |
| disable_search: true | |
| token: ${{ secrets[matrix.codecov_token_secret] }} | |
| url: ${{ secrets[matrix.codecov_url_secret] }} | |
| - name: Uploading integration test coverage (${{ matrix.name }}) | |
| if: ${{ inputs.run_integration == true }} | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./integration.*.coverage.xml | |
| flags: ${{ format('{0}integration', inputs.flag_prefix) }} | |
| disable_search: true | |
| token: ${{ secrets[matrix.codecov_token_secret] }} | |
| url: ${{ secrets[matrix.codecov_url_secret] }} | |
| - name: Uploading unit test results (${{ matrix.name }}) | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| files: ./unit.*.junit.xml | |
| flags: ${{ format('{0}unit', inputs.flag_prefix) }} | |
| disable_search: true | |
| token: ${{ secrets[matrix.codecov_token_secret] }} | |
| url: ${{ secrets[matrix.codecov_url_secret] }} | |
| - name: Uploading integration test results (${{ matrix.name }}) | |
| if: ${{ inputs.run_integration == true }} | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| files: ./integration.*.junit.xml | |
| flags: ${{ format('{0}integration', inputs.flag_prefix) }} | |
| disable_search: true | |
| token: ${{ secrets[matrix.codecov_token_secret] }} | |
| url: ${{ secrets[matrix.codecov_url_secret] }} |