Refactor CI test runs to run against the code built and packaged instead of source #15
Workflow file for this run
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: CI - ___ | |
| on: | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| lint_check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - uses: ./.github/actions/ci-common-setup | |
| - name: Lint check | |
| run: pnpm exec eslint --cache | |
| prettier_check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - uses: ./.github/actions/ci-common-setup | |
| - name: Prettier check | |
| run: pnpm exec prettier --check "./{src,spec}/**/*.{ts,tsx,js,mjs,jsx}" | |
| run_tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - uses: ./.github/actions/ci-common-setup | |
| - name: Get "name" from package.json | |
| id: get-name | |
| run: | | |
| echo "package_name=$(cat ./package.json | jq -r '.name')" >> $GITHUB_OUTPUT | |
| - name: Build and pack library locally | |
| id: pkg-pack | |
| run: | | |
| pnpm pack | |
| - name: Install locally-packaged library | |
| run: | | |
| PACKAGE_FILENAME=$(ls ${{ steps.get-name.outputs.package_name }}-*.tgz) | |
| pnpm i packaged-react-async-iterators@file:./$PACKAGE_FILENAME | |
| - name: Run tests against packaged library code | |
| run: | | |
| [[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing | |
| echo 'export * from "packaged-react-async-iterators";' > ./spec/libEntrypoint.ts | |
| pnpm test | |
| [[ -e ./src-ignored-for-packaged-testing ]] && mv ./src-ignored-for-packaged-testing ./src | |
| run_type_check_on_tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - uses: ./.github/actions/ci-common-setup | |
| - name: Get "name" from package.json | |
| id: get-name | |
| run: | | |
| echo "package_name=$(cat ./package.json | jq -r '.name')" >> $GITHUB_OUTPUT | |
| - name: Build and pack library locally | |
| id: pkg-pack | |
| run: | | |
| pnpm pack | |
| - name: Install locally-packaged library | |
| run: | | |
| PACKAGE_FILENAME=$(ls ${{ steps.get-name.outputs.package_name }}-*.tgz) | |
| pnpm i packaged-react-async-iterators@file:./$PACKAGE_FILENAME | |
| - name: Type-check tests code | |
| run: | | |
| [[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing | |
| echo 'export * from "packaged-react-async-iterators";' > ./spec/libEntrypoint.ts | |
| pnpm run test-typings-check | |
| [[ -e ./src-ignored-for-packaged-testing ]] && mv ./src-ignored-for-packaged-testing ./src |