|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + configure-nodejs-ref: |
| 11 | + description: Ref in pwrdrvr/configure-nodejs to validate |
| 12 | + default: main |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + |
| 16 | +env: |
| 17 | + CONFIGURE_NODEJS_REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.configure-nodejs-ref || 'main' }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + unit: |
| 21 | + name: Unit Tests |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v6 |
| 25 | + |
| 26 | + - name: Checkout configure-nodejs |
| 27 | + uses: actions/checkout@v6 |
| 28 | + with: |
| 29 | + repository: pwrdrvr/configure-nodejs |
| 30 | + ref: ${{ env.CONFIGURE_NODEJS_REF }} |
| 31 | + path: configure-nodejs |
| 32 | + |
| 33 | + - uses: actions/setup-node@v6 |
| 34 | + with: |
| 35 | + node-version: 22.x |
| 36 | + |
| 37 | + - name: Run unit tests |
| 38 | + run: npm test |
| 39 | + |
| 40 | + fixture-lookup: |
| 41 | + name: Fixture Lookup (${{ matrix.package-manager }}) |
| 42 | + needs: unit |
| 43 | + runs-on: ubuntu-latest |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + include: |
| 48 | + - package-manager: npm |
| 49 | + fixture: fixtures/npm-basic |
| 50 | + install-command: npm ci |
| 51 | + lockfile-name: package-lock.json |
| 52 | + - package-manager: pnpm |
| 53 | + fixture: fixtures/pnpm-basic |
| 54 | + install-command: pnpm install --frozen-lockfile |
| 55 | + lockfile-name: pnpm-lock.yaml |
| 56 | + - package-manager: yarn |
| 57 | + fixture: fixtures/yarn-basic |
| 58 | + install-command: yarn install --immutable |
| 59 | + lockfile-name: yarn.lock |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v6 |
| 62 | + |
| 63 | + - name: Checkout configure-nodejs |
| 64 | + uses: actions/checkout@v6 |
| 65 | + with: |
| 66 | + repository: pwrdrvr/configure-nodejs |
| 67 | + ref: ${{ env.CONFIGURE_NODEJS_REF }} |
| 68 | + path: configure-nodejs |
| 69 | + |
| 70 | + - name: Configure Node.js |
| 71 | + id: configure-nodejs |
| 72 | + uses: ./configure-nodejs |
| 73 | + with: |
| 74 | + working-directory: ${{ matrix.fixture }} |
| 75 | + cache-key-suffix: fixture-tests |
| 76 | + lookup-only: "true" |
| 77 | + |
| 78 | + - name: Assert resolved action outputs |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + test "${{ steps.configure-nodejs.outputs.package-manager }}" = "${{ matrix.package-manager }}" |
| 82 | + test "${{ steps.configure-nodejs.outputs.install-command }}" = "${{ matrix.install-command }}" |
| 83 | + test "${{ steps.configure-nodejs.outputs.working-directory }}" = "${{ matrix.fixture }}" |
| 84 | + test "${{ steps.configure-nodejs.outputs.lockfile-name }}" = "${{ matrix.lockfile-name }}" |
| 85 | +
|
| 86 | + - name: Assert lookup-only behavior |
| 87 | + working-directory: ${{ matrix.fixture }} |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + if [ "${{ steps.configure-nodejs.outputs.cache-hit }}" = "true" ]; then |
| 91 | + test ! -d node_modules |
| 92 | + else |
| 93 | + test -d node_modules |
| 94 | + node check.mjs |
| 95 | + fi |
| 96 | +
|
| 97 | + fixture-validate: |
| 98 | + name: Fixture Validate (${{ matrix.package-manager }}) |
| 99 | + needs: fixture-lookup |
| 100 | + runs-on: ubuntu-latest |
| 101 | + strategy: |
| 102 | + fail-fast: false |
| 103 | + matrix: |
| 104 | + include: |
| 105 | + - package-manager: npm |
| 106 | + fixture: fixtures/npm-basic |
| 107 | + install-command: npm ci |
| 108 | + lockfile-name: package-lock.json |
| 109 | + - package-manager: pnpm |
| 110 | + fixture: fixtures/pnpm-basic |
| 111 | + install-command: pnpm install --frozen-lockfile |
| 112 | + lockfile-name: pnpm-lock.yaml |
| 113 | + - package-manager: yarn |
| 114 | + fixture: fixtures/yarn-basic |
| 115 | + install-command: yarn install --immutable |
| 116 | + lockfile-name: yarn.lock |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v6 |
| 119 | + |
| 120 | + - name: Checkout configure-nodejs |
| 121 | + uses: actions/checkout@v6 |
| 122 | + with: |
| 123 | + repository: pwrdrvr/configure-nodejs |
| 124 | + ref: ${{ env.CONFIGURE_NODEJS_REF }} |
| 125 | + path: configure-nodejs |
| 126 | + |
| 127 | + - name: Configure Node.js |
| 128 | + id: configure-nodejs |
| 129 | + uses: ./configure-nodejs |
| 130 | + with: |
| 131 | + working-directory: ${{ matrix.fixture }} |
| 132 | + cache-key-suffix: fixture-tests |
| 133 | + |
| 134 | + - name: Assert restore behavior |
| 135 | + shell: bash |
| 136 | + run: | |
| 137 | + test "${{ steps.configure-nodejs.outputs.package-manager }}" = "${{ matrix.package-manager }}" |
| 138 | + test "${{ steps.configure-nodejs.outputs.install-command }}" = "${{ matrix.install-command }}" |
| 139 | + test "${{ steps.configure-nodejs.outputs.working-directory }}" = "${{ matrix.fixture }}" |
| 140 | + test "${{ steps.configure-nodejs.outputs.lockfile-name }}" = "${{ matrix.lockfile-name }}" |
| 141 | + test "${{ steps.configure-nodejs.outputs.cache-hit }}" = "true" |
| 142 | +
|
| 143 | + - name: Validate installed dependency |
| 144 | + working-directory: ${{ matrix.fixture }} |
| 145 | + run: node check.mjs |
0 commit comments