Skip to content

Commit

Permalink
ci: only fetch dependencies once (#10961)
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Dec 22, 2020
1 parent e5a84d9 commit e32e274
Showing 1 changed file with 49 additions and 20 deletions.
69 changes: 49 additions & 20 deletions .github/workflows/nodejs.yml
Expand Up @@ -17,24 +17,55 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"

lint-and-typecheck:
name: Running TypeScript compiler & ESLint
prepare-yarn-cache:
name: Prepare yarn cache
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2.1.2
with:
node-version: 14.x

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ubuntu-latest-node-12.x-yarn-${{ hashFiles('**/yarn.lock') }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
ubuntu-latest-node-12.x-yarn-
yarn2-
- name: Validate cache
env:
# Use PnP and disable postinstall scripts as this just needs to
# populate the cache for the other jobs
YARN_NODE_LINKER: pnp
YARN_ENABLE_SCRIPTS: false
run: yarn --immutable

lint-and-typecheck:
name: Running TypeScript compiler & ESLint
runs-on: ubuntu-latest
needs: prepare-yarn-cache

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.4
with:
node-version: 12.x
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- name: install
run: yarn --immutable
- name: build
Expand All @@ -57,6 +88,7 @@ jobs:
node-version: [10.x, 12.x, 14.x, 15.x]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}
needs: prepare-yarn-cache

steps:
- name: Set git config
Expand All @@ -66,19 +98,19 @@ jobs:
git config --global core.symlinks true
if: runner.os == 'Windows'
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.1.4
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-yarn-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.1.4
with:
node-version: ${{ matrix.node-version }}
yarn2-
- name: install
run: yarn --immutable
- name: build
Expand All @@ -88,8 +120,6 @@ jobs:
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }}
env:
CI: true

test-jasmine:
name: Node LTS on ${{ matrix.os }} using jest-jasmine2
Expand All @@ -98,6 +128,7 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}
needs: prepare-yarn-cache

steps:
- name: Set git config
Expand All @@ -107,19 +138,19 @@ jobs:
git config --global core.symlinks true
if: runner.os == 'Windows'
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v2.1.4
with:
node-version: 14.x
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-14.x-yarn-${{ hashFiles('**/yarn.lock') }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-14.x-yarn-
- name: Use Node.js 14.x
uses: actions/setup-node@v2.1.4
with:
node-version: 14.x
yarn2-
- name: install
run: yarn --immutable
- name: build
Expand All @@ -129,5 +160,3 @@ jobs:
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests using jest-jasmine
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }}
env:
CI: true

0 comments on commit e32e274

Please sign in to comment.