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!: upgrade to nx 19.1 and angular 18 #209

Merged
merged 32 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
99c29f8
chore: upgrade to nx 19.1 and angular 18
nacho-vazquez May 28, 2024
c0fa635
docs: update compatibility table
nacho-vazquez May 28, 2024
1b4d37a
feat: swap angular build of app to esbuild and start using pnpm
nacho-vazquez May 28, 2024
2d1c2f8
ci: use pnpm instead of yarn
nacho-vazquez May 28, 2024
95b8f95
fix: specify pnpm on restrictions
nacho-vazquez May 28, 2024
a51105d
ci: change to new nx ci
nacho-vazquez May 28, 2024
15ad7c2
fix: ci dependencies
nacho-vazquez May 28, 2024
b55ee5c
fix: format issues
nacho-vazquez May 28, 2024
bb63f96
fix: replace yarn with pnpm
nacho-vazquez May 28, 2024
b69208a
fix: adjust cypress config
nacho-vazquez May 28, 2024
42536cf
fix: app serving
nacho-vazquez May 28, 2024
af02556
fix: docusaurus
nacho-vazquez May 29, 2024
0697ba5
fix: format issues
nacho-vazquez May 29, 2024
eeb1bfa
fix: exclude build docusarus from prettier
nacho-vazquez May 29, 2024
0543ced
fix: format issues
nacho-vazquez May 29, 2024
4d60dae
fix: create dist directory if it doesn't exist
nacho-vazquez May 30, 2024
2c3b511
fix: never ending e2e
nacho-vazquez May 30, 2024
5a8c97f
fix: ci
nacho-vazquez May 30, 2024
efc2f7b
fix: try to cache cypress
nacho-vazquez May 30, 2024
e665f73
fix: remove bad config
nacho-vazquez May 30, 2024
3a5c20d
fix: attempt to cache cypress
nacho-vazquez May 30, 2024
41f1fc9
fix: try e2e-ci
nacho-vazquez May 30, 2024
1b5e20b
chore: update to the latest nx and pnpm
nacho-vazquez Jul 13, 2024
c24bf64
chore: update to pnpm 9 on ci
nacho-vazquez Jul 13, 2024
27de2ac
chore: migrate to node 20
nacho-vazquez Jul 13, 2024
49da12a
ci: use normal e2e instead of the ci version
nacho-vazquez Jul 13, 2024
7a4e48d
fix: restore ci config
nacho-vazquez Jul 13, 2024
d99a8e8
fix: e2e configuration
nacho-vazquez Jul 13, 2024
516d35c
fix: run e2e-ci in serial
nacho-vazquez Jul 13, 2024
c67868b
fix: missing command orchestrator
nacho-vazquez Jul 13, 2024
158ef5d
fix: remove duplicated docusaurus config
nacho-vazquez Jul 13, 2024
05b94b3
chore: update local ci script
nacho-vazquez Jul 13, 2024
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
10 changes: 8 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
"rules": {
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
Expand All @@ -57,7 +60,10 @@
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
"rules": {
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx", "*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
Expand Down
15 changes: 7 additions & 8 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ runs:
id: node_version
shell: bash
run: echo "node_version=$(cat .nvmrc)" >> $GITHUB_OUTPUT

- uses: pnpm/action-setup@v2
with:
version: 9

- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: yarn
node-version: ${{ steps.node_version.outputs.node_version }}
# This doesn't just set the registry url, but also sets
# the right configuration in .npmrc that reads NPM token
# from NPM_AUTH_TOKEN environment variable.
# It actually creates a .npmrc in a temporary folder
# and sets the NPM_CONFIG_USERCONFIG environment variable.
registry-url: https://registry.npmjs.org
cache: 'pnpm'

- name: Install dependencies
shell: bash
run: yarn install --immutable --immutable-cache
run: pnpm install
151 changes: 81 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- main
pull_request: {}

permissions:
actions: read
contents: read

concurrency:
# Group concurrency on workflow, then:
# - Is merge run? Group on branch name (`refs/heads/main`)
Expand All @@ -24,73 +28,80 @@ env:
NODE_OPTIONS: --max-old-space-size=6144

jobs:
# We're using Nx Cloud for Distributed Task Execution
# Reference: https://nx.dev/using-nx/dte
#
# The coordinator outputs the combination of task outputs from the agents,
# both terminal and file outputs
dte_coordinator:
name: DTE Coordinator
uses: nrwl/ci/.github/workflows/[email protected]
secrets:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
permissions:
contents: read
actions: read
with:
main-branch-name: main
# Must match dte_agents.number-of-agents
number-of-agents: 4
# The --stop-agents-after parameter must match the task target listed last
# in the parallel-commands-on-agents command list
# The --agent-count parameter must match the number-of-agents parameter
init-commands: |
yarn nx-cloud start-ci-run --stop-agents-after="e2e" --agent-count=4
# Commands run in parallel on this DTE coordinator
parallel-commands: |
yarn nx-cloud record -- yarn nx format:check
# Commands distributed between DTE agents
# Distribution strategy for 2 vCPUs per hosted runner (GitHub Free):
# lint: 2 tasks assigned at a time, 1 task per vCPU
# test: 1 task assigned at a time with 2 parallel processes, 1 process per vCPU
# build: 2 tasks assigned at a time, 1 task per vCPU
# e2e: 1 task assigned at a time, 1 task total
parallel-commands-on-agents: |
yarn nx run-many --all --target=lint --configuration=report --parallel=2 --max-warnings=0
yarn nx run-many --all --target=test --configuration=coverage --parallel=1 --max-workers=2
yarn nx affected --target=build --parallel=2
yarn nx affected --target=e2e --parallel=1
# Commands run sequentially on this DTE coordinator after parallel jobs
# final-commands: |

# We're using Nx Cloud for Distributed Task Execution
# Reference: https://nx.dev/using-nx/dte
#
# Agents receive tasks to execute in bulk whenever they are ready or have
# finished their previous tasks
dte_agents:
name: DTE Agents
uses: nrwl/ci/.github/workflows/[email protected]
secrets:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
permissions:
contents: read
actions: read
with:
# The Free GitHub plan has a limit of 20 concurrent jobs on Ubuntu images
# Reference: https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration
# If we need to, we can optimize for 2 simultaneous workflow runs:
# 2 x 1 main job = 2 concurrent jobs
# 2 x 9 agent jobs = 18 concurrent jobs
# Total = 20 concurrent jobs
#
# However, we don't have many projects or targets in this workspace, so we
# lower the number of agents to reduce spent compute time.
number-of-agents: 4
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# 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"

- uses: pnpm/action-setup@v2
with:
version: 9
# Cache node_modules
- uses: actions/setup-node@v4
with:
node-version: 20

- uses: nrwl/nx-set-shas@v4

# Restore the previous npm modules and Cypress binary archives.
# Any updated archives will be saved automatically after the entire
# workflow successfully finishes.
# See https://github.com/actions/cache
# we use exact restore key to avoid npm module snowballing
# https://glebbahmutov.com/blog/do-not-let-npm-cache-snowball/
- name: Cache central npm modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ github.ref }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-${{ github.ref }}-${{ hashFiles('**/pnpm-lock.yaml') }}

# we use the exact restore key to avoid Cypress binary snowballing
# https://glebbahmutov.com/blog/do-not-let-cypress-cache-snowball/
- name: Cache Cypress binary
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
cypress-${{ runner.os }}-cypress-${{ github.ref }}-${{ hashFiles('**/pnpm-lock.yaml') }}

# Cache local node_modules to pass to testing jobs
- name: Cache local node_modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ github.ref }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-modules-${{ github.ref }}-

- name: install dependencies and verify Cypress
env:
# make sure every Cypress install prints minimal information
CI: 1
run: |
pnpm install --frozen-lockfile
pnpm exec cypress cache path
pnpm exec cypress cache list
pnpm exec cypress verify
pnpm exec cypress info

- name: Run NX Commands
run: |
pnpm exec nx-cloud record -- nx format:check
pnpm exec nx affected -t lint test build
pnpm exec nx affected -t e2e-ci --parallel=1

deploy-docs:
name: '[Merge] Deploy docs to GitHub Pages'
needs: dte_coordinator
needs: main
if: github.event_name == 'push' && github.ref_name == 'main'
runs-on: ubuntu-latest
permissions:
Expand All @@ -110,9 +121,9 @@ jobs:
uses: ./.github/actions/setup
# Uses the cache generated in the distributed step
- name: Build docs
run: yarn nx build docs-lumberjack-docs-app
run: pnpm exec nx build docs-lumberjack-docs-app
- name: Set up GitHub Pages
uses: actions/configure-pages@v4
uses: actions/nonfigure-pages@v4
- name: Upload docs to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
Expand All @@ -123,7 +134,7 @@ jobs:

sonarcloud:
name: SonarCloud
needs: dte_coordinator
needs: main
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -138,13 +149,13 @@ jobs:
uses: ./.github/actions/setup
# Uses the cache generated in the distributed step (Needed for the sonar eslint reports).
- name: Lint with reports
run: yarn nx run-many --all --target=lint --configuration=report --parallel=2 --max-warnings=0
run: pnpm exec nx run-many --all --target=lint --configuration=report --parallel=2 --max-warnings=0
# Uses the cache generated in the distributed step (Needed for the sonar jest coverage reports).
- name: Tests with coverage
run: yarn nx run-many --all --target=test --configuration=coverage --parallel=1 --max-workers=2
run: pnpm exec nx run-many --all --target=test --configuration=coverage --parallel=1 --max-workers=2

- name: Configure Sonar report paths
run: yarn configure-sonar-report-paths
run: pnpm run configure-sonar-report-paths

- name: SonarCloud Scan
uses: sonarsource/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
# Generates the changelog commit and tags and pushes them to Github.
# Use two post actions to Create a release in Github and for Publishing the package to NPM
shell: bash
run: npx nx version ngworker-lumberjack --releaseAs=${{ github.event.inputs.release_as }}
run: pnpm exec nx version ngworker-lumberjack --releaseAs=${{ github.event.inputs.release_as }}

# Needed if we want to automize multiple releases with the affected commands.
- name: Tag last-release
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ migrations.json
.docusaurus/
.cache-loader/

.nx/cache
.nx/cache
.nx/workspace-data
.angular
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.0
20
6 changes: 5 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
/reports
/.angular/
.docusaurus/
build

# Generated files
packages/**/CHANGELOG.md

/.nx/cache
/.nx/cache
.angular

/.nx/workspace-data
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
Start by installing all dependencies:

```bash
yarn
pnpm install
```

Run the tests:

```bash
yarn test
yarn e2e
pnpm exec test
pnpm exec e2e
```

Run the playground app:

```bash
yarn start
pnpm exec start
```

## Building

```bash
yarn build
pnpm exec build
```

## <a name="rules"></a> Coding Rules
Expand Down
10 changes: 9 additions & 1 deletion e2e/docs/lumberjack-docs-app-e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
...nxE2EPreset(__dirname),
...nxE2EPreset(__filename, {
cypressDir: 'src',
webServerCommands: {
default: 'nx run docs-lumberjack-docs-app:serve:development',
production: 'nx run docs-lumberjack-docs-app:serve:production',
},
ciWebServerCommand: 'nx run docs-lumberjack-docs-app:start',
}),
baseUrl: 'http://localhost:3000',
},
});
37 changes: 3 additions & 34 deletions e2e/docs/lumberjack-docs-app-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,7 @@
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/docs/lumberjack-docs-app-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"dependsOn": [
{
"target": "build",
"dependencies": true
}
],
"options": {
"cypressConfig": "e2e/docs/lumberjack-docs-app-e2e/cypress.config.ts",
"devServerTarget": "docs-lumberjack-docs-app:serve:development",
"testingType": "e2e"
},
"configurations": {
"production": {
"devServerTarget": "docs-lumberjack-docs-app:serve:production"
}
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"configurations": {
"report": {
"format": "json",
"force": true,
"outputFile": "reports/e2e/docs/lumberjack-docs-app-e2e/lint/report.json"
}
}
}
},
"tags": [],
"implicitDependencies": ["docs-lumberjack-docs-app"]
"tags": ["scope:internal", "type:e2e"],
"implicitDependencies": ["docs-lumberjack-docs-app"],
"targets": {}
}
7 changes: 0 additions & 7 deletions e2e/examples/lumberjack-app-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["src/plugins/index.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off"
}
}
]
}
Loading
Loading