chore(deps)!: migrate from yarn to npm + workspaces #16085
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instead of waiting for Yari to be published to npmjs.com and be upgraded | |
# inside mdn/content by Dependabot, we do all those steps here using `npm pack`. | |
name: NPM Publish simulation | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/checkout@v4 | |
with: | |
repository: mdn/content | |
path: mdn/content | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: npm | |
cache-dependency-path: "**/package-lock.json" | |
- name: Cache @vscode/ripgrep bin | |
uses: actions/cache@v4 | |
with: | |
key: vscode-ripgrep-bin-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }} | |
path: node_modules/@vscode/ripgrep/bin/ | |
- name: Install all npm packages | |
run: npm ci | |
env: | |
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup kernel for react native, increase watchers | |
run: | | |
# When running Yari on Linux, you might get the | |
# "Error: ENOSPC: System limit for number of file watchers reached" error. | |
# This, resolves that. | |
# Source https://github.com/expo/expo-github-action/issues/20#issuecomment-541676895 | |
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p | |
- name: Prepare to build | |
env: | |
# The following env vars is what we do in npm-publish.yml | |
# Each variable set is documented there. | |
REACT_APP_WRITER_MODE: true | |
REACT_APP_DISABLE_AUTH: true | |
CONTENT_ROOT: testing/content/files | |
run: | | |
npm run build:prepare | |
- name: Build and install tarball | |
run: | | |
echo mdn/content/ >> .npmignore | |
npm pack | |
TARBALL=`ls mdn-yari-*.tgz` | |
echo $TARBALL | |
ls -lh $TARBALL | |
mv $TARBALL mdn/content/ | |
cd mdn/content | |
npm add file:$TARBALL | |
npm install | |
- name: (mdn/content) npx yari-build | |
working-directory: mdn/content | |
run: npx yari-build --help | |
- name: (mdn/content) npx yari-filecheck | |
working-directory: mdn/content | |
run: npx yari-filecheck --help | |
- name: (mdn/content) npx yari-tool | |
working-directory: mdn/content | |
run: npx yari-tool --help | |
- name: (mdn/content) npm run start | |
working-directory: mdn/content | |
run: npm run start > /tmp/stdout.log 2> /tmp/stderr.log & | |
- name: View some URLs on localhost:5042 | |
run: | | |
curl --retry-connrefused --retry 5 -I http://localhost:5042 | |
# Basically, test if it 200 OKs. If not, this'll exit non-zero. | |
curl --fail http://localhost:5042/en-US/ > /dev/null | |
curl --fail http://localhost:5042/en-US/docs/MDN/Kitchensink > /dev/null | |
- name: Test viewing the dev server | |
env: | |
# When running Yari from within mdn/content it only starts 1 server; | |
# the one on localhost:5042. No React dev server; the one | |
# on localhost:3000. | |
# Testing that dev server is not relevant or important in this context. | |
DEVELOPING_SKIP_DEV_URL: true | |
run: | | |
npm run test:developing | |
- name: SSR build a page | |
working-directory: mdn/content | |
run: | | |
npm run build files/en-us/mdn/kitchensink/index.md | |
- name: Debug server's stdout and stderr if tests failed | |
if: failure() | |
run: | | |
echo "STDOUT..................................................." | |
cat /tmp/stdout.log | |
echo "" | |
echo "STDERR..................................................." | |
cat /tmp/stderr.log |