Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps)!: migrate from yarn to npm + workspaces #6322

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file exists exclusively for running the functional tests.
# These values are deliberately hardcoded.

# The relative path trick is necessary because `yarn build` will
# The relative path trick is necessary because `npm run build` will
# be running from the `./build/` directory.

CONTENT_ROOT=testing/content/files
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
1. Read the Community Participation Guidelines: https://www.mozilla.org/about/governance/policies/participation/
2. Ensure that there is an open issue for the problem you're solving, or create it first: https://github.com/mdn/yari/issues/new/choose
3. Fork the repository and create your branch from `main`.
4. Run `yarn` in the repository root.
4. Run `npm install` in the repository root.
5. Make sure to sign all your commits: https://docs.github.com/authentication/managing-commit-signature-verification/signing-commits
-->

Expand Down
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ macros:
- "kumascript/**/*"
dependencies:
- "**/poetry.lock"
- "**/yarn.lock"
- "**/package-lock.json"
deployer:
- "deployer/**/*"
flaw-system:
Expand Down
27 changes: 14 additions & 13 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache: npm
cache-dependency-path: "**/package-lock.json"

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Install all npm packages
run: npm ci

- name: Install Python
uses: actions/setup-python@v4
Expand Down Expand Up @@ -115,7 +116,7 @@ jobs:
# Now is not the time to worry about flaws.
BUILD_FLAW_LEVELS: "*:ignore"

# Uncomment when hacking on this workflow. It means the `yarn build`
# Uncomment when hacking on this workflow. It means the `npm run build`
# finishes much sooner, which can be helpful debugging the other stuff
# the workflow needs to do.
# BUILD_FOLDERSEARCH: web/html
Expand All @@ -131,21 +132,21 @@ jobs:
# Info about which CONTENT_* environment variables were set and to what.
echo "CONTENT_ROOT=$CONTENT_ROOT"
echo "CONTENT_TRANSLATED_ROOT=$CONTENT_TRANSLATED_ROOT"
yarn build:prepare
npm run build:prepare

# (July 15, 2021) This is a temporary solution. This should become an
# integrated part of 'build:prepare'.
# See https://github.com/mdn/yari/issues/4217
yarn tool popularities
npm run tool popularities

yarn tool sync-translated-content
npm run tool sync-translated-content

# Spread the work across 2 processes. Why 2? Because that's what you
# get in the default GitHub hosting Linux runners.
# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
yarn build --locale en-us --locale ja --locale fr &
npm run build -- --locale en-us --locale ja --locale fr &
build1=$!
yarn build --not-locale en-us --not-locale ja --not-locale fr &
npm run build -- --not-locale en-us --not-locale ja --not-locale fr &
build2=$!

# You must explicitly specify the job you're waiting-on to ensure
Expand All @@ -159,12 +160,12 @@ jobs:
du -sh client/build

# Generate sitemap index file
yarn build --sitemap-index
npm run build --sitemap-index

# Generate whatsdeployed files.
yarn tool whatsdeployed --output client/build/_whatsdeployed/code.json
yarn tool whatsdeployed $CONTENT_ROOT --output client/build/_whatsdeployed/content.json
yarn tool whatsdeployed $CONTENT_TRANSLATED_ROOT --output client/build/_whatsdeployed/translated-content.json
npm run tool whatsdeployed -- --output client/build/_whatsdeployed/code.json
npm run tool whatsdeployed $CONTENT_ROOT -- --output client/build/_whatsdeployed/content.json
npm run tool whatsdeployed $CONTENT_TRANSLATED_ROOT -- --output client/build/_whatsdeployed/translated-content.json

- name: Deploy with deployer
env:
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/developing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache: npm
cache-dependency-path: "**/package-lock.json"

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Install all npm packages
run: npm ci

- name: Setup kernel for react native, increase watchers
run: |
Expand All @@ -45,8 +46,8 @@ jobs:
# the content if loading this page fails.
ls "$CONTENT_ROOT/en-us/mdn/kitchensink"

yarn build:prepare
yarn start > /tmp/stdout.log 2> /tmp/stderr.log &
npm run build:prepare
npm run start > /tmp/stdout.log 2> /tmp/stderr.log &

- name: Wait for servers
run: |
Expand All @@ -58,7 +59,7 @@ jobs:

- name: Test viewing the dev server
run: |
yarn test:developing
npm run test:developing

- name: Debug server's stdout and stderr if tests failed
if: failure()
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache: npm
cache-dependency-path: "**/package-lock.json"

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Install all npm packages
run: npm ci

- name: Build the build
env:
Expand All @@ -41,15 +42,15 @@ jobs:
# whoami endpoint.
REACT_APP_DISABLE_AUTH: true

# The 'yarn build:prepare' command is going to try to build up a
# The 'npm run build:prepare' command is going to try to build up a
# file for the git history so it can have an index of each files.
# This makes sense in most of the cases where you have a CONTENT_ROOT
# which you'll want to build. But the CONTENT_ROOT can't be empty
# so you have to set it to something. So let's (ab)use the content
# we use for the end-to-end testing.
CONTENT_ROOT: testing/content/files
run: |
yarn build:prepare
npm run build:prepare

- name: Dry-run publish to see which files are included
run: |
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/npm-published-simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"
cache: npm
cache-dependency-path: "**/package-lock.json"

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Install all npm packages
run: npm ci

- name: Setup kernel for react native, increase watchers
run: |
Expand All @@ -46,7 +47,7 @@ jobs:
REACT_APP_DISABLE_AUTH: true
CONTENT_ROOT: testing/content/files
run: |
yarn build:prepare
npm run build:prepare

