diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 426a264f..89838d61 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,6 +1,8 @@ name: Pull Request on: + push: + branches: ['ci-test/*'] pull_request: branches: '*' @@ -11,5 +13,7 @@ jobs: trigger-unit-test: name: Run Unit Tests + permissions: + pull-requests: write uses: ./.github/workflows/unit-test.yml secrets: inherit diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 401c1229..e151c841 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -13,6 +13,36 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v42 + with: + files_yaml: | + auth: + - 'packages/auth/**' + common: + - 'packages/common/**' + event-producer: + - 'packages/event-producer/**' + player: + - 'packages/player/**' + player-web-components: + - 'packages/player-web-components/**' + template: + - 'packages/template/**' + true-time: + - 'packages/true-time/**' + # Optionally set `files_yaml_from_source_file` to read the YAML from a file. e.g `files_yaml_from_source_file: .github/changed-files.yml` + + - name: Run step if test file(s) change + # NOTE: Ensure all outputs are prefixed by the same key used above e.g. `test_(...)` | `doc_(...)` | `src_(...)` when trying to access the `any_changed` output. + if: steps.changed-files.outputs.any_changed == 'true' + env: + TEST_ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.any_changed_files }} + run: | + echo "One or more test file(s) has changed." + echo "List all the files that have changed: $TEST_ALL_CHANGED_FILES" + - name: Prepare test user for player tests id: json run: | @@ -26,36 +56,43 @@ jobs: TEST_USER: ${{ secrets.PLAYER_TEST_USER }} - name: Run Tests run: | + echo "Running tests for ${{ inputs.modules }}" pnpm test:coverage env: TEST_USER: ${{ steps.json.outputs.encoded }} - name: Report Auth Coverage - if: always() + if: steps.changed-files.outputs.auth_any_changed uses: davelosert/vitest-coverage-report-action@v2 with: name: 'Auth' - working-directory: './packages/auth' + working-directory: 'packages/auth' - name: Report Common Coverage - if: always() + if: steps.changed-files.outputs.common_any_changed uses: davelosert/vitest-coverage-report-action@v2 with: name: 'Common' - working-directory: './packages/common' + working-directory: 'packages/common' - name: Report Event-Producer Coverage - if: always() + if: steps.changed-files.outputs.event-producer_any_changed uses: davelosert/vitest-coverage-report-action@v2 with: name: 'Event Producer' - working-directory: './packages/event-producer' + working-directory: 'packages/event-producer' - name: Report Player-Web-Components Coverage - if: always() + if: steps.changed-files.outputs.player-web-components_any_changed uses: davelosert/vitest-coverage-report-action@v2 with: name: 'Player Web Components' - working-directory: './packages/player-web-components' + working-directory: 'packages/player-web-components' + - name: Report Template Coverage + if: steps.changed-files.outputs.template_any_changed + uses: davelosert/vitest-coverage-report-action@v2 + with: + name: 'Template' + working-directory: 'packages/template' - name: Report True-Time Coverage - if: always() + if: steps.changed-files.outputs.true-time_any_changed uses: davelosert/vitest-coverage-report-action@v2 with: name: 'True Time' - working-directory: './packages/true-time' + working-directory: 'packages/true-time' diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index 7140264e..5a99110b 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,6 +1,8 @@ +/* v8 ignore start */ export * from './illegalArgumentError'; export * from './networkError'; export * from './retryableError'; export * from './tidalError'; export * from './tidalMessage'; export * from './credentialsProvider'; +/* v8 ignore stop */ diff --git a/packages/event-producer/src/bus.ts b/packages/event-producer/src/bus.ts index d6f99099..ed385995 100644 --- a/packages/event-producer/src/bus.ts +++ b/packages/event-producer/src/bus.ts @@ -26,3 +26,9 @@ export const postMessage = (message: OutageStartError | TidalMessage) => { }); globalThis.dispatchEvent(event); }; + +// @ts-expect-error this is for testing ci only +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const someLegacyCode = () => { + console.error('please delete me'); +};