Skip to content

Commit a38e64f

Browse files
authored
refactor: test new action
2 parents f1fbf09 + 00cdc56 commit a38e64f

File tree

9 files changed

+703
-212
lines changed

9 files changed

+703
-212
lines changed

.github/workflows/ci.yml

Lines changed: 130 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,147 @@
11
name: CI
2+
permissions:
3+
contents: read
24

35
on:
46
push:
5-
branches:
6-
- main
7+
branches: [main]
78
pull_request:
9+
branches: [main]
810

9-
permissions:
10-
actions: read
11-
contents: read
11+
env:
12+
NX_NON_NATIVE_HASHER: true
1213

1314
jobs:
14-
main:
15+
format:
1516
runs-on: ubuntu-latest
17+
name: Format check
1618
steps:
17-
- uses: actions/checkout@v4
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
1821
with:
1922
fetch-depth: 0
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version-file: .node-version
27+
cache: npm
28+
- name: Set base and head for Nx affected commands
29+
uses: nrwl/nx-set-shas@v4
30+
- name: Install dependencies
31+
run: npm ci
32+
- name: Check formatting of affected files
33+
run: npx nx format:check
2034

21-
# Connect your workspace on nx.app and uncomment this to enable task distribution.
22-
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested
23-
# - run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build"
35+
lint:
36+
runs-on: ubuntu-latest
37+
name: Linter
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
- name: Set up Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version-file: .node-version
47+
cache: npm
48+
- name: Set base and head for Nx affected commands
49+
uses: nrwl/nx-set-shas@v4
50+
- name: Install dependencies
51+
run: npm ci
52+
- name: Lint affected projects
53+
run: npx nx affected -t lint --parallel=3
2454

25-
# Cache node_modules
26-
- uses: actions/setup-node@v3
55+
unit-test:
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
os: [ubuntu-latest, windows-latest, macos-latest]
60+
name: Unit tests
61+
runs-on: ${{ matrix.os }}
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v4
2765
with:
28-
node-version: 20
29-
cache: 'npm'
30-
- run: npm ci
31-
- uses: nrwl/nx-set-shas@v4
66+
fetch-depth: 0
67+
- name: Set up Node.js
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version-file: .node-version
71+
cache: npm
72+
- name: Set base and head for Nx affected commands
73+
uses: nrwl/nx-set-shas@v4
74+
- name: Install dependencies
75+
run: npm ci
76+
- name: Unit test affected projects
77+
run: npx nx affected -t unit-test --parallel=3
3278

33-
- run: git branch --track main origin/main
34-
if: ${{ github.event_name == 'pull_request' }}
79+
integration-test:
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
os: [ubuntu-latest, windows-latest, macos-latest]
84+
name: Integration tests
85+
runs-on: ${{ matrix.os }}
86+
steps:
87+
- name: Checkout repository
88+
uses: actions/checkout@v4
89+
with:
90+
fetch-depth: 0
91+
- name: Set up Node.js
92+
uses: actions/setup-node@v4
93+
with:
94+
node-version-file: .node-version
95+
cache: npm
96+
- name: Set base and head for Nx affected commands
97+
uses: nrwl/nx-set-shas@v4
98+
- name: Install dependencies
99+
run: npm ci
100+
- name: Integration test affected projects
101+
run: npx nx affected -t int-test --parallel=3
35102

36-
- run: npx nx format:check
37-
- run: npx nx affected -t lint unit-test int-test e2e-test build
103+
e2e:
104+
strategy:
105+
fail-fast: false
106+
matrix:
107+
os: [ubuntu-latest, windows-latest, macos-latest]
108+
name: E2E tests
109+
runs-on: ${{ matrix.os }}
110+
steps:
111+
- name: Checkout repository
112+
uses: actions/checkout@v4
113+
with:
114+
fetch-depth: 0
115+
- name: Set up Node.js
116+
uses: actions/setup-node@v4
117+
with:
118+
node-version-file: .node-version
119+
cache: npm
120+
- name: Set base and head for Nx affected commands
121+
uses: nrwl/nx-set-shas@v4
122+
- name: Install dependencies
123+
run: npm ci
124+
- name: E2E test affected projects
125+
run: npx nx affected -t e2e-test --parallel=1
126+
127+
build:
128+
runs-on: ubuntu-latest
129+
name: Build
130+
steps:
131+
- name: Checkout repository
132+
uses: actions/checkout@v4
133+
with:
134+
fetch-depth: 0
135+
- name: Set up Node.js
136+
uses: actions/setup-node@v4
137+
with:
138+
node-version-file: .node-version
139+
cache: npm
140+
- name: Set base and head for Nx affected commands
141+
uses: nrwl/nx-set-shas@v4
142+
- name: Install dependencies
143+
run: npm ci
144+
- name: Build all projects # affected is not used to be able to test-release packages
145+
run: npx nx run-many --target=build --parallel=3
146+
#- name: Test-release packages
147+
# run: npx pkg-pr-new publish "packages/**/dist"

e2e/plugin-knip-e2e/tests/collect.e2e.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ describe('PLUGIN collect report with knip-plugin NPM package', () => {
4242

4343
expect(code).toBe(0);
4444
expect(stdout).toContain('Knip audits');
45-
expect(stdout).toContain('Collecting report successful!');
4645

4746
const report = await readJsonFile(
4847
path.join(defaultSetupDir, '.code-pushup', 'report.json'),

e2e/plugin-knip-e2e/tests/knip-reporter.e2e.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ describe('knip reporter for code pushup audits', () => {
4444
'knip',
4545
'--no-exit-code',
4646
`--reporter=${reporterPath}`,
47-
/* eslint-disable-next-line unicorn/prefer-string-raw */
48-
`--reporter-options={\\"outputFile\\":\\"knip-report.json\\"}`,
47+
`--reporter-options=${JSON.stringify(JSON.stringify({ outputFile: 'knip-report.json' }))}`,
4948
],
5049
cwd: reporterSetupDir,
5150
});
@@ -66,7 +65,7 @@ describe('knip reporter for code pushup audits', () => {
6665
message: 'Unused dependency zod',
6766
severity: 'error',
6867
source: {
69-
file: expect.stringContaining('package.json'),
68+
file: expect.pathToEndWith('package.json'),
7069
position: {
7170
startColumn: 6,
7271
startLine: 4,

e2e/plugin-knip-e2e/tsconfig.test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"vitest.e2e.config.ts",
1010
"tests/**/*.e2e.test.ts",
1111
"tests/**/*.d.ts",
12-
"mocks/**/*.ts"
12+
"mocks/**/*.ts",
13+
"../../testing/test-setup/src/vitest.d.ts"
1314
]
1415
}

0 commit comments

Comments
 (0)