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

Migrate to NPM #6393

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
1. Read the Community Participation Guidelines: https://www.mozilla.org/en-US/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.
5. Ensure the code is formatted: `yarn prettier --write .`
4. Run `npm i` in the repository root.
5. Ensure the code is formatted: `npm run prettier --write .`
-->

## Summary
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
24 changes: 13 additions & 11 deletions .github/workflows/aws-lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,47 +35,49 @@ jobs:
#
# The reason `yarn install` won't pick up the sub-dependencies
# is because these 3 directories don't share a common root.
#
# XXX Is this still needed with NPM?

- name: Cache node_modules content-origin-request
uses: actions/cache@v3
id: cached-node_modules-content-origin-request
with:
path: |
deployer/aws-lambda/content-origin-request/node_modules
key: ${{ runner.os }}-${{ hashFiles('deployer/aws-lambda/**/yarn.lock') }}-${{ hashFiles('libs/**/*.js') }}
- name: Install all yarn packages
key: ${{ runner.os }}-${{ hashFiles('deployer/aws-lambda/**/package-lock.json') }}-${{ hashFiles('libs/**/*.js') }}
- name: Install all NodeJS packages
if: steps.cached-node_modules-content-origin-request.outputs.cache-hit != 'true'
working-directory: deployer/aws-lambda/content-origin-request
run: yarn --frozen-lockfile
run: npm ci

- name: Cache node_modules content-origin-response
uses: actions/cache@v3
id: cached-node_modules-content-origin-response
with:
path: |
deployer/aws-lambda/content-origin-response/node_modules
key: ${{ runner.os }}-${{ hashFiles('deployer/aws-lambda/**/yarn.lock') }}-${{ hashFiles('libs/**/*.js') }}
- name: Install all yarn packages
key: ${{ runner.os }}-${{ hashFiles('deployer/aws-lambda/**/package-lock.json') }}-${{ hashFiles('libs/**/*.js') }}
- name: Install all NodeJS packages
if: steps.cached-node_modules-content-origin-response.outputs.cache-hit != 'true'
working-directory: deployer/aws-lambda/content-origin-response
run: yarn --frozen-lockfile
run: npm ci

- name: Cache node_modules
uses: actions/cache@v3
id: cached-node_modules
with:
path: |
deployer/aws-lambda/tests/node_modules
key: ${{ runner.os }}-${{ hashFiles('deployer/aws-lambda/**/yarn.lock') }}-${{ hashFiles('libs/**/*.js') }}
- name: Install all yarn packages
key: ${{ runner.os }}-${{ hashFiles('deployer/aws-lambda/**/package-lock.json') }}-${{ hashFiles('libs/**/*.js') }}
- name: Install all NodeJS packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
working-directory: deployer/aws-lambda/tests
run: yarn --frozen-lockfile
run: npm ci

- name: Run test server
working-directory: deployer/aws-lambda/tests
run: |
yarn serve > /tmp/stdout.log 2> /tmp/stderr.log &
npm run serve > /tmp/stdout.log 2> /tmp/stderr.log &

- name: Check that the server started
run: curl --retry-connrefused --retry 5 -I http://localhost:7000/ping
Expand All @@ -88,7 +90,7 @@ jobs:
- name: End-to-end test
working-directory: deployer/aws-lambda/tests
run: |
yarn test-server
npm run test-server

- name: Debug any server outputs
if: failure()
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ jobs:
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install all yarn packages
- name: Install all NodeJS packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: npm ci

- name: Install Python
uses: actions/[email protected]
Expand Down Expand Up @@ -120,7 +120,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 @@ -136,21 +136,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 Down
13 changes: 6 additions & 7 deletions .github/workflows/developing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"

- name: Cache node_modules
uses: actions/cache@v3
id: cached-node_modules
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.github/workflows/developing.yml') }}
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/developing.yml') }}

- name: Install all yarn packages
- name: Install all NodeJS packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: npm ci

- name: Setup kernel for react native, increase watchers
run: |
Expand All @@ -54,8 +53,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 @@ -67,7 +66,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
14 changes: 6 additions & 8 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.github/workflows/npm-publish.yml') }}
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/npm-publish.yml') }}

- name: Install all yarn packages
- name: Install all NodeJS packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: npm ci

- name: Build the build
env:
Expand All @@ -48,19 +48,17 @@ 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
run: npm run build:prepare

- name: Dry-run publish to see which files are included
run: |
npm publish --access public --dry-run
run: npm publish --access public --dry-run

- name: Publish to npmjs
uses: mikeal/merge-release@master
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/npm-published-simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"

- name: Cache node_modules
uses: actions/cache@v3
id: cached-node_modules
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.github/workflows/npm-published-simulation.yml') }}
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/npm-published-simulation.yml') }}

- name: Install all yarn packages
- name: Install all NodeJS packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
run: npm ci

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

- name: Build and install tarball
run: |
Expand All @@ -66,12 +64,11 @@ jobs:
ls -lh $TARBALL
mv $TARBALL mdn/content/
cd mdn/content
yarn add file:$TARBALL
npm run add file:$TARBALL

- name: Start Yari from mock content repo
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 @@ -88,13 +85,11 @@ jobs:
# on localhost:3000.
# Testing that dev server is not relevant or important in this context.
DEVELOPING_SKIP_DEV_URL: true
run: |
yarn test:developing
run: npm run test:developing

- name: SSR build a page
working-directory: mdn/content
run: |
yarn build files/en-us/mdn/kitchensink/index.md
run: 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: 8 additions & 9 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 Down Expand Up @@ -35,12 +35,11 @@ jobs:
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.github/workflows/performance.yml') }}
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/performance.yml') }}

- name: Install all yarn packages
- name: Install all NodeJS packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: |
yarn --frozen-lockfile
run: npm ci

- name: Build select important pages
env:
Expand All @@ -52,15 +51,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
1 change: 0 additions & 1 deletion .github/workflows/pr-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"

- name: Lint markdown files
run: |
Expand Down
12 changes: 5 additions & 7 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 @@ -34,15 +34,13 @@ jobs:
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.github/workflows/pr-kumascript.yml') }}
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.github/workflows/pr-kumascript.yml') }}

- name: Install all yarn packages
- name: Install all NodeJS packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: |
yarn --frozen-lockfile
run: npm ci

- name: Unit testing kumascript
env:
CONTENT_ROOT: testing/content/files
run: |
yarn test:kumascript
run: npm run test:kumascript
Loading