Skip to content

Merge pull request #50 from codecov/matt/remove-cutover-cruft #6

Merge pull request #50 from codecov/matt/remove-cutover-cruft

Merge pull request #50 from codecov/matt/remove-cutover-cruft #6

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
outputs:
tests_passed:
# Silly issue with returning job results as workflow outputs
# https://github.com/actions/runner/issues/2495
value: ${{ fromJSON(toJSON(jobs.test)).result }}
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:
# 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
submodules: 'recursive'
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: ${{ inputs.repo }}-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

Check failure on line 92 in .github/workflows/run-tests-split.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/run-tests-split.yml

Invalid workflow file

You have an error in your yaml syntax on line 92
- 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
submodules: 'recursive'
- name: Download coverage
id: download_coverage
uses: actions/download-artifact@v4
with:
pattern: coveragefiles-*
merge-multiple: true
- name: Download test results
id: 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: ${{ steps.download_coverage.outputs.download-path }}/unit.*.coverage.xml
flags: unit
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] }}
recurse_submodules: true
- name: Uploading integration test coverage (${{ matrix.name }})
if: ${{ inputs.run_integration == true }}
uses: codecov/codecov-action@v5
with:
files: ${{ steps.download_coverage.outputs.download-path }}/integration.*.coverage.xml
flags: integration
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] }}
recurse_submodules: true
# The test result action doesn't accept globs in its `files` argument
# so this step expands the globs into a comma-separated list of files
- name: Expand globs for test result files
id: junit_files
# echo ./unit.*.junit.xml => ./unit.1.junit.xml ./unit.2.junit.xml ./unit.3.junit.xml
# echo ./unit.*.junit.xml | sed 's/ /,/g' => ./unit.1.junit.xml,./unit.2.junit.xml,./unit.3.junit.xml
run: |
base_path="${{ steps.download_test_results.outputs.download-path }}"
unit_junit_files=$(echo $base_path/unit.*.junit.xml | sed 's/ /,/g')
integration_junit_files=$(echo $base_path/integration.*.junit.xml | sed 's/ /,/g')
echo "unit_junit_files=$unit_junit_files" >> $GITHUB_OUTPUT
echo "integration_junit_files=$integration_junit_files" >> $GITHUB_OUTPUT
- name: Uploading unit test results (${{ matrix.name }})
uses: codecov/test-results-action@v1
with:
files: ${{ steps.junit_files.outputs.unit_junit_files }}
flags: unit
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: ${{ steps.junit_files.outputs.integration_junit_files }}
flags: integration
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