- name: Build and install tarball
run: |
Expand All @@ -57,25 +58,24 @@ jobs:
ls -lh $TARBALL
mv $TARBALL mdn/content/
cd mdn/content
yarn cache clean --all
yarn add file:$TARBALL
yarn install
npm add file:$TARBALL
npm install

- name: (mdn/content) yarn yari-build --help
- name: (mdn/content) npx yari-build
working-directory: mdn/content
run: yarn yari-build --help
run: npx yari-build --help

- name: (mdn/content) yarn yari-filecheck --help
- name: (mdn/content) npx yari-filecheck
working-directory: mdn/content
run: yarn yari-filecheck --help
run: npx yari-filecheck --help

- name: (mdn/content) yarn yari-tool
- name: (mdn/content) npx yari-tool
working-directory: mdn/content
run: yarn yari-tool --help
run: npx yari-tool --help

- name: (mdn/content) yarn start
- name: (mdn/content) npm run start
working-directory: mdn/content
run: yarn start > /tmp/stdout.log 2> /tmp/stderr.log &
run: npm run start > /tmp/stdout.log 2> /tmp/stderr.log &

- name: View some URLs on localhost:5042
run: |
Expand All @@ -93,12 +93,12 @@ jobs:
# Testing that dev server is not relevant or important in this context.
DEVELOPING_SKIP_DEV_URL: true
run: |
yarn test:developing
npm run test:developing

- name: SSR build a page
working-directory: mdn/content
run: |
yarn build files/en-us/mdn/kitchensink/index.md
npm run build files/en-us/mdn/kitchensink/index.md

- name: Debug server's stdout and stderr if tests failed
if: failure()
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- client/src/**
- .github/workflows/performance.yml
- package.json
- yarn.lock
- package-lock.json

jobs:
lighthouse:
Expand All @@ -28,10 +28,11 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache: npm
cache-dependency-path: "**/package-lock.json"

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Install all npm packages
run: npm ci

- name: Build select important pages
env:
Expand All @@ -43,15 +44,15 @@ jobs:
# Google Analytics tag which is most realistic.
BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-00000000-0
run: |
yarn build:prepare
# BUILD_FOLDERSEARCH=mdn/kitchensink yarn build
BUILD_FOLDERSEARCH=web/javascript/reference/global_objects/array/foreach yarn build
npm run build:prepare
# BUILD_FOLDERSEARCH=mdn/kitchensink npm run build
BUILD_FOLDERSEARCH=web/javascript/reference/global_objects/array/foreach npm run build

- name: Serve and lhci
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
run: |
yarn start:static-server &
npm run start:static-server &
sleep 1
curl --retry-connrefused --retry 5 \
http://localhost:5042/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach/ > /dev/null
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"
cache: npm

- name: Lint markdown files
run: |
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/pr-kumascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
paths:
- kumascript/**
- .github/workflows/pr-kumascript.yml
- yarn.lock
- package-lock.json

jobs:
test:
Expand All @@ -27,13 +27,14 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache: npm
cache-dependency-path: "**/package-lock.json"

- name: Install all yarn packages
run: yarn --frozen-lockfile
- name: Install all npm packages
run: npm ci

- name: Unit testing kumascript
env:
CONTENT_ROOT: testing/content/files
run: |
yarn test:kumascript
npm run test:kumascript
25 changes: 13 additions & 12 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache: npm
cache-dependency-path: "**/package-lock.json"

- name: Install all yarn packages
- name: Install all npm packages
if: ${{ ! vars.SKIP_BUILD }}
run: yarn --frozen-lockfile
run: npm ci

- name: Install Python
if: ${{ ! vars.SKIP_BUILD }}
Expand Down Expand Up @@ -215,20 +216,20 @@ jobs:
# Info about which CONTENT_* environment variables were set and to what.
echo "CONTENT_ROOT=$CONTENT_ROOT"
echo "CONTENT_TRANSLATED_ROOT=$CONTENT_TRANSLATED_ROOT"
yarn build:sw
yarn build:prepare
npm run build:sw
npm run build:prepare

# (July 15, 2021) This is a temporary solution. This should become an
# integrated part of 'build:prepare'.
# See https://github.com/mdn/yari/issues/4217
yarn tool popularities
npm run tool popularities

yarn tool sync-translated-content
npm run tool sync-translated-content

# Build using one process per locale.
# Note: We have 4 cores, but 9 processes is a reasonable number.
for locale in en-us es fr ja ko pt-br ru zh-cn zh-tw; do
yarn build --locale $locale 2>&1 | sed "s/^/[$locale] /" &
npm run build -- --locale $locale 2>&1 | sed "s/^/[$locale] /" &
pids+=($!)
done

Expand All @@ -239,12 +240,12 @@ jobs:
du -sh client/build

# Generate sitemap index file
yarn build --sitemap-index
npm run build --sitemap-index

# Generate whatsdeployed files.
yarn tool whatsdeployed --output client/build/_whatsdeployed/code.json
yarn tool whatsdeployed $CONTENT_ROOT --output client/build/_whatsdeployed/content.json
yarn tool whatsdeployed $CONTENT_TRANSLATED_ROOT --output client/build/_whatsdeployed/translated-content.json
npm run tool whatsdeployed -- --output client/build/_whatsdeployed/code.json
npm run tool whatsdeployed $CONTENT_ROOT -- --output client/build/_whatsdeployed/content.json
npm run tool whatsdeployed $CONTENT_TRANSLATED_ROOT -- --output client/build/_whatsdeployed/translated-content.json

- name: Deploy with deployer
if: ${{ ! (vars.SKIP_BUILD || vars.SKIP_AWS) }}
Expand Down
Loading