Skip to content

Commit

Permalink
chore: migrate to yarn v3 (#6519)
Browse files Browse the repository at this point in the history
#### Details

Migrates the repo's package manager from yarn v1 to yarn v3 (in
non-zero-installs configuration)

Some of this was mechanical based on [Yarn's migration
guide](https://yarnpkg.com/getting-started/migration). Beyond the steps
there, this PR:

* Updates assorted CI pipelines/workflows and dev docs to adapt to minor
syntax updates
* Updates CI workflow's caching strategy to use
`actions/setup-node@v3`'s built-in support for yarn berry friendly
caching instead of implementing our own with `actions/cache@v3`
* Updates license-check-and-add and prettier configs to exclude `.yarn/`
* Updates e2e `Dockerfile` to account for new changes
* Drops Lerna dependency in favor of plain Yarn workspaces, similar to
service and action

##### Motivation

* Simplifies some common dev commands. In particular, the command to
update report package snapshots changes from `yarn test:report:e2e -- --
-- -u` to just `yarn test:report:e2e -u`
* Consistency with other repos
* Allows for versioned resolutions (similar to
microsoft/accessibility-insights-action#1596) -
I left modifying existing resolutions out of scope since this PR was
already pretty large without them, will cover them in a different PR
* Removes a dependency (Lerna)

##### Context

Similar PRs in other repos:

* microsoft/accessibility-insights-service#2210
* microsoft/accessibility-insights-action#1559
* microsoft/accessibility-insights-action#1596
* microsoft/axe-sarif-converter#935
* https://github.com/microsoft/accessibility-insights-docs/pull/1577

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a"
in the checkbox -->
- [n/a] Addresses an existing issue: #0000
- [x] Ran `yarn fastpass`
- [n/a] Added/updated relevant unit test(s) (and ran `yarn test`)
- [n/a] Verified code coverage for the changes made. Check coverage
report at: `<rootDir>/test-results/unit/coverage`
- [x] PR title *AND* final merge commit title both start with a semantic
tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See
`CONTRIBUTING.md`.
- [n/a] (UI changes only) Added screenshots/GIFs to description above
- [n/a] (UI changes only) Verified usability with NVDA/JAWS
  • Loading branch information
dbjorge committed Mar 22, 2023
1 parent 8f6496b commit 6222eb0
Show file tree
Hide file tree
Showing 17 changed files with 16,437 additions and 13,311 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Expand Up @@ -8,3 +8,12 @@ drop/
extension/
node_modules/
test-results/

# Yarn config for non-zero-installs
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
118 changes: 24 additions & 94 deletions .github/workflows/ci.yml
Expand Up @@ -27,26 +27,12 @@ jobs:
timeout-minutes: 2

- uses: actions/setup-node@v3
with: { node-version: "${{ env.NODE_VERSION }}" }
timeout-minutes: 2

- name: query yarn cache path
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
timeout-minutes: 1

- name: restore yarn cache
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}
node-version: "${{ env.NODE_VERSION }}"
cache: yarn
timeout-minutes: 5

- run: yarn install --frozen-lockfile --prefer-offline
- run: yarn install --immutable
timeout-minutes: 10

# CG and NOTICE generation would go here
Expand Down Expand Up @@ -75,26 +61,12 @@ jobs:
timeout-minutes: 2

- uses: actions/setup-node@v3
with: { node-version: "${{ env.NODE_VERSION }}" }
timeout-minutes: 2

- name: query yarn cache path
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
timeout-minutes: 1

- name: restore yarn cache
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}
node-version: "${{ env.NODE_VERSION }}"
cache: yarn
timeout-minutes: 5

- run: yarn install --frozen-lockfile --prefer-offline
- run: yarn install --immutable
timeout-minutes: 10

# We set maxWorkers to 2 since GH Action VMs have 2 cores and by default Jest only uses 1.
Expand Down Expand Up @@ -137,7 +109,7 @@ jobs:
path: unit-tests-2-results
timeout-minutes: 2

- run: yarn publish-code-coverage
- run: npx codecov
timeout-minutes: 3

lints:
Expand All @@ -148,26 +120,12 @@ jobs:
timeout-minutes: 2

- uses: actions/setup-node@v3
with: { node-version: "${{ env.NODE_VERSION }}" }
timeout-minutes: 2

- name: query yarn cache path
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
timeout-minutes: 1

- name: restore yarn cache
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}
node-version: "${{ env.NODE_VERSION }}"
cache: yarn
timeout-minutes: 5

- run: yarn install --frozen-lockfile --prefer-offline
- run: yarn install --immutable
timeout-minutes: 10

- run: yarn copyright:check
Expand Down Expand Up @@ -220,16 +178,16 @@ jobs:
timeout-minutes: 2

