diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 31cfaa0..22ae77b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,9 +6,33 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + node: [16, 18] + pnpm: [7, 8] steps: - uses: actions/checkout@v3 - uses: ./ with: + node: ${{ matrix.node }} + pnpm: ${{ matrix.pnpm }} cwd: "test" install-ignore-scripts: true + + test-version-file: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./ + with: + cwd: "test" + node-file: ".node-version" + install-ignore-scripts: true + + - name: check version + id: check-version + run: echo "VERSION=$(node -v)" >> $GITHUB_OUTPUT + + - name: fail on wrong version (${{ steps.check-version.outputs.VERSION }}) + if: ${{ steps.check-version.outputs.VERSION != 'v16.16.0' }} + run: exit 1 diff --git a/.gitignore b/.gitignore index adceed6..da1dd01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules test/node_modules +/.idea/ \ No newline at end of file diff --git a/README.md b/README.md index 64e766f..2e4dfdf 100644 --- a/README.md +++ b/README.md @@ -16,18 +16,20 @@ jobs: # with: # pnpm: 8 # node: 18 - # cwd: "." + # node-file: '' + # cwd: '.' # install: false # install-ignore-scripts: false ``` -| Inputs | Default value | Description | -|--------------------------|---------------|-------------------------------------------------------------------------------------------------------------------| -| `pnpm` | `8` | PNPM version to install | -| `node` | `18` | Node version to install | -| `cwd` | `.` | Changes pnpm-lock.yaml lookup location and the work directory of "pnpm install" if enabled | -| `install` | `false` | Runs "pnpm install" in working directory | -| `install-ignore-scripts` | `false` | Runs "pnpm install --ignore-scripts" in working directory. Enable "install" or "install-ignore-scripts" only once | +| Inputs | Default value | Description | +|--------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `pnpm` | `8` | PNPM version to install | +| `node` | `18` | Version Spec of the version to use in SemVer notation.
It also emits such aliases as lts, latest, nightly and canary builds.
Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node | +| `node-file` | `''` | File containing the version Spec of the version to use.
Examples: .nvmrc, .node-version, .tool-versions.
If node-version and node-version-file are both provided the action will use version from node-version. | +| `cwd` | `.` | Changes pnpm-lock.yaml lookup location and the work directory of "pnpm install" if enabled | +| `install` | `false` | Runs "pnpm install" in working directory | +| `install-ignore-scripts` | `false` | Runs "pnpm install --ignore-scripts" in working directory. Enable "install" or "install-ignore-scripts" only once | diff --git a/action.yml b/action.yml index a5c791c..5044c18 100644 --- a/action.yml +++ b/action.yml @@ -9,11 +9,15 @@ inputs: pnpm: description: "PNPM version" required: false - default: 8 + default: '8' node: - description: "Node version" + description: "Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0." required: false - default: 18 + default: '18' + node-file: + description: 'File containing the version Spec of the version to use. Examples: .nvmrc, .node-version, .tool-versions.' + required: false + default: '' cwd: description: "Work directory" required: false @@ -34,14 +38,23 @@ runs: uses: pnpm/action-setup@v2 with: version: ${{ inputs.pnpm }} - + - name: use Node.js ${{ inputs.node }} + if: "${{ inputs.node-file == '' }}" uses: actions/setup-node@v3 with: node-version: ${{ inputs.node }} cache: "pnpm" cache-dependency-path: "${{ inputs.cwd }}/pnpm-lock.yaml" + - name: use Node.js ${{ inputs.node }} + if: "${{ inputs.node-file != '' }}" + uses: actions/setup-node@v3 + with: + node-version-file: "${{ inputs.cwd }}/${{ inputs.node-file }}" + cache: "pnpm" + cache-dependency-path: "${{ inputs.cwd }}/pnpm-lock.yaml" + - name: Run pnpm install if: "${{ inputs.install == 'true' }}" shell: bash diff --git a/test/.node-version b/test/.node-version new file mode 100644 index 0000000..5d8bda1 --- /dev/null +++ b/test/.node-version @@ -0,0 +1 @@ +v16.16.0 \ No newline at end of file