Skip to content

Commit

Permalink
chore: use nx commands (#2493)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna authored Nov 5, 2024
1 parent 95547b8 commit 6234918
Show file tree
Hide file tree
Showing 68 changed files with 137 additions and 75 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
with:
fetch-depth: 0

# If you update this version make sure to keep in sync:
# - `build-and-cache` job of unit-test workflow
# - `build-and-cache` job of test-all-versions workflow
- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/test-all-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,36 @@ on:
type: string

jobs:
build-and-cache:
strategy:
fail-fast: false
runs-on: ubuntu-latest
env:
NPM_CONFIG_UNSAFE_PERM: true
NODE_OPTIONS: --max-old-space-size=4096
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Use the same Node.js version used for `release-please` workflow.
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install
run: npm ci
- name: Build
run: npm run compile
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: tav-build-cache-${{ github.run_number }}
path: node_modules/.cache/nx
retention-days: 1

tav:
name: Run test-all-versions
needs: build-and-cache
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -120,6 +148,11 @@ jobs:
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
- name: Install
run: npm ci
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: tav-build-cache-${{ github.run_number }}
path: node_modules/.cache/nx
- name: Build
run: npm run compile
- name: Run test-all-versions
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,35 @@ on:
pull_request:

jobs:
build-and-cache:
strategy:
fail-fast: false
runs-on: ubuntu-latest
env:
NPM_CONFIG_UNSAFE_PERM: true
NODE_OPTIONS: --max-old-space-size=4096
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Use the same Node.js version used for `release-please` workflow.
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install
run: npm ci
- name: Build
run: npm run compile
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: tests-build-cache-${{ github.run_number }}
path: node_modules/.cache/nx
retention-days: 1

unit-test:
needs: build-and-cache
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -128,6 +156,11 @@ jobs:
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
- name: Install
run: npm ci
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: tests-build-cache-${{ github.run_number }}
path: node_modules/.cache/nx
- name: Build
run: npm run compile
- name: Unit tests (Full)
Expand All @@ -145,6 +178,7 @@ jobs:
verbose: true

browser-test:
needs: build-and-cache
strategy:
fail-fast: false
matrix:
Expand All @@ -166,6 +200,11 @@ jobs:
run: npm install -g npm@9 # npm@9 supports node >=14.17.0
- name: Install
run: npm ci
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: tests-build-cache-${{ github.run_number }}
path: node_modules/.cache/nx
- name: Build
run: npm run compile
- name: Unit tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-alibaba-cloud --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-aws --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand Down Expand Up @@ -40,6 +39,8 @@
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.42.0",
"@opentelemetry/instrumentation-fs": "^0.16.0",
"@opentelemetry/instrumentation-http": "^0.54.0",
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/sinon": "10.0.20",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-azure --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand All @@ -33,6 +32,7 @@
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.42.0",
"@opentelemetry/instrumentation-http": "^0.54.0",
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/sinon": "10.0.20",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-container --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand All @@ -34,6 +33,7 @@
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.42.0",
"@opentelemetry/instrumentation-fs": "^0.16.0",
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/sinon": "10.0.20",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-gcp --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand Down Expand Up @@ -40,6 +39,7 @@
"devDependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/contrib-test-utils": "^0.42.0",
"@opentelemetry/instrumentation-http": "^0.54.0",
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/semver": "7.5.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-github --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-instana --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand Down
1 change: 0 additions & 1 deletion metapackages/auto-configuration-propagators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/auto-configuration-propagators --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
1 change: 0 additions & 1 deletion metapackages/auto-instrumentations-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/auto-instrumentations-node --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"tdd": "yarn test -- --watch-extensions ts --watch",
Expand Down
1 change: 0 additions & 1 deletion metapackages/auto-instrumentations-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/auto-instrumentations-web --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test:browser": "nyc karma start --single-run",
Expand Down
43 changes: 43 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"compile",
"lint",
"version:update"
]
}
}
},
"targetDefaults": {
"compile": {
"dependsOn": [
"version:update",
"^compile"
],
"inputs": [
"{projectRoot}/src",
"{projectRoot}/test"
],
"outputs": [
"{projectRoot}/build"
]
},
"lint": {
"inputs": [
"{projectRoot}/src",
"{projectRoot}/test"
]
},
"version:update": {
"inputs": [
"{projectRoot}/package.json"
],
"outputs": [
"{projectRoot}/src/version.ts"
]
}
}
}
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,22 @@
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"scripts": {
"clean": "lerna run clean",
"precompile": "tsc --version && npm run version:update",
"version:update": "lerna run version:update",
"compile": "lerna run compile",
"prewatch": "npm run precompile",
"test": "lerna run test",
"test:ci:changed": "lerna run test --since origin/main",
"test:browser": "lerna run test:browser --concurrency 1",
"test-all-versions": "npm run --if-present --workspaces test-all-versions",
"bump": "lerna publish",
"clean": "nx run-many -t clean",
"version:update": "nx run-many -t version:update",
"compile": "nx run-many -t compile",
"test": "nx run-many -t test",
"test:browser": "nx run-many -t test:browser",
"test:ci:changed": "nx affected -t test --base=origin/main --head=HEAD",
"test-all-versions": "nx run-many -t test-all-versions",
"changelog": "lerna-changelog",
"lint": "lerna run lint && npm run lint:deps && npm run lint:readme && npm run lint:markdown",
"lint:fix": "lerna run lint:fix && npm run lint:markdown:fix",
"lint": "nx run-many -t lint && npm run lint:readme && npm run lint:markdown",
"lint:fix": "nx run-many -t lint:fix && npm run lint:markdown:fix",
"lint:deps": "npx --yes [email protected] --dependencies --production --tags=-knipignore",
"lint:examples": "eslint ./examples/**/*.js",
"lint:examples:fix": "eslint ./examples/**/*.js --fix",
"lint:markdown": "markdownlint-cli2 $(git ls-files '*.md')",
"lint:markdown:fix": "markdownlint-cli2 --fix $(git ls-files '*.md')",
"lint:readme": "lerna run lint:readme"
"lint:readme": "nx run-many -t lint:readme"
},
"keywords": [
"opentelemetry",
Expand All @@ -57,6 +54,7 @@
"lerna-changelog": "2.2.0",
"markdownlint-cli2": "0.13.0",
"minimatch": "^9.0.3",
"nx": "15.9.7",
"mocha": "^10.7.3",
"prettier": "2.8.8",
"process": "0.11.10",
Expand Down
1 change: 0 additions & 1 deletion packages/baggage-span-processor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/baggage-span-processor --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
1 change: 0 additions & 1 deletion packages/opentelemetry-host-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/host-metrics --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
1 change: 0 additions & 1 deletion packages/opentelemetry-id-generator-aws-xray/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js-contrib",
"scripts": {
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/id-generator-aws-xray --include-dependencies",
"prewatch": "npm run precompile",
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
Expand Down
1 change: 0 additions & 1 deletion packages/opentelemetry-propagation-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/propagation-utils --include-dependencies",
"prepublishOnly": "npm run compile",
"prewatch": "npm run precompile",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
1 change: 0 additions & 1 deletion packages/opentelemetry-redis-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"compile": "tsc --build tsconfig.json",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/redis-common --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand Down
1 change: 0 additions & 1 deletion packages/opentelemetry-sql-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"compile": "tsc --build tsconfig.json",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/sql-common --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
Expand Down
Loading

0 comments on commit 6234918

Please sign in to comment.