Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 130 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,147 @@
name: CI
permissions:
contents: read

on:
push:
branches:
- main
branches: [main]
pull_request:
branches: [main]

permissions:
actions: read
contents: read
env:
NX_NON_NATIVE_HASHER: true

jobs:
main:
format:
runs-on: ubuntu-latest
name: Format check
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Check formatting of affected files
run: npx nx format:check

# Connect your workspace on nx.app and uncomment this to enable task distribution.
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested
# - run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build"
lint:
runs-on: ubuntu-latest
name: Linter
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Lint affected projects
run: npx nx affected -t lint --parallel=3

# Cache node_modules
- uses: actions/setup-node@v3
unit-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: Unit tests
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
node-version: 20
cache: 'npm'
- run: npm ci
- uses: nrwl/nx-set-shas@v4
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Unit test affected projects
run: npx nx affected -t unit-test --parallel=3

- run: git branch --track main origin/main
if: ${{ github.event_name == 'pull_request' }}
integration-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: Integration tests
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Integration test affected projects
run: npx nx affected -t int-test --parallel=3

- run: npx nx format:check
- run: npx nx affected -t lint unit-test int-test e2e-test build
e2e:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: E2E tests
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: E2E test affected projects
run: npx nx affected -t e2e-test --parallel=1

build:
runs-on: ubuntu-latest
name: Build
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Build all projects # affected is not used to be able to test-release packages
run: npx nx run-many --target=build --parallel=3
#- name: Test-release packages
# run: npx pkg-pr-new publish "packages/**/dist"
1 change: 0 additions & 1 deletion e2e/plugin-knip-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe('PLUGIN collect report with knip-plugin NPM package', () => {

expect(code).toBe(0);
expect(stdout).toContain('Knip audits');
expect(stdout).toContain('Collecting report successful!');

const report = await readJsonFile(
path.join(defaultSetupDir, '.code-pushup', 'report.json'),
Expand Down
5 changes: 2 additions & 3 deletions e2e/plugin-knip-e2e/tests/knip-reporter.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ describe('knip reporter for code pushup audits', () => {
'knip',
'--no-exit-code',
`--reporter=${reporterPath}`,
/* eslint-disable-next-line unicorn/prefer-string-raw */
`--reporter-options={\\"outputFile\\":\\"knip-report.json\\"}`,
`--reporter-options=${JSON.stringify(JSON.stringify({ outputFile: 'knip-report.json' }))}`,
],
cwd: reporterSetupDir,
});
Expand All @@ -66,7 +65,7 @@ describe('knip reporter for code pushup audits', () => {
message: 'Unused dependency zod',
severity: 'error',
source: {
file: expect.stringContaining('package.json'),
file: expect.pathToEndWith('package.json'),
position: {
startColumn: 6,
startLine: 4,
Expand Down
3 changes: 2 additions & 1 deletion e2e/plugin-knip-e2e/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"vitest.e2e.config.ts",
"tests/**/*.e2e.test.ts",
"tests/**/*.d.ts",
"mocks/**/*.ts"
"mocks/**/*.ts",
"../../testing/test-setup/src/vitest.d.ts"
]
}
Loading