Add turbo caching to GH actions workflows

This commit is contained in:
bjoluc 2022-01-06 18:14:48 +01:00
parent 6f2613cc5c
commit 0362e65bd4
3 changed files with 33 additions and 13 deletions

View File

@ -2,9 +2,6 @@ name: build
on: [push, pull_request] on: [push, pull_request]
env:
HUSKY: 0
jobs: jobs:
test: test:
name: Build, lint, and test on Node.js ${{ matrix.node }} name: Build, lint, and test on Node.js ${{ matrix.node }}
@ -12,22 +9,35 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node: [14.x, 16.x] node: [14, 16]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node }} - name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v1 uses: actions/setup-node@v2
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: npm
- name: Install npm@v7 - name: Install npm@v7
run: npm install -g npm@7 run: npm install -g npm@7
- name: Install dependencies and build packages - name: Install dependencies
run: npm ci run: npm ci
# Running this after `npm ci` because `npm ci` removes `node_modules`:
- name: Download Turborepo cache
uses: actions/cache@v2
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-node-${{ matrix.node }}-turbo-${{ hashFiles('node_modules/.cache/turbo') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-turbo-
- name: Build packages
run: npm run build
# TODO setup linting # TODO setup linting
# - name: Lint # - name: Lint
# run: npm run lint # run: npm run lint

View File

@ -1,8 +1,5 @@
name: release name: release
env:
HUSKY: 0
on: on:
push: push:
paths: paths:
@ -21,14 +18,26 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup Node.js 16.x - name: Setup Node.js 16
uses: actions/setup-node@v2 uses: actions/setup-node@v2
with: with:
node-version: 16.x node-version: 16
cache: npm
- name: Install dependencies and build packages - name: Install dependencies
run: npm install run: npm install
- name: Download Turborepo cache
uses: actions/cache@v2
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-node-16-turbo-${{ hashFiles('node_modules/.cache/turbo') }}
restore-keys: |
${{ runner.os }}-node-16-turbo-
- name: Build packages
run: npm run build
- name: Run tests - name: Run tests
run: npm run test -- --ci --maxWorkers=2 run: npm run test -- --ci --maxWorkers=2
env: env:

View File

@ -9,7 +9,7 @@
"test:watch": "npm test -- --watch", "test:watch": "npm test -- --watch",
"build": "turbo run build", "build": "turbo run build",
"build:archive": "gulp createCoreDistArchive", "build:archive": "gulp createCoreDistArchive",
"prepare": "husky install && npm run build", "prepare": "node -e 'process.exit(!process.env.CI)' || (husky install && npm run build)",
"tsc": "turbo tsc", "tsc": "turbo tsc",
"changeset": "changeset", "changeset": "changeset",
"release": "changeset publish" "release": "changeset publish"
@ -47,6 +47,7 @@
}, },
"turbo": { "turbo": {
"baseBranch": "origin/main", "baseBranch": "origin/main",
"npmClient": "npm",
"pipeline": { "pipeline": {
"build": { "build": {
"dependsOn": [ "dependsOn": [