Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use codecov actions to upload instead of the cli #42

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 122 additions & 18 deletions .github/workflows/run-tests-split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,37 @@ on:
type: number
required: false
default: 5
flag_prefix:
type: string
default: ''
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
runs-on: ubuntu-latest
outputs:
groups: ${{ steps.prepare_groups.outputs.groups }}
# 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:
- name: Prepare groups
id: prepare_groups
run: |
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 +80,103 @@ 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
# Strange workaround: API has a `codecov` directory in the repo root
# which conflicts with the action's `codecov` binary
use_pypi: 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
# Strange workaround: API has a `codecov` directory in the repo root
# which conflicts with the action's `codecov` binary
use_pypi: 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] }}
# The coverage action will have installed codecovcli with pip. The
# actual binary will be found in $PATH.
binary: codecovcli

- 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] }}
# The coverage action will have installed codecovcli with pip. The
# actual binary will be found in $PATH.
binary: codecovcli
116 changes: 95 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,101 @@ 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
# Strange workaround: API has a `codecov` directory in the repo root
# which conflicts with the action's `codecov` binary
use_pypi: 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
# Strange workaround: API has a `codecov` directory in the repo root
# which conflicts with the action's `codecov` binary
use_pypi: 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] }}
# The coverage action will have installed codecovcli with pip. The
# actual binary will be found in $PATH.
binary: codecovcli

- 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] }}
# The coverage action will have installed codecovcli with pip. The
# actual binary will be found in $PATH.
binary: codecovcli
Loading