Skip to content

Commit b7dc10c

Browse files
committed
feat: add support for pnpm
Signed-off-by: Emilien Escalle <[email protected]>
1 parent 8181eca commit b7dc10c

File tree

21 files changed

+63647
-23018
lines changed

21 files changed

+63647
-23018
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ updates:
2929
- package-ecosystem: npm
3030
open-pull-requests-limit: 20
3131
versioning-strategy: increase
32-
directory: "/"
32+
directories:
33+
- "/"
34+
- "/tests/npm"
35+
- "/tests/pnpm"
36+
- "/tests/pnpm-package-manager"
37+
- "/tests/yarn"
3338
schedule:
3439
interval: weekly
3540
day: friday

.github/workflows/__test-action-get-package-manager.yml

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,68 @@ on:
66
permissions:
77
contents: read
88

9+
# jscpd:ignore-start
910
jobs:
10-
test-yarn:
11-
name: Tests with Yarn package manager
11+
test:
12+
name: Tests with ${{ matrix.package-manager }} package manager
1213
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
include:
17+
- working-directory: tests/npm
18+
package-manager: npm
19+
lock-file: package-lock.json
20+
cache-dependency-path: "**/package-lock.json"
21+
install-command: npm ci
22+
run-script-command: npm run
23+
24+
- working-directory: tests/pnpm
25+
package-manager: pnpm
26+
lock-file: pnpm-lock.yaml
27+
cache-dependency-path: "**/pnpm-lock.yaml"
28+
install-command: pnpm install --frozen-lockfile
29+
run-script-command: pnpm
30+
31+
- working-directory: tests/pnpm-package-manager
32+
package-manager: pnpm
33+
lock-file: pnpm-lock.yaml
34+
cache-dependency-path: "**/pnpm-lock.yaml"
35+
install-command: pnpm install --frozen-lockfile
36+
run-script-command: pnpm
37+
38+
- working-directory: tests/yarn
39+
package-manager: yarn
40+
lock-file: yarn.lock
41+
cache-dependency-path: "**/yarn.lock"
42+
install-command: yarn install --frozen-lockfile
43+
run-script-command: yarn
1344
steps:
1445
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1546

16-
- run: rm -f package-lock.json
17-
47+
# jscpd:ignore-end
1848
- id: get-package-manager
1949
uses: ./actions/get-package-manager
50+
with:
51+
working-directory: ${{ matrix.working-directory }}
2052

2153
- name: Check "get-package-manager" outputs
2254
run: |
23-
if [ "${{ steps.get-package-manager.outputs.package-manager }}" != 'yarn' ]; then
55+
if [ "${{ steps.get-package-manager.outputs.package-manager }}" != '${{ matrix.package-manager }}' ]; then
2456
echo "get-package-manager outputs result is not valid"
2557
exit 1
2658
fi
2759
28-
test-npm:
29-
name: Tests with Npm package manager
30-
runs-on: ubuntu-latest
31-
steps:
32-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33-
34-
- run: rm -f yarn.lock
60+
if [ "${{ steps.get-package-manager.outputs.cache-dependency-path }}" != '${{ matrix.cache-dependency-path }}' ]; then
61+
echo "get-package-manager outputs cache-dependency-path is not valid"
62+
exit 1
63+
fi
3564
36-
- id: get-package-manager
37-
uses: ./actions/get-package-manager
65+
if [ "${{ steps.get-package-manager.outputs.install-command }}" != '${{ matrix.install-command }}' ]; then
66+
echo "get-package-manager outputs install-command is not valid"
67+
exit 1
68+
fi
3869
39-
- name: Check "get-package-manager" outputs
40-
run: |
41-
if [ "${{ steps.get-package-manager.outputs.package-manager }}" != 'npm' ]; then
42-
echo "get-package-manager outputs result is not valid"
70+
if [ "${{ steps.get-package-manager.outputs.run-script-command }}" != '${{ matrix.run-script-command }}' ]; then
71+
echo "get-package-manager outputs run-script-command is not valid"
4372
exit 1
4473
fi

.github/workflows/__test-action-has-installed-dependencies.yml

Lines changed: 41 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,57 @@ on:
66
permissions:
77
contents: read
88

9+
# jscpd:ignore-start
10+
env:
11+
LOCK_FILES: |
12+
yarn.lock
13+
package-lock.json
14+
pnpm-lock.yaml
15+
916
jobs:
10-
test-yarn:
11-
name: Tests with Yarn package manager
17+
test:
18+
name: Tests with ${{ matrix.package-manager }} package manager
1219
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
include:
23+
- working-directory: tests/npm
24+
package-manager: npm
25+
lock-file: package-lock.json
26+
27+
- working-directory: tests/pnpm
28+
package-manager: pnpm
29+
lock-file: pnpm-lock.yaml
30+
31+
- working-directory: tests/pnpm-package-manager
32+
package-manager: pnpm
33+
lock-file: pnpm-lock.yaml
34+
35+
- working-directory: tests/yarn
36+
package-manager: yarn
37+
lock-file: yarn.lock
1338
steps:
1439
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1540

