Skip to content

Commit

Permalink
use codecov actions to upload instead of the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-codecov committed Feb 14, 2025
1 parent 285163a commit 21cb3d0
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 39 deletions.
123 changes: 105 additions & 18 deletions .github/workflows/run-tests-split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,28 @@ 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:
group: [1, 2, 3, 4, 5]
# Parse our group list into a JSON object
group: ${{ fromJSON(needs.prepare_groups.outputs.groups) }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -59,20 +75,91 @@ jobs:
if: inputs.run_integration == true
run: |
make test_env.run_integration GROUP=${{ matrix.group }} SPLIT=${{ inputs.split }}
## Don't upload on forks for now.
- name: upload using codecovcli
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_URL }}
- name: upload using codecovcli staging
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN_STAGING }} CODECOV_URL=${{ secrets.CODECOV_STAGING_URL }}
- name: upload using codecovcli qa
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_QA_URL }}
- name: upload using codecovcli public qa
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_PUBLIC_QA_URL }}
- 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] }}
104 changes: 83 additions & 21 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
repo:
type: string
required: true
flag_prefix:
type: string
default: ''
env:
AR_REPO: ${{ inputs.repo }}

Expand Down Expand Up @@ -52,30 +55,89 @@ jobs:
if: ${{ !cancelled() && inputs.run_integration == true }}
run: |
make test_env.run_integration
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: coveragefiles
path: ./*.coverage.xml

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: junitfiles
path: ./*junit*.xml
## Don't upload on forks for now.
- name: upload using codecovcli
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_URL }}
- name: upload using codecovcli staging
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_ORG_TOKEN_STAGING }} CODECOV_URL=${{ secrets.CODECOV_STAGING_URL }}
- name: upload using codecovcli qa
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_QA_URL }}
- name: upload using codecovcli public qa
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
make test_env.upload CODECOV_UPLOAD_TOKEN=${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} CODECOV_URL=${{ secrets.CODECOV_PUBLIC_QA_URL }}
- name: run basic-test-results
if: ${{ !cancelled() && github.ref && contains(github.ref, 'pull') && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
uses: codecov/basic-test-results@v1

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:
name: coveragefiles

- name: Download test results
uses: actions/download-artifact@v4
with:
name: junitfiles

- 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:
github-token: ${{ secrets.GITHUB_TOKEN }}
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] }}

0 comments on commit 21cb3d0

Please sign in to comment.