- uses: actions/setup-node@v3
with: { node-version: "${{ env.NODE_VERSION }}" }
with:
node-version: "${{ env.NODE_VERSION }}"
# Intentionally omitting caching; it would need a separate, larger
# cache bucket to account for differences in container image and
# PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD, and that would eat so far into
# our 5GB cache quota that we'd run into issues with useful main builds'
# caches being evicted anytime dependabot filed a few PRs in a row.
timeout-minutes: 2

# Intentionally omitting caching; it would need a separate, larger
# cache bucket to account for differences in container image and
# PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD, and that would eat so far into
# our 5GB cache quota that we'd run into issues with useful main builds'
# caches being evicted anytime dependabot filed a few PRs in a row.

- run: yarn install --frozen-lockfile --prefer-offline
- run: yarn install --immutable
timeout-minutes: 10

- run: yarn build:prod
Expand Down Expand Up @@ -283,26 +241,12 @@ jobs:
timeout-minutes: 2

- uses: actions/setup-node@v3
with: { node-version: "${{ env.NODE_VERSION }}" }
timeout-minutes: 2

- name: query yarn cache path
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
timeout-minutes: 1

- name: restore yarn cache
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}
node-version: "${{ env.NODE_VERSION }}"
cache: yarn
timeout-minutes: 5

- run: yarn install --frozen-lockfile --prefer-offline
- run: yarn install --immutable
timeout-minutes: 10

- run: yarn build:unified
Expand Down Expand Up @@ -337,26 +281,12 @@ jobs:
timeout-minutes: 2

- uses: actions/setup-node@v3
with: { node-version: "${{ env.NODE_VERSION }}" }
timeout-minutes: 2

- name: query yarn cache path
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
timeout-minutes: 1

- name: restore yarn cache
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('.github/workflows/ci.yml') }}
node-version: "${{ env.NODE_VERSION }}"
cache: yarn
timeout-minutes: 5

- run: yarn install --frozen-lockfile --prefer-offline
- run: yarn install --immutable
timeout-minutes: 10

- run: yarn build:package:report
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Expand Up @@ -26,3 +26,12 @@ generated-validate-assessment-json.js
node_modules/
.DS_STORE
yarn-error.log

# Yarn config for non-zero-installs
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
2 changes: 1 addition & 1 deletion .prettierignore
Expand Up @@ -25,8 +25,8 @@
.github/
.prettierignore
.swcrc
.yarnrc
.vs/
.yarn/
AppXManifest.xml
copyright-header.txt
bin/
Expand Down
28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.5.0.cjs

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion .yarnrc → .yarnrc.yml
Expand Up @@ -3,4 +3,12 @@

