[TEST] QA Global Upload Token #6587
This file contains 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: Gazebo CI | |
on: | |
push: | |
branches: | |
- main | |
- staging | |
pull_request: | |
merge_group: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
install: | |
name: Install deps | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-gazebo-node-modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}- | |
# - name: Setup Bun | |
# uses: oven-sh/setup-bun@v1 | |
# if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }} | |
- name: Install packages | |
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }} | |
run: | | |
yarn install | |
codecov-startup: | |
name: Codecov Startup | |
needs: install | |
uses: codecov/gha-workflows/.github/workflows/[email protected] | |
secrets: inherit | |
runner-indexes-vitest: | |
runs-on: ubuntu-latest | |
name: Generate runner indexes Vitest | |
needs: install | |
env: | |
TEST_SPLIT_NUMBER: 80 | |
outputs: | |
json: ${{ steps.generate-index-list.outputs.json }} | |
test_list_array: ${{ steps.generate-index-list.outputs.test_list_array }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Generate test index list | |
id: generate-index-list | |
run: | | |
shopt -s globstar | |
TEST_LIST=$(ls src/**/*.test.js src/**/*.test.jsx src/**/*.test.ts src/**/*.test.tsx | jq -R -s -c 'split("\n")[:-1]') | |
TEST_LENGTH=$(echo $TEST_LIST | jq length) | |
MAX_INDEX=$((($TEST_LENGTH/${{ env.TEST_SPLIT_NUMBER }}))) | |
MAX_INDEX=$(($MAX_INDEX < 0 ? 0 : $TEST_LENGTH % ${{ env.TEST_SPLIT_NUMBER }} == 0 ? $MAX_INDEX - 1 : $MAX_INDEX)) | |
INDEX_LIST=$(seq 0 ${MAX_INDEX}) | |
INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST}) | |
echo json=${INDEX_JSON} >> $GITHUB_OUTPUT | |
echo test_list_array=$(echo ${TEST_LIST} | jq -c '[_nwise(${{ env.TEST_SPLIT_NUMBER }})]') >> $GITHUB_OUTPUT | |
test-vitest: | |
name: 'Test Runner #${{ matrix.runner-index }} - Vitest' | |
needs: [install, codecov-startup, runner-indexes-vitest] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
runner-index: ${{ fromjson(needs.runner-indexes-vitest.outputs.json) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-gazebo-node-modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}- | |
- name: Run tests | |
run: | | |
TESTS=$(echo $TEST_LIST | jq -cr 'join(" ")') | |
yarn test:ci --minWorkers=1 --maxWorkers=2 $TESTS | |
env: | |
ENABLE_TEST_REPORTER: true | |
TEST_LIST: ${{ tojson(fromjson(needs.runner-indexes-vitest.outputs.test_list_array)[matrix.runner-index]) }} | |
- name: Upload test results to Codecov QA | |
uses: codecov/test-results-action@v1 | |
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov'}} | |
with: | |
token: ${{ secrets.CODECOV_QA_GLOBAL_UPLOAD_TOKEN }} | |
url: ${{ secrets.CODECOV_QA_URL }} | |
- name: Install CLI | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
make test_env.install_cli | |
- name: Upload coverage to QA | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
codecovcli -u ${{ secrets.CODECOV_QA_URL }} do-upload -t ${{ secrets.CODECOV_QA_GLOBAL_UPLOAD_TOKEN }} --fail-on-error |