Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for nx 18.x #192

Merged
merged 4 commits into from
Mar 6, 2024
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
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Nx 18 enables using plugins to infer targets by default
# This is disabled for existing workspaces to maintain compatibility
# For more info, see: https://nx.dev/concepts/inferred-tasks
NX_ADD_PLUGINS=false
3 changes: 0 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
},
{
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
- run: npm ci

- run: npx nx format:check
- run: npx nx affected --target=lint --parallel=3
- run: npx nx affected --target=test --parallel=3 --ci --code-coverage --silent
- run: npx nx affected --target=build --parallel=3
- run: npx nx affected -t lint test build
- run: |
echo "NO_COVERAGE_RUN=$(if [ -z "$(npx nx print-affected --select=projects)" ]; then echo "true"; else echo "false";fi)" >> $GITHUB_ENV
- name: Merge coverage
Expand Down
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
sonar.exclusions=**/tests/**/*, **/test/**/*, **/*.spec.*

# Exclude from SonarCloud duplication measure
sonar.cpd.exclusions=**/jest.config.ts
sonar.cpd.exclusions=**/vite.config.ts
10 changes: 0 additions & 10 deletions e2e/data-migration-e2e/jest.config.ts

This file was deleted.

8 changes: 2 additions & 6 deletions e2e/data-migration-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
"sourceRoot": "e2e/data-migration-e2e/src",
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/data-migration-e2e/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
"executor": "@nx/vite:test",
"options": {},
"dependsOn": ["data-migration:build"]
},
"lint": {
Expand Down
17 changes: 7 additions & 10 deletions e2e/data-migration-e2e/tests/dynamodb-migration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ describe('dynamodb-migration e2e', () => {
// on a unique project in the workspace, such that they
// are not dependant on one another.
beforeAll(() => {
ensureNxProject(
'@nxlv/dynamodb-python',
'dist/packages/dynamodb-migration'
);
ensureNxProject('@nxlv/data-migration', 'dist/packages/dynamodb-migration');
});

afterAll(() => {
Expand All @@ -29,7 +26,7 @@ describe('dynamodb-migration e2e', () => {
it('should create dynamodb-migration', async () => {
const project = uniq('dynamodb-migration');
await runNxCommandAsync(
`generate @nxlv/dynamodb-python:dynamodb-migration ${project}`
`generate @nxlv/data-migration:dynamodb-migration ${project}`,
);
const result = await runNxCommandAsync(`build ${project}`);
expect(result.stdout).toContain('Executor ran');
Expand All @@ -39,10 +36,10 @@ describe('dynamodb-migration e2e', () => {
it('should create src in the specified directory', async () => {
const project = uniq('dynamodb-migration');
await runNxCommandAsync(
`generate @nxlv/dynamodb-python:dynamodb-migration ${project} --directory subdir`
`generate @nxlv/data-migration:dynamodb-migration ${project} --directory subdir`,
);
expect(() =>
checkFilesExist(`libs/subdir/${project}/src/index.ts`)
checkFilesExist(`libs/subdir/${project}/src/index.ts`),
).not.toThrow();
}, 120000);
});
Expand All @@ -51,11 +48,11 @@ describe('dynamodb-migration e2e', () => {
it('should add tags to the project', async () => {
const projectName = uniq('dynamodb-migration');
ensureNxProject(
'@nxlv/dynamodb-python',
'dist/packages/dynamodb-migration'
'@nxlv/data-migration',
'dist/packages/dynamodb-migration',
);
await runNxCommandAsync(
`generate @nxlv/dynamodb-python:dynamodb-migration ${projectName} --tags e2etag,e2ePackage`
`generate @nxlv/data-migration:dynamodb-migration ${projectName} --tags e2etag,e2ePackage`,
);
const project = readJson(`libs/${projectName}/project.json`);
expect(project.tags).toEqual(['e2etag', 'e2ePackage']);
Expand Down
18 changes: 15 additions & 3 deletions e2e/data-migration-e2e/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"jest.config.ts",
"vite.config.ts",
"vitest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
34 changes: 34 additions & 0 deletions e2e/data-migration-e2e/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite';

import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/e2e/data-migration-e2e',

plugins: [nxViteTsPaths()],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

test: {
name: 'data-migration-e2e',
minWorkers: 1,
maxWorkers: 1,
globals: true,
cache: {
dir: '../../node_modules/.vitest',
},
environment: 'node',
include: ['tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],

reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/e2e/data-migration-e2e',
provider: 'v8',
},
},
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["../../../.eslintrc.json"],
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
Expand Down
15 changes: 0 additions & 15 deletions e2e/nx-python-e2e/jest.config.ts

This file was deleted.

12 changes: 6 additions & 6 deletions e2e/nx-python-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"sourceRoot": "e2e/nx-python-e2e/src",
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "e2e/nx-python-e2e/jest.config.ts",
"runInBand": true,
"passWithNoTests": false
},
"executor": "@nx/vite:test",
"options": {},
"dependsOn": ["nx-python:build"]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
}
},
"tags": [],
Expand Down
84 changes: 83 additions & 1 deletion e2e/nx-python-e2e/tests/__snapshots__/nx-python.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,86 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`nx-python e2e > shared virtual environment > should create nx-python project with 3 levels with shared virtual environment 1`] = `
"[tool.nx]
autoActivate = true

[tool.poetry]
name = "@proj/source"
version = "1.0.0"
description = ""
authors = [ ]
license = "Proprietary"
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.9,<3.11"

[tool.poetry.dependencies.app1]
path = "app1"
develop = true

[tool.poetry.dependencies.lib1]
path = "lib1"
develop = true

[tool.poetry.dependencies.lib2]
path = "lib2"
develop = true

[tool.poetry.group.dev.dependencies]
autopep8 = "2.0.2"
flake8 = "6.0.0"
pytest = "7.3.1"
pytest-sugar = "0.9.7"
pytest-cov = "4.1.0"
pytest-html = "3.2.0"

[build-system]
requires = [ "poetry-core==1.1.0" ]
build-backend = "poetry.core.masonry.api"
"
`;

exports[`nx-python e2e > shared virtual environment > should create one nx-python project, migrate to shared venv and add 3 levels 1`] = `
"[tool.nx]
autoActivate = true

[tool.poetry]
name = "@proj/source"
version = "1.0.0"
description = ""
authors = [ ]
license = "Proprietary"
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.9,<3.11"

[tool.poetry.dependencies.app1]
path = "app1"
develop = true

[tool.poetry.dependencies.lib1]
path = "lib1"
develop = true

[tool.poetry.dependencies.lib2]
path = "lib2"
develop = true

[tool.poetry.group.dev.dependencies]
autopep8 = "2.0.2"
flake8 = "6.0.0"
pytest = "7.3.1"
pytest-sugar = "0.9.7"
pytest-cov = "4.1.0"
pytest-html = "3.2.0"

[build-system]
requires = [ "poetry-core==1.1.0" ]
build-backend = "poetry.core.masonry.api"
"
`;

exports[`nx-python e2e shared virtual environment should create nx-python project with 3 levels with shared virtual environment 1`] = `
"[tool.nx]
Expand Down
Loading
Loading