Skip to content

.github/workflows/continuous-integration-javascript.yml #22850

.github/workflows/continuous-integration-javascript.yml

.github/workflows/continuous-integration-javascript.yml #22850

on:
merge_group:
types:
- checks_requested
pull_request:
# We do not run tests on master as the changes were already tested when opening a PR,
# and we require every PR to be up-to-date before merging it to master.
types:
- opened
- synchronize
- reopened
env:
CI: true
NODE_OPTIONS: --max-old-space-size=6144
BABEL_DISABLE_CACHE: '1'
jobs:
javascript-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# We support only Node.js versions with "LTS" and "Current" status (no "Maintenance").
# See: https://nodejs.dev/en/about/releases/
# See: https://github.com/nodejs/Release
node-version: [20.x, 21.x, 22.x]
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4.1.5
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
fetch-depth: 0
# https://github.com/dorny/paths-filter
- uses: dorny/paths-filter@v3.0.2
id: paths-filter
with:
filters: .github/filters.js.yaml
# https://github.com/actions/setup-node
- name: Use Node.js ${{ matrix.node-version }}
if: steps.paths-filter.outputs.src == 'true'
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ matrix.node-version }}
- name: Get Yarn cache directory path
if: steps.paths-filter.outputs.src == 'true'
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
# https://github.com/actions/cache
- name: Restore Yarn cache
if: steps.paths-filter.outputs.src == 'true'
uses: actions/cache@v4.0.2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }}
restore-keys: |
yarn-cache-folder-
# https://github.com/dtolnay/rust-toolchain
- uses: dtolnay/rust-toolchain@stable
if: steps.paths-filter.outputs.src == 'true'
- name: Install Yarn dependencies
if: steps.paths-filter.outputs.src == 'true'
run: ./x install -- --immutable
- name: Check Yarn constraints
if: steps.paths-filter.outputs.src == 'true'
run: yarn constraints # TODO: move to `./x install` (?)
# We are purposefully expecting zero warnings in the output to make sure flowtests are
# working as expected (Flow returns warnings for unused suppression comments).
- name: Run Flow check
if: steps.paths-filter.outputs.src == 'true'
run: ./x flow -- --max-warnings=0
# TypeScript can be used in one of two ways - as a linter, or as a build tool.
# We are using it as a linter on a monorepo level and as a build tool on individual packages.
- name: Run TypeScript check
if: steps.paths-filter.outputs.src == 'true'
run: yarn tsc --allowJs --project tsconfig.json # TODO: `./x ts`
- name: Run Eslint check
if: steps.paths-filter.outputs.src == 'true'
run: ./x lints
- name: Run Jest tests
if: steps.paths-filter.outputs.src == 'true'
run: ./x tests
- name: Run monorepo scanner
if: steps.paths-filter.outputs.src == 'true'
run: ./x scanner
# Runs the Relay Compiler for the whole monorepo and exit if there are new changes
# (meaning the generated files are not up-to-date).
- name: Run Relay check
if: steps.paths-filter.outputs.src == 'true'
run: ./x relay -- --validate
- name: Make sure there are no file changes generated by our scripts
run: git diff --exit-code
# The purpose of this job is to wait for the completion of the `javascript-test` jobs (matrix)
# and evaluate whether the run was successful or not. This is useful when configuring the
# required jobs in GitHub UI (we can require just this one job instead of all the jobs in
# the test matrix).
javascript-test-results:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [javascript-test]
steps:
- run: |
result="${{ needs.javascript-test.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi