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

Tooling: Use NX instead of Lerna for running tasks #260

Merged
merged 3 commits into from
Jun 1, 2023
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
26 changes: 14 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- name: Setup .npmrc file for NPM registry
uses: actions/setup-node@v3
with:
Expand All @@ -21,27 +23,27 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --prefer-offline
- name: Check types
run: yarn typecheck
run: yarn nx affected -t typecheck --parallel
- name: Lint
run: yarn lint
run: yarn nx affected -t lint --parallel
- name: Unit tests
run: yarn test:ci
run: yarn nx affected -t test --ci
- name: Build all packages
run: yarn build

- name: '@grafana/create-plugin - test an app plugin generation'
run: yarn workspace @grafana/create-plugin run generate-app && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
run: yarn nx run @grafana/create-plugin:generate-app && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test an app with backend plugin generation'
run: yarn workspace @grafana/create-plugin run generate-app-backend && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
run: yarn nx run @grafana/create-plugin:generate-app-backend && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test panel plugin generation'
run: yarn workspace @grafana/create-plugin run generate-panel && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
run: yarn nx run @grafana/create-plugin:generate-panel && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test datasource plugin generation'
run: yarn workspace @grafana/create-plugin run generate-datasource && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
run: yarn nx run @grafana/create-plugin:generate-datasource && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test datasource with backend plugin generation'
run: yarn workspace @grafana/create-plugin run generate-datasource-backend && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
run: yarn nx run @grafana/create-plugin:generate-datasource-backend && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test scenes app plugin generation'
run: yarn workspace @grafana/create-plugin run generate-scenes-app && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
run: yarn nx run @grafana/create-plugin:generate-scenes-app && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)

- name: '@grafana/sign-plugin - build'
run: yarn workspace @grafana/sign-plugin run build
- name: '@grafana/sign-plugin - sign generated plugin'
env:
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --prefer-offline
- name: Build documentation website
run: yarn workspace website run build
run: yarn docs:build

# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
paths:
- '.github/workflows/deploy.yml'
- '.github/workflows/test-deploy.yml'
- '.github/workflows/test-build.yml'
- 'docusaurus/**'

jobs:
Expand All @@ -26,4 +26,4 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --prefer-offline
- name: Build documentation website
run: yarn workspace website run build
run: yarn docs:build
29 changes: 29 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test"]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/dist"]
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc"]
},
"test": {
"inputs": ["default", "{projectRoot}/jest.config.js", "{workspaceRoot}/jest.config.base.js"]
}
},
"namedInputs": {
"sharedGlobals": ["{workspaceRoot}/.github/workflows/ci.yml"]
},
"affected": {
"defaultBase": "main"
}
}
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"author": "Grafana",
"private": true,
"scripts": {
"clean": "lerna run clean",
"build": "lerna run build --scope=\"@grafana/*\"",
"dev": "lerna run dev",
"docs": "yarn workspace website run start",
"docs:build": "yarn workspace website run build",
"lint": "lerna run lint",
"lint:fix": "lerna run lint:fix",
"clean": "nx run-many --target=clean",
"build": "nx run-many --target=build --parallel --exclude website",
"dev": "nx run-many --target=dev --parallel",
"docs": "nx run website:start",
"docs:build": "nx run website:build",
"lint": "nx run-many --target=lint --parallel",
"lint:fix": "nx run-many --target=lint:fix --parallel",
"release": "auto shipit",
"test": "lerna run test",
"test:ci": "lerna run test --ci",
"typecheck": "lerna run typecheck"
"test": "nx run-many --target=test --parallel",
"test:ci": "nx run-many --target=test --ci",
"typecheck": "nx run-many --target=typecheck --parallel"
},
"devDependencies": {
"@auto-it/all-contributors": "^10.37.6",
Expand All @@ -29,8 +29,9 @@
"@types/node": "18.11.7",
"auto": "^10.37.6",
"jest": "^27.5.1",
"lerna": "^6.0.1",
"lerna": "6.6.1",
"nodemon": "^2.0.13",
"nx": "16.2.1",
"prettier": "2.5.1",
"tsc-watch": "^4.5.0",
"typescript": "^4.4.3"
Expand Down
Loading