Skip to content

Commit

Permalink
Chore(repo): Enable distributed caching of builds using Nx Cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Oct 17, 2023
1 parent 96f3c2e commit 7388fd4
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 85 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
- packages/web/**
- packages/web-react/**

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_BRANCH: ${{ github.event.number || github.ref_name }}
NX_VERBOSE_LOGGING: true

jobs:
build:
name: Building on node ${{ matrix.node-version }})
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
schedule:
- cron: '0 9 * * *' # every day at 9:00

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_BRANCH: ${{ github.event.number || github.ref_name }}
NX_VERBOSE_LOGGING: true

jobs:
test:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -40,14 +45,18 @@ jobs:
run: yarn types

- name: Publish Web Package Code Coverage
uses: coverallsapp/[email protected]
# When Nx hits its cloud cache, there is no generated coverage to sent, e.g. do not let this crash
if: ${{ hashFiles('./packages/web/.coverage/lcov.info') != '' }}
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ./packages/web/.coverage/lcov.info
flag-name: web

- name: Publish Web-React Package Code Coverage
uses: coverallsapp/[email protected]
# When Nx hits its cloud cache, there is no generated coverage to sent, e.g. do not let this crash
if: ${{ hashFiles('./packages/web-react/.coverage/lcov.info') != '' }}
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ./packages/web-react/.coverage/lcov.info
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ packages/*/build
/test-results/
/playwright-report/
/playwright/.cache/

# Narwall Nx
# Use `nc-cloud.env ` to store the `NX_CLOUD_ACCESS_TOKEN` for connection to the Nx Cloud.
# This prevents accidental commit of this token to the repository.
nx-cloud.env
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ We are investigating how we should handle visual testing and several paths like

So the visual tests do not provide full coverage now.

### Speed up CI performance

This project uses [Nx Cloud](https://nx.app/) for speeding up CI runs by caching its results.
You can also benefit from this feature locally by adding `nx-cloud.env` to root of this project with `NX_CLOUD_ACCESS_TOKEN=<token>`.
Read-write token can be generated inside the Nx Cloud App.
Otherwise only read access is used so you cannot [upload your local cache](https://lerna.js.org/docs/features/share-your-cache).

## Publishing

This project uses GitHub Actions to publish the packages automatically to npm. New packages are published after the new tag is pushed to the main branch. PR can be merged only by the appropriate group of maintainers.
Expand Down
5 changes: 3 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
},
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": ["lint", "test", "types", "build"]
"cacheableOperations": ["lint", "test", "types", "build"],
"accessToken": "NGYxNTY3NTAtOWY5NC00MWVmLThiNWEtY2MwNjE4OWJjZTcxfHJlYWQ="
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@lmc-eu/conventional-changelog-lmc-github": "3.0.0",
"@lmc-eu/eslint-config-react": "2.0.1",
"@lmc-eu/prettier-config": "1.2.4",
"@nrwl/nx-cloud": "16.4.0",
"@omlet/cli": "1.0.1-beta.37",
"@playwright/test": "1.38.1",
"@rollup/plugin-babel": "6.0.4",
Expand Down Expand Up @@ -88,7 +89,7 @@
"lerna": "6.6.2",
"netlify-cli": "12.14.0",
"npm-run-all": "4.1.5",
"nx": "15.9.7",
"nx": "16.10.0",
"postcss": "8.4.31",
"prettier": "2.8.8",
"pretty-quick": "3.1.3",
Expand Down
Loading

0 comments on commit 7388fd4

Please sign in to comment.