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: update Nx workspace to v20.1.2 #240

Merged
merged 23 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b0c3bb9
chore: convert to inferred tasks
tinesoft Aug 16, 2024
c36065b
feat: update Nx workspace to `v20.1.2`
tinesoft Nov 6, 2024
25f9b80
feat: add support for the `useGithub` option in all the `create-nx-*`…
tinesoft Nov 20, 2024
d9e330e
chore: allow persiting shell history in `devcontainer`
tinesoft Dec 1, 2024
bd7bb9d
chore: update e2e tasks, to only populate local registry once for all…
tinesoft Nov 23, 2024
5cdaaf4
chore: set packages version to `0.0.0-dev` to allow local publishing…
tinesoft Dec 3, 2024
87ace03
chore: exclude all `tmp` folders from git history (for `e2e` tests)
tinesoft Dec 3, 2024
9f17c96
chore: migrate Nx workspace to `v20.2.2`
tinesoft Dec 11, 2024
130b0ef
chore: update schema and generators
tinesoft Dec 14, 2024
29f974c
fix(nx-ktor): fix url to generate the project
tinesoft Dec 14, 2024
aa6e2f2
feat(common-cli): add `presetVersion` option
tinesoft Dec 14, 2024
e8c3119
test: fix `e2e` tests
tinesoft Dec 14, 2024
6b178f5
feat(common-cli): add support for inferred tasks when adding the plug…
tinesoft Dec 31, 2024
5aa7790
chore: restore caching of custom tools (`sdkman`, `flutter`, etc) on …
tinesoft Dec 4, 2024
dea2277
chore: upgrade base nx agent image to `ubuntu22.04-node20.11-v10` and…
tinesoft Dec 4, 2024
4eafd5a
chore: increase nx agent resource-class to `large`
tinesoft Dec 4, 2024
096503e
chore: fix ci (remove parallel) and update agents config
tinesoft Dec 15, 2024
cb49b0b
chore: update schemas
tinesoft Jan 9, 2025
9fd630f
chore: fix e2e tests
tinesoft Jan 16, 2025
307ded1
chore: change distribution of nx agents
tinesoft Jan 16, 2025
80b6a76
chore: update to Nx workspace to `v20.3.3`
tinesoft Jan 25, 2025
d1a0a11
chore: use atomizer for unit tests on ci
tinesoft Jan 26, 2025
c185a2d
chore: update to Nx workspace to `v20.4.0`
tinesoft Jan 30, 2025
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
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
"ghcr.io/devcontainers/features/java:1": {
"installGradle": true,
"installMaven": true,
"version": "21"
"version": "17"
},
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
@@ -26,7 +26,8 @@
},

"mounts": [
"source=nxrocks-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
"source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume",
"source=${localWorkspaceFolderBasename}-profile,target=/root,type=volume","target=/root/.vscode-server,type=volume"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ jobs:
ANDROID_SDK_VERSION: 34
FLUTTER_VERSION: 3.19.3
JDK_VERSION: 17.0.11
JAVA_OPTIONS: '-Xmx3g'
timeout-minutes: 120
steps:
- name: Checkout Repo
@@ -35,7 +36,7 @@ jobs:

# 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 "e2e" targets have been requested
- run: pnpm exec nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml" --stop-agents-after="e2e-ci" --with-env-vars="ANDROID_SDK_VERSION,FLUTTER_VERSION,JDK_VERSION"
- run: pnpm exec nx-cloud start-ci-run --distribute-on=".nx/workflows/distribution-config.yaml" --stop-agents-after="e2e-ci" --with-env-vars="ANDROID_SDK_VERSION,FLUTTER_VERSION,JDK_VERSION"

# This line is needed for nx affected to work when CI is running on a PR
- run: git branch --track develop origin/develop || exit 0
@@ -46,4 +47,4 @@ jobs:
main-branch-name: 'develop'

- run: pnpm exec nx-cloud record -- nx format:check
- run: pnpm exec nx affected -t lint test build e2e-ci --parallel=5 --exclude=smoke --codeCoverage
- run: pnpm exec nx affected -t lint test-ci build e2e-ci --parallel=5 --exclude=smoke
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -34,4 +34,4 @@ jobs:
env:
NX_E2E_CI_CACHE_KEY: smoke-gha-${{ matrix.os }}-${{ matrix.node-version }}
NX_RUN_GROUP: ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}
run: pnpm nx test smoke
run: pnpm nx e2e-ci smoke
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

