test: 🚨 fix coverage reports for vitest based libs and projects #5051
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: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**/version.json' | |
- '**/CHANGELOG.MD' | |
tags-ignore: | |
- 'v*' | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') || startsWith(github.ref_name, 'renovate-github-sh') }} | |
# Needed for nx-set-shas when run on the main branch | |
permissions: | |
actions: read | |
contents: write | |
pull-requests: write | |
env: | |
HUSKY: 0 | |
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_DASHBOARD_KEY }} | |
NODE_OPTIONS: '--max_old_space_size=4096' | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
outputs: | |
shouldTriggerRelease: ${{ steps.shouldTriggerRelease.outputs.triggerRelease }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Debug print env variables | |
run: | | |
printenv | |
- uses: nrwl/nx-set-shas@v4 | |
- run: | | |
echo "BASE: ${{ env.NX_BASE }}" | |
echo "HEAD: ${{ env.NX_HEAD }}" | |
# Connect your workspace on nx.app and uncomment this to enable task distribution. | |
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested | |
- run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: 'npm' | |
- name: Install Deps | |
uses: ./.github/actions/install-deps | |
with: | |
cypress: 'true' | |
apt-packages: 'true' | |
# This line is needed for nx affected to work when CI is running on a PR | |
# - run: git branch --track main origin/main | |
# if: github.event_name == 'pull_request' | |
- run: npx nx-cloud record -- nx format:check | |
- run: npx nx affected -t=\"lint,test,build,component-test,e2e-ci\" -c=ci | |
- run: npx nx-cloud stop-all-agents | |
if: ${{ always() }} | |
- name: Report Codecov | |
if: github.ref_name == 'main' && hashFiles('coverage/**/*') != '' | |
uses: codecov/codecov-action@v5-beta | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: unittests | |
fail_ci_if_error: true | |
verbose: true | |
- name: determine if deployables are affected and a release should be triggered | |
if: github.ref_name == 'main' | |
id: shouldTriggerRelease | |
run: | | |
projects=$(npx nx show projects --affected -t deploy); | |
echo $projects | |
triggerRelease=$([[ -z $projects ]] && echo "false" || echo "true") | |
echo "triggerRelease=$triggerRelease" >> $GITHUB_OUTPUT | |
echo "$([[ -z $projects ]] && echo 'No deployable projects affected, no need for a release' || echo 'Deployable projects affected. Trigger release!!!')" >> $GITHUB_STEP_SUMMARY | |
# as the main workflow is mandatory for the branch protection we need a separate job | |
trigger-release: | |
uses: ./.github/workflows/trigger-release.yml | |
secrets: inherit | |
needs: main | |
if: ${{ success() && needs.main.outputs.shouldTriggerRelease == 'true' && !contains(github.event.head_commit.message, 'chore(release):') && github.ref_name == 'main' }} |