16-
- run: rm -f package-lock.json
41+
# jscpd:ignore-end
42+
43+
- id: setup-node
44+
uses: ./actions/setup-node
45+
with:
46+
working-directory: ${{ matrix.working-directory }}
1747

18-
- uses: ./actions/setup-node
48+
- name: Check that package manager is the expected one
49+
id: check-package-manager
50+
run: |
51+
if [[ "${{ steps.setup-node.outputs.run-script-command }}" != "${{ matrix.package-manager }}*" ]]; then
52+
echo "Package manager is not ${{ matrix.package-manager }}"
53+
exit 1
54+
fi
1955
2056
- id: has-installed-dependencies
2157
uses: ./actions/has-installed-dependencies
2258
with:
59+
working-directory: ${{ matrix.working-directory }}
2360
dependencies: |
2461
gatsby
2562
jest
@@ -59,57 +96,3 @@ jobs:
5996
JSON.stringify(expectedResult),
6097
`"installed-dependencies" output is not valid`
6198
);
62-
63-
test-npm:
64-
name: Tests with Npm package manager
65-
runs-on: ubuntu-latest
66-
steps:
67-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
68-
69-
- run: rm -f yarn.lock
70-
71-
- uses: ./actions/setup-node
72-
73-
- id: has-installed-dependencies
74-
uses: ./actions/has-installed-dependencies
75-
with:
76-
dependencies: |
77-
nx
78-
gatsby
79-
storybook
80-
prettier
81-
unknown
82-
83-
- name: Check "has-installed-dependencies" outputs
84-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
85-
with:
86-
script: |
87-
// jscpd:ignore-start
88-
const assert = require("assert");
89-
90-
const installedDependenciesOutput = `${{ steps.has-installed-dependencies.outputs.installed-dependencies }}`;
91-
assert(installedDependenciesOutput.length, `"installed-dependencies" output is empty`);
92-
93-
// Check if is valid Json
94-
let installedDependencies = null;
95-
try {
96-
installedDependencies = JSON.parse(installedDependenciesOutput);
97-
} catch (error) {
98-
throw new Error(`"installed-dependencies" output is not a valid JSON: ${error}`);
99-
}
100-
101-
const expectedResult = {
102-
nx: true,
103-
gatsby: true,
104-
storybook: true,
105-
prettier: true,
106-
unknown: false,
107-
};
108-
109-
assert.equal(
110-
JSON.stringify(installedDependencies),
111-
JSON.stringify(expectedResult),
112-
`"installed-dependencies" output is not valid`
113-
);
114-
115-
// jscpd:ignore-end

.github/workflows/__test-action-setup-node.yml

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,55 @@ on:
66
permissions:
77
contents: read
88

9+
# jscpd:ignore-start
10+
env:
11+
LOCK_FILES: |
12+
yarn.lock
13+
package-lock.json
14+
pnpm-lock.yaml
15+
916
jobs:
10-
test-yarn:
11-
name: Tests with Yarn package manager
17+
test:
18+
name: Tests with ${{ matrix.package-manager }} package manager
1219
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
include:
23+
- working-directory: tests/npm
24+
package-manager: npm
25+
lock-file: package-lock.json
26+
run-script-command: npm run
27+
28+
- working-directory: tests/pnpm
29+
package-manager: pnpm
30+
lock-file: pnpm-lock.yaml
31+
run-script-command: pnpm
32+
33+
- working-directory: tests/pnpm-package-manager
34+
package-manager: pnpm
35+
lock-file: pnpm-lock.yaml
36+
run-script-command: pnpm
37+
38+
- working-directory: tests/yarn
39+
package-manager: yarn
40+
lock-file: yarn.lock
41+
run-script-command: yarn
1342
steps:
1443
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1544

16-
- run: |
17-
rm -f package-lock.json
18-
echo "lts/*" > .nvmrc
19-
20-
- id: setup-node
21-
uses: ./actions/setup-node
22-
23-
- name: Check "setup-node" outputs
24-
run: |
25-
if [ "${{ steps.setup-node.outputs.run-script-command }}" != 'yarn' ]; then
26-
echo "setup-node outputs result is not valid"
27-
exit 1
28-
fi
29-
30-
test-npm:
31-
name: Tests with Npm package manager
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+
# jscpd:ignore-end
3546

36-
- run: |
37-
rm -f yarn.lock
38-
echo "lts/*" > .nvmrc
47+
- run: echo "lts/*" > .nvmrc
48+
working-directory: ${{ matrix.working-directory }}
3949

4050
- id: setup-node
4151
uses: ./actions/setup-node
52+
with:
53+
working-directory: ${{ matrix.working-directory }}
4254

