Nx Cloud Build #438
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nx Cloud Build | |
on: | |
workflow_dispatch: {} | |
schedule: | |
# Run periodically to freshen Nx Cloud cache. | |
- cron: 0 4,11,13,15 * * 1-5 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/latest' }} | |
env: | |
NX_BRANCH: ${{ github.ref }} | |
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_ACCESS_TOKEN }} | |
# Set to --batch to enable batch execution. | |
NX_BATCH_FLAG: '--batch' | |
jobs: | |
execute_blt: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Cache node_modules | |
if: github.event.inputs.clean_checkout != 'true' | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules/ | |
packages/*/node_modules/ | |
plugins/*/node_modules/ | |
libraries/*/node_modules/ | |
key: node_modules-${{hashFiles('yarn.lock','patches/*.patch', 'packages/*/package.json', 'plugins/*/package.json')}} | |
restore-keys: node_modules- # Take any latest cache if failed to find it for current yarn.lock | |
- name: Setup Node.js | |
id: setup_node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
- name: yarn install | |
id: yarn_install | |
run: | | |
(yarn check --integrity && yarn postinstall) || yarn install --ci | |
if [[ ! -f node_modules/canvas/build/Release/canvas.node ]] ; then | |
echo "canvas.node binary not found, cannot proceed." | |
exit 1 | |
fi | |
- name: nx build | |
id: build | |
run: | | |
# Non-batched builds - some TS/JS targets will fail if run with --batch, so build them unbatched first. | |
yarn nx run-many -p tag:no-batching -t build --parallel=3 | |
# Batched builds. | |
yarn nx run-many -t build --parallel=3 --exclude all ${NX_BATCH_FLAG} | |
- name: nx blt | |
id: blt | |
run: | | |
yarn nx run blt | |
- name: Tidy Nx Cache | |
run: | | |
sudo du -sh .nx/cache | |
./tools/tidy-nx-cache.sh | |
sudo du -sh .nx/cache |