test: add external dogfood harness for configure-nodejs (#1) #2
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: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| configure-nodejs-ref: | |
| description: Ref in pwrdrvr/configure-nodejs to validate | |
| default: main | |
| required: false | |
| type: string | |
| env: | |
| CONFIGURE_NODEJS_REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.configure-nodejs-ref || 'main' }} | |
| jobs: | |
| unit: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Checkout configure-nodejs | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: pwrdrvr/configure-nodejs | |
| ref: ${{ env.CONFIGURE_NODEJS_REF }} | |
| path: configure-nodejs | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.x | |
| - name: Run unit tests | |
| run: npm test | |
| fixture-lookup: | |
| name: Fixture Lookup (${{ matrix.package-manager }}) | |
| needs: unit | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - package-manager: npm | |
| fixture: fixtures/npm-basic | |
| install-command: npm ci | |
| lockfile-name: package-lock.json | |
| - package-manager: pnpm | |
| fixture: fixtures/pnpm-basic | |
| install-command: pnpm install --frozen-lockfile | |
| lockfile-name: pnpm-lock.yaml | |
| - package-manager: yarn | |
| fixture: fixtures/yarn-basic | |
| install-command: yarn install --immutable | |
| lockfile-name: yarn.lock | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Checkout configure-nodejs | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: pwrdrvr/configure-nodejs | |
| ref: ${{ env.CONFIGURE_NODEJS_REF }} | |
| path: configure-nodejs | |
| - name: Configure Node.js | |
| id: configure-nodejs | |
| uses: ./configure-nodejs | |
| with: | |
| working-directory: ${{ matrix.fixture }} | |
| cache-key-suffix: fixture-tests | |
| lookup-only: "true" | |
| - name: Assert resolved action outputs | |
| shell: bash | |
| run: | | |
| test "${{ steps.configure-nodejs.outputs.package-manager }}" = "${{ matrix.package-manager }}" | |
| test "${{ steps.configure-nodejs.outputs.install-command }}" = "${{ matrix.install-command }}" | |
| test "${{ steps.configure-nodejs.outputs.working-directory }}" = "${{ matrix.fixture }}" | |
| test "${{ steps.configure-nodejs.outputs.lockfile-name }}" = "${{ matrix.lockfile-name }}" | |
| - name: Assert lookup-only behavior | |
| working-directory: ${{ matrix.fixture }} | |
| shell: bash | |
| run: | | |
| if [ "${{ steps.configure-nodejs.outputs.cache-hit }}" = "true" ]; then | |
| test ! -d node_modules | |
| else | |
| test -d node_modules | |
| node check.mjs | |
| fi | |
| fixture-validate: | |
| name: Fixture Validate (${{ matrix.package-manager }}) | |
| needs: fixture-lookup | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - package-manager: npm | |
| fixture: fixtures/npm-basic | |
| install-command: npm ci | |
| lockfile-name: package-lock.json | |
| - package-manager: pnpm | |
| fixture: fixtures/pnpm-basic | |
| install-command: pnpm install --frozen-lockfile | |
| lockfile-name: pnpm-lock.yaml | |
| - package-manager: yarn | |
| fixture: fixtures/yarn-basic | |
| install-command: yarn install --immutable | |
| lockfile-name: yarn.lock | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Checkout configure-nodejs | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: pwrdrvr/configure-nodejs | |
| ref: ${{ env.CONFIGURE_NODEJS_REF }} | |
| path: configure-nodejs | |
| - name: Configure Node.js | |
| id: configure-nodejs | |
| uses: ./configure-nodejs | |
| with: | |
| working-directory: ${{ matrix.fixture }} | |
| cache-key-suffix: fixture-tests | |
| - name: Assert restore behavior | |
| shell: bash | |
| run: | | |
| test "${{ steps.configure-nodejs.outputs.package-manager }}" = "${{ matrix.package-manager }}" | |
| test "${{ steps.configure-nodejs.outputs.install-command }}" = "${{ matrix.install-command }}" | |
| test "${{ steps.configure-nodejs.outputs.working-directory }}" = "${{ matrix.fixture }}" | |
| test "${{ steps.configure-nodejs.outputs.lockfile-name }}" = "${{ matrix.lockfile-name }}" | |
| test "${{ steps.configure-nodejs.outputs.cache-hit }}" = "true" | |
| - name: Validate installed dependency | |
| working-directory: ${{ matrix.fixture }} | |
| run: node check.mjs |