4355
- name: Check "setup-node" outputs
4456
run: |
45-
if [ "${{ steps.setup-node.outputs.run-script-command }}" != 'npm run' ]; then
46-
echo "setup-node outputs result is not valid"
57+
if [ "${{ steps.setup-node.outputs.run-script-command }}" != '${{ matrix.run-script-command }}' ]; then
58+
echo "get-package-manager outputs run-script-command is not valid"
4759
exit 1
4860
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules
2+
/tests/*/node_modules
23
/dist

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM ghcr.io/super-linter/super-linter:slim-v7
33

44
ARG UID=1000
55
ARG GID=1000
6+
RUN chown -R ${UID}:${GID} /github/home
67
USER ${UID}:${GID}
78

89
ENV RUN_LOCAL=true

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ lint: ## Execute linting
88

99
lint-fix: ## Execute linting and fix
1010
$(call run_linter, \
11+
-e FIX_JSON_PRETTIER=true \
12+
-e FIX_JAVASCRIPT_PRETTIER=true \
13+
-e FIX_JAVASCRIPT_STANDARD=true \
1114
-e FIX_YAML_PRETTIER=true \
1215
-e FIX_MARKDOWN=true \
1316
-e FIX_MARKDOWN_PRETTIER=true \
@@ -17,10 +20,12 @@ define run_linter
1720
DEFAULT_WORKSPACE="$(CURDIR)"; \
1821
LINTER_IMAGE="linter:latest"; \
1922
VOLUME="$$DEFAULT_WORKSPACE:$$DEFAULT_WORKSPACE"; \
20-
docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) --tag $$LINTER_IMAGE .; \
23+
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $$LINTER_IMAGE .; \
2124
docker run \
2225
-e DEFAULT_WORKSPACE="$$DEFAULT_WORKSPACE" \
2326
-e FILTER_REGEX_INCLUDE="$(filter-out $@,$(MAKECMDGOALS))" \
27+
-e IGNORE_GITIGNORED_FILES=true \
28+
-e KUBERNETES_KUBECONFORM_OPTIONS="--schema-location default --schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'" \
2429
$(1) \
2530
-v $$VOLUME \
2631
--rm \

actions/dependencies-cache/action.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ inputs:
99
dependencies:
1010
description: "List of dependencies for which the cache should be managed."
1111
required: true
12+
working-directory:
13+
description: "Working directory where the dependencies are installed."
14+
required: false
15+
default: "."
1216

1317
runs:
1418
using: "composite"
@@ -22,16 +26,18 @@ runs:
2226
uses: ./self-dependencies-cache-action/has-installed-dependencies
2327
with:
2428
dependencies: ${{ inputs.dependencies }}
29+
working-directory: ${{ inputs.working-directory }}
2530

2631
- id: get-package-manager
2732
if: inputs.package-manager == ''
2833
uses: ./self-setup-node-action/get-package-manager
34+
working-directory: ${{ inputs.working-directory }}
2935

3036
- name: ♻️ NX cache
3137
if: fromJson(steps.has-installed-dependencies.outputs.installed-dependencies).nx == true
3238
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3339
with:
34-
path: node_modules/.cache/nx
40+
path: ${{ inputs.working-directory }}/node_modules/.cache/nx
3541
key: ${{ runner.os }}-cache-nx-${{ github.sha }}
3642
restore-keys: |
3743
${{ runner.os }}-cache-nx-
@@ -40,7 +46,7 @@ runs:
4046
if: fromJson(steps.has-installed-dependencies.outputs.installed-dependencies).prettier == true
4147
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
4248
with:
43-
path: node_modules/.cache/prettier
49+
path: ${{ inputs.working-directory }}/node_modules/.cache/prettier
4450
key: ${{ runner.os }}-cache-prettier-${{ github.sha }}
4551
restore-keys: |
4652
${{ runner.os }}-cache-prettier-
@@ -50,8 +56,8 @@ runs:
5056
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
5157
with:
5258
path: |
53-
.cache
54-
public
59+
${{ inputs.working-directory }}/.cache
60+
${{ inputs.working-directory }}/public
5561
key: ${{ runner.os }}-cache-gatsby-${{ github.sha }}
5662
restore-keys: |
5763
${{ runner.os }}-cache-gatsby-
@@ -60,7 +66,7 @@ runs:
6066
if: fromJson(steps.has-installed-dependencies.outputs.installed-dependencies).storybook == true
6167
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
6268
with:
63-
path: node_modules/.cache/storybook
69+
path: ${{ inputs.working-directory }}/node_modules/.cache/storybook
6470
key: ${{ runner.os }}-cache-storybook-${{ github.sha }}
6571
restore-keys: |
6672
${{ runner.os }}-cache-storybook-

0 commit comments

Comments
 (0)