[MOO-2404] - fix intro screen - main #1879
This file contains hidden or 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: Run unit tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| # Supersede in-flight runs: a new push to the same PR/branch cancels the previous run | |
| # instead of queueing beside it (this repo shares GitHub Free's 20-concurrent-job cap with | |
| # NativePipeline, so stale runs directly delay the ones that matter). Only PR runs are | |
| # cancelled — a push run on main/mx-* is the recorded result for that commit, so let it finish. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| test: | |
| name: "Unit tests" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "Checking changed files" | |
| id: files | |
| uses: softprops/diffset@d60d53313c1b61c12ccb0fc76cbde5a14ae5d330 # v3 | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| with: | |
| base: main | |
| global_files: | | |
| !{packages/**/*,configs/e2e/*.json,scripts/**/*,data/**/*} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: "Checking-out code" | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: "Fetching main to compare" | |
| if: github.event_name == 'pull_request' && steps.files.outputs.global_files == '' | |
| run: git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} | |
| - name: "Defining environment variables" | |
| id: variables | |
| run: echo "arg=$(if [ "${{ steps.files.outputs.global_files }}" = "" ] && ${{ github.event_name == 'pull_request' }}; then echo '...[origin/main]'; else echo '**'; fi)" >> ${{ runner.os == 'Windows' && '$env:GITHUB_OUTPUT' || '$GITHUB_OUTPUT' }} | |
| - name: "Defining node version" | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| with: | |
| node-version-file: ".nvmrc" | |
| package-manager-cache: false | |
| - name: "Setup pnpm" | |
| uses: pnpm/action-setup@a8198c4bff370c8506180b035930dea56dbd5288 # v5 | |
| - name: "Get pnpm store directory" | |
| id: pnpm-cache | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
| - name: "Defining cache" | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: "Installing dependencies" | |
| # Avoid running workspace lifecycle builds during install; the internal utilities are built once below. | |
| run: pnpm install --frozen-lockfile --ignore-scripts | |
| - name: "Building internal utilities" | |
| run: pnpm run build:internal-utils | |
| - name: "Linting code" | |
| run: pnpm -r --filter=${{ steps.variables.outputs.arg }} run lint | |
| - name: "Running unit tests" | |
| run: pnpm -r --filter=${{ steps.variables.outputs.arg }} run test |