Skip to content

Commit 71213e3

Browse files
authored
build(devs-infra): migrate to Yarn 2 (#873)
1 parent 1893574 commit 71213e3

File tree

27 files changed

+56856
-41835
lines changed

27 files changed

+56856
-41835
lines changed

.github/workflows/node.js.yml renamed to .github/workflows/nodejs.yml

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
4-
name: Node.js CI
1+
name: Node CI
52

63
on:
74
push:
@@ -20,32 +17,63 @@ jobs:
2017
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2118
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
2219

23-
lint-and-typecheck:
24-
name: Running ESLint
20+
prepare-yarn-cache:
21+
name: Prepare yarn cache
2522
runs-on: ubuntu-latest
23+
2624
steps:
2725
- uses: actions/checkout@v2
26+
27+
- uses: actions/[email protected]
28+
with:
29+
node-version: 14.x
30+
2831
- name: Get yarn cache
2932
id: yarn-cache
3033
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
31-
- uses: actions/cache@v2
34+
35+
- uses: actions/[email protected]
3236
with:
3337
path: ${{ steps.yarn-cache.outputs.dir }}
34-
key: ubuntu-latest-node-12.x-yarn-${{ hashFiles('**/yarn.lock') }}
38+
key: yarn2-${{ hashFiles('yarn.lock') }}
3539
restore-keys: |
36-
ubuntu-latest-node-12.x-yarn-
37-
- uses: actions/[email protected]
40+
yarn2-
41+
42+
- name: Validate cache
43+
env:
44+
# Use PnP and disable postinstall scripts as this just needs to
45+
# populate the cache for the other jobs
46+
YARN_NODE_LINKER: pnp
47+
YARN_ENABLE_SCRIPTS: false
48+
run: yarn --immutable
49+
50+
lint-and-typecheck:
51+
name: Running TypeScript compiler & ESLint
52+
runs-on: ubuntu-latest
53+
needs: prepare-yarn-cache
54+
55+
steps:
56+
- uses: actions/checkout@v2
57+
- uses: actions/[email protected]
3858
with:
3959
node-version: 12.x
60+
- name: Get yarn cache
61+
id: yarn-cache
62+
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
63+
- uses: actions/[email protected]
64+
with:
65+
path: ${{ steps.yarn-cache.outputs.dir }}
66+
key: yarn2-${{ hashFiles('yarn.lock') }}
67+
restore-keys: |
68+
yarn2-
4069
- name: install
41-
run: yarn
70+
run: yarn --immutable
4271
- name: build
4372
run: yarn build
4473
- name: run eslint
4574
run: yarn lint
46-
- name: Run prettier
75+
- name: run prettier
4776
run: yarn lint:prettier-ci
48-
4977
test:
5078
name: Node v${{ matrix.node-version }} on ${{ matrix.os }}
5179
strategy:
@@ -54,6 +82,7 @@ jobs:
5482
node-version: [12.x, 14.x]
5583
os: [ubuntu-latest, windows-latest]
5684
runs-on: ${{ matrix.os }}
85+
needs: prepare-yarn-cache
5786

5887
steps:
5988
- name: Set git config
@@ -63,21 +92,21 @@ jobs:
6392
git config --global core.symlinks true
6493
if: runner.os == 'Windows'
6594
- uses: actions/checkout@v2
95+
- name: Use Node.js ${{ matrix.node-version }}
96+
uses: actions/[email protected]
97+
with:
98+
node-version: ${{ matrix.node-version }}
6699
- name: Get yarn cache
67100
id: yarn-cache
68101
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
69-
- uses: actions/cache@v2
102+
- uses: actions/cache@v2.1.4
70103
with:
71104
path: ${{ steps.yarn-cache.outputs.dir }}
72-
key: ${{ runner.os }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
105+
key: yarn2-${{ hashFiles('yarn.lock') }}
73106
restore-keys: |
74-
${{ runner.os }}-node-${{ matrix.node-version }}-yarn-
75-
- name: Use Node.js ${{ matrix.node-version }}
76-
uses: actions/[email protected]
77-
with:
78-
node-version: ${{ matrix.node-version }}
107+
yarn2-
79108
- name: install
80-
run: yarn
109+
run: yarn --immutable
81110
- name: build
82111
run: yarn build
83112
- name: run unit tests with CommomJS
@@ -86,5 +115,3 @@ jobs:
86115
run: yarn test-esm:unit
87116
- name: run e2e tests
88117
run: yarn test:e2e
89-
env:
90-
CI: true

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@ node_modules
33
*.log
44
.idea
55
*.tgz
6+
.yarn/*
7+
!.yarn/cache
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/sdks
12+
!.yarn/versions
13+
e2e/**/.yarn/*
14+
!e2e/**/.yarn/cache
15+
!e2e/**/.yarn/patches
16+
!e2e/**/.yarn/plugins
17+
!e2e/**/.yarn/releases
18+
!e2e/**/.yarn/sdks
19+
!e2e/**/.yarn/versions

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ tsconfig-esm.spec.json
4646
.npmrc
4747
.gitattributes
4848
.husky
49+
.yarn/*
50+
.yarnrc.yml

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 77 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/releases/yarn-berry.cjs

Lines changed: 55 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
enableGlobalCache: true
2+
3+
nodeLinker: node-modules
4+
5+
plugins:
6+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
7+
spec: '@yarnpkg/plugin-interactive-tools'
8+
9+
yarnPath: .yarn/releases/yarn-berry.cjs

e2e/test-app-v10/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@ src/__tests__
4141
# System Files
4242
.DS_Store
4343
Thumbs.db
44+
.yarn/*
45+
!.yarn/cache
46+
!.yarn/patches
47+
!.yarn/plugins
48+
!.yarn/releases
49+
!.yarn/sdks
50+
!.yarn/versions

e2e/test-app-v10/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 77 additions & 0 deletions
Large diffs are not rendered by default.

e2e/test-app-v10/.yarn/releases/yarn-berry.cjs

Lines changed: 55 additions & 0 deletions
Large diffs are not rendered by default.

e2e/test-app-v10/.yarnrc.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
enableGlobalCache: true
2+
3+
nodeLinker: node-modules
4+
5+
plugins:
6+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
7+
spec: '@yarnpkg/plugin-interactive-tools'
8+
9+
yarnPath: .yarn/releases/yarn-berry.cjs

0 commit comments

Comments
 (0)