# compiled output
/dist
/tmp
tmp
/out-tsc
/bin

58 changes: 28 additions & 30 deletions .nx/workflows/agents.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
launch-templates:
linux-medium-js-java-flutter:
resource-class: 'docker_linux_amd64/medium'
image: 'ubuntu22.04-node20.11-v7'
resource-class: 'docker_linux_amd64/medium+'
image: 'ubuntu22.04-node20.11-v10'
init-steps:
- name: Checkout
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/checkout/main.yaml'
@@ -13,34 +13,32 @@ launch-templates:
paths: 'node_modules'
base-branch: 'develop'

# Restoring files/folders outside the workspace is not currently supoprted by Nx Cloud...
#
# - name: Restore Maven/Gradle/SDKMan Cache
# uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
# inputs:
# key: '"sdkman"|**/pom.xml|**/build.gradle|**/build.gradle.kts|**/settings.gradle|**/settings.gradle.kts'
# paths: |
# ../.m2/repository
# ../.gradle/caches
# ../.sdkman
# base-branch: 'develop'

# - name: Restore Flutter Cache
# uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
# inputs:
# key: '"flutter-sdk"|**/pubspec.yaml'
# paths: |
# ../flutter
# ../.pub-cache
# base-branch: 'develop'

# - name: Restore Android Cache
# uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
# inputs:
# key: '"android-sdk"'
# paths: |
# ../android/sdk
# base-branch: 'develop'
- name: Restore Maven/Gradle/SDKMan Cache
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
inputs:
key: '"sdkman"|**/pom.xml|**/build.gradle|**/build.gradle.kts|**/settings.gradle|**/settings.gradle.kts'
paths: |
~/.m2/repository
~/.gradle/caches
~/.sdkman
base-branch: 'develop'

- name: Restore Flutter Cache
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
inputs:
key: '"flutter-sdk"|**/pubspec.yaml'
paths: |
~/flutter
~/.pub-cache
base-branch: 'develop'

- name: Restore Android Cache
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
inputs:
key: '"android-sdk"'
paths: |
~/android/sdk
base-branch: 'develop'

- name: Install Node Modules
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-node-modules/main.yaml'
23 changes: 23 additions & 0 deletions .nx/workflows/distribution-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
distribute-on:
small-changeset: 4 linux-medium-js-java-flutter
medium-changeset: 6 linux-medium-js-java-flutter
large-changeset: 8 linux-medium-js-java-flutter
# small-changeset: 2 linux-large-js, 4 linux-medium-js-java-flutter, 2 linux-medium-js
# medium-changeset: 3 linux-large-js, 6 linux-medium-js-java-flutter, 5 linux-medium-js
# large-changeset: 4 linux-large-js, 8 linux-medium-js-java-flutter, 8 linux-medium-js
# assignment-rules:
# - target: build
# runs-on:
# - linux-large-js

# - target: e2e
# runs-on:
# - linux-medium-js-java-flutter

# - target: test
# runs-on:
# - linux-medium-js

# - target: lint
# runs-on:
# - linux-medium-js
4 changes: 0 additions & 4 deletions .nx/workflows/dynamic-changesets.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion .verdaccio/config.yml
Original file line number Diff line number Diff line change
@@ -23,10 +23,11 @@ packages:
proxy: npmjs

# log settings
logs:
log:
type: stdout
format: pretty
level: warn

publish:
allow_offline: true # set offline to true to allow publish offline

12 changes: 1 addition & 11 deletions e2e/nx-flutter-e2e/project.json
Original file line number Diff line number Diff line change
@@ -5,15 +5,5 @@
"sourceRoot": "e2e/nx-flutter-e2e/tests",
"tags": ["e2e"],
"implicitDependencies": ["nx-flutter"],
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "e2e/nx-flutter-e2e/jest.config.ts",
"runInBand": true
},
"dependsOn": ["^build"]
}
}
"targets": {}
}
6 changes: 4 additions & 2 deletions e2e/nx-flutter-e2e/tests/create-nx-flutter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
import { createCLITestProject } from '@nxrocks/common/testing';
import { execSync } from 'child_process';
@@ -23,15 +24,16 @@ describe('create-nx-flutter', () => {
`('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => {
projectDirectory = createCLITestProject(
'create-nx-flutter',
`--prjName=flutapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --no-interactive`
`--prjName=flutapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive`
);

// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-flutter', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-flutter`, {
cwd: useNxWrapper
? join(projectDirectory, '/.nx/installation')
: projectDirectory,
stdio: 'inherit',
env: process.env,
});

expect(hasNxWrapper(projectDirectory)).toEqual(useNxWrapper);
50 changes: 28 additions & 22 deletions e2e/nx-flutter-e2e/tests/nx-flutter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
import { uniq } from '@nx/plugin/testing';
import {
uniq,
} from '@nx/plugin/testing';
import { checkFilesExist, createTestProject, readJson, runNxCommandAsync } from '@nxrocks/common/testing';
checkFilesExist,
createTestProject,
readJson,
runNxCommandAsync,
} from '@nxrocks/common/testing';
import { execSync } from 'child_process';
import { rmSync } from 'fs-extra';