# This prevents inconsistent timeouts during yarn install of the large office fabric fonts package
# See https://github.com/yarnpkg/yarn/issues/5540#issuecomment-374069461
network-timeout 120000
httpTimeout: 120000

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.5.0.cjs
12 changes: 8 additions & 4 deletions Dockerfile
Expand Up @@ -27,13 +27,17 @@ RUN apt-get update && \
apt-get install -y dotnet-sdk-6.0 && \
rm -rf /var/lib/apt/lists/*

RUN npm install -g yarn@1.22.10

WORKDIR /app

COPY package.json yarn.lock /app/
COPY .yarn /app/.yarn
COPY yarn.lock .yarnrc.yml package.json /app/
COPY packages/axe-config/package.json /app/packages/axe-config/
COPY packages/report/package.json /app/packages/report/
COPY packages/report-e2e-tests/package.json /app/packages/report-e2e-tests/
COPY packages/ui/package.json /app/packages/ui/
COPY packages/validator/package.json /app/packages/validator/

RUN yarn install --frozen-lockfile
RUN yarn install --immutable

COPY . /app

Expand Down
1 change: 1 addition & 0 deletions copyright-header.config.json
Expand Up @@ -7,6 +7,7 @@
"./.swcrc",
"./.vs",
"./.vscode",
"./.yarn",
"./dist",
"./docs/art/ada-cat.ansi256.txt",
"./docs/LICENSE.txt",
Expand Down
8 changes: 4 additions & 4 deletions docs/building-web.md
Expand Up @@ -85,7 +85,7 @@ We expect almost all code to be covered by unit tests (the main exception to thi
yarn test --changedSince main

# Test only files matching a particular name pattern
yarn test -- -- SomeFile.test.tsx
yarn test -- SomeFile.test.tsx

# This runs unit tests continuously as they are updated
yarn watch:test
Expand All @@ -96,7 +96,7 @@ yarn test
# -u updates snapshots
yarn test --changedSince main -u
yarn test -u
yarn test -- -u -- SomeFile.test.tsx
yarn test -u -- SomeFile.test.tsx
```

Extra command line arguments and flags are passed along to Jest. See more about Jest options [here](https://jestjs.io/docs/en/cli.html).
Expand Down Expand Up @@ -128,9 +128,9 @@ yarn test:report:e2e

# -u updates snapshots for the report package
# Windows:
yarn test:report:e2e -- -- -- -u
yarn test:report:e2e -u
#Linux and Mac:
yarn test:report:e2e -- -- -u
yarn test:report:e2e -u

# On occasion you may need to clear the Jest cache before running tests
yarn jest --clearCache
Expand Down
6 changes: 0 additions & 6 deletions lerna.json

This file was deleted.

16 changes: 7 additions & 9 deletions package.json
Expand Up @@ -9,9 +9,9 @@
"url": "https://github.com/Microsoft/accessibility-insights-web"
},
"engines": {
"node": ">=12.16.1",
"yarn": "^1.22.4"
"node": ">=12.16.1"
},
"packageManager": "yarn@3.5.0",
"workspaces": [
"packages/*"
],
Expand All @@ -21,6 +21,7 @@
"firefox 87"
],
"scripts": {
"packages": "yarn workspaces foreach --verbose",
"ada-cat": "grunt ada-cat",
"assessment": "npm-run-all --serial scss:clean fastpass build:all test test:e2e test:unified",
"build": "grunt",
Expand All @@ -30,8 +31,8 @@
"build:unified": "grunt build-unified",
"build:unified:all": "grunt build-unified-all",
"build:unified:canary": "grunt build-unified-canary",
"build:package:report": "lerna --scope accessibility-insights-report run build",
"build:package:ui": "lerna --scope accessibility-insights-ui run build",
"build:package:report": "yarn packages --include accessibility-insights-report run build",
"build:package:ui": "yarn packages --include accessibility-insights-ui run build",
"build:prod": "grunt build-prod",
"build:package:axe-config": "grunt generate-axe-config",
"change-log": "node ./tools/get-change-log-for-release.js",
Expand All @@ -47,7 +48,7 @@
"format:check": "prettier --config prettier.config.js --check \"**/*\"",
"format:fix": "prettier --config prettier.config.js --write \"**/*\"",
"lint:check": "eslint \"**/*.{js,ts,tsx}\"",
"lint:check:all": "yarn lint:check && yarn lint:scss && lerna run lint:check",
"lint:check:all": "yarn lint:check && yarn lint:scss && yarn packages run lint:check",
"lint:fix": "eslint \"**/*.{js,ts,tsx}\" --quiet --fix",
"lint:scss": "stylelint \"**/*.scss\"",
"lint:scss:fix": "stylelint \"**/*.scss\" --fix",
Expand Down Expand Up @@ -80,7 +81,7 @@
"test:e2e:docker:run:unified": "docker run -t accessibility-insights-unified-e2e sh -c \"yarn test:unified --ci\"",
"test:e2e:docker": "npm-run-all --serial test:e2e:docker:build \"test:e2e:docker:run {@}\" --",
"test:unified": "cross-env NODE_OPTIONS='--unhandled-rejections=strict' jest --projects src/tests/electron --runInBand --forceExit --detectOpenHandles",
"test:report:e2e": "lerna --scope accessibility-insights-report-e2e-tests run test",
"test:report:e2e": "yarn packages --include accessibility-insights-report-e2e-tests run test",
"tbuild": "yarn build && yarn type:check",
"tbuild:all": "yarn build:all && yarn type:check",
"type:check": "tsc -noEmit",
Expand Down Expand Up @@ -152,7 +153,6 @@
"jest-environment-jsdom": "^29.5.0",
"jest-junit": "^15.0.0",
"js-yaml": "^4.1.0",
"lerna": "^6.5.1",
"license-check-and-add": "^4.0.5",
"mini-css-extract-plugin": "2.7.3",
"npm-run-all": "^4.1.5",
Expand Down Expand Up @@ -205,12 +205,10 @@
"resolutions": {
"@types/node": "^16.11.7",
"ansi-regex": "^5.0.1",
"**/compare-func/dot-prop": "^5.2.0",
"got": "^11.8.5",
"jpeg-js": ">=0.4.4",
"kind-of": "^6.0.3",
"license-check-and-add/yargs": "^15.3.1",
"**/dir-compare/minimatch": "^3.0.5",
"minimist": "^1.2.3",
"moment": "^2.29.4",
"nth-check": ">=2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/README.md
Expand Up @@ -8,7 +8,7 @@ Licensed under the MIT License.
As of Oct 2020, this repository is an ad-hoc monorepo; `/src` contains code for multiple projects,
and does not separate them as cleanly as we would like.

We plan to gradually convert the repository into a Lerna/Yarn Workspaces based monorepo, similar to
We plan to gradually convert the repository into a Yarn Workspaces based monorepo, similar to
how [accessibility-insights-service](https://github.com/microsoft/accessibility-insights-service) is
structured.

Expand Down
3 changes: 1 addition & 2 deletions packages/axe-config/package.json
Expand Up @@ -15,6 +15,5 @@
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/accessibility-insights-web"
},
"dependencies": {}
}
}
3 changes: 1 addition & 2 deletions packages/validator/package.json
Expand Up @@ -15,6 +15,5 @@
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/accessibility-insights-web"
},
"dependencies": {}
}
}

0 comments on commit 6222eb0

Please sign in to comment.