//jest.mock('enquirer'); // we mock 'enquirer' to bypass the interactive prompt
import * as enquirer from 'enquirer';
import { getPackageManagerCommand } from '@nx/devkit';

describe('nx-flutter e2e', () => {
let projectDirectory: string;

beforeAll(() => {
// Cleanup the test project
projectDirectory &&
rmSync(projectDirectory, {
recursive: true,
force: true,
});

projectDirectory = createTestProject();

// The plugin has been built and published to a local registry in the jest globalSetup
// Install the plugin built with the latest source code into the test repo
execSync(`npm install @nxrocks/nx-flutter@0.0.0-e2e`, {
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
});
});

afterAll(() => {
// Cleanup the test project
projectDirectory && rmSync(projectDirectory, {
recursive: true,
force: true,
});
execSync(
`${getPackageManagerCommand().addDev} @nxrocks/nx-flutter@0.0.0-e2e`,
{
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
}
);
});

it('should be installed', () => {
// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-flutter', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-flutter`, {
cwd: projectDirectory,
stdio: 'inherit',
});
@@ -52,7 +58,7 @@ describe('nx-flutter e2e', () => {
});

it('should create nx-flutter project with default options', async () => {
const appName = uniq('nx-flutter');
const appName = uniq('nx-flutter-');

const sep = process.platform === 'win32' ? '\\' : '/';
await runNxCommandAsync(
@@ -111,7 +117,7 @@ describe('nx-flutter e2e', () => {
}, 400000);

it('should create nx-flutter project with given options', async () => {
const appName = uniq('nx-flutter');
const appName = uniq('nx-flutter-');
const org = 'com.tinesoft';
const description = 'My flutter application';
const androidLanguage = 'java';
@@ -151,10 +157,10 @@ describe('nx-flutter e2e', () => {

describe('--directory', () => {
it('should create src in the specified directory', async () => {
const appName = uniq('nx-flutter');
const appName = uniq('nx-flutter-');

await runNxCommandAsync(
`generate @nxrocks/nx-flutter:create ${appName} --directory subdir --no-interactive`
`generate @nxrocks/nx-flutter:new --directory subdir/${appName} --no-interactive`
);
expect(() =>
checkFilesExist(`subdir/${appName}/pubspec.yaml`)
@@ -164,7 +170,7 @@ describe('nx-flutter e2e', () => {

describe('--tags', () => {
it('should add tags to nx.json', async () => {
const appName = uniq('nx-flutter');
const appName = uniq('nx-flutter-');

await runNxCommandAsync(
`generate @nxrocks/nx-flutter:create ${appName} --tags e2etag,e2ePackage --no-interactive`
12 changes: 1 addition & 11 deletions e2e/nx-ktor-e2e/project.json
Original file line number Diff line number Diff line change
@@ -5,15 +5,5 @@
"sourceRoot": "e2e/nx-ktor-e2e/tests",
"tags": ["e2e"],
"implicitDependencies": ["nx-ktor"],
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "e2e/nx-ktor-e2e/jest.config.ts",
"runInBand": true
},
"dependsOn": ["^build"]
}
}
"targets": {}
}
6 changes: 4 additions & 2 deletions e2e/nx-ktor-e2e/tests/create-nx-ktor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
import { execSync } from 'child_process';
@@ -23,15 +24,16 @@ describe('create-nx-ktor', () => {
`('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => {
projectDirectory = createCLITestProject(
'create-nx-ktor',
`--prjName=bootapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --no-interactive --verbose=true`
`--prjName=ktapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive`
);

// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-ktor', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-ktor`, {
cwd: useNxWrapper
? join(projectDirectory, '/.nx/installation')
: projectDirectory,
stdio: 'inherit',
env: process.env,
});

expect(hasNxWrapper(projectDirectory)).toEqual(useNxWrapper);
Loading