Skip to content

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

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

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

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.
# See: https://nodejs.dev/en/about/releases/
# See: https://github.com/nodejs/Release
node-version: [18.x, 20.x, 21.x]
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4.1.1
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
fetch-depth: 0
# https://github.com/actions/setup-node
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4.0.0
with:
node-version: ${{ matrix.node-version }}
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
# https://github.com/actions/cache
- name: Restore Yarn cache
uses: actions/cache@v3.3.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
- name: Install Yarn dependencies
run: ./x install -- --immutable
# 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
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
run: yarn tsc --project . # TODO: `./x ts`
- name: Run Eslint check
run: ./x lints
- name: Run Jest tests
run: ./x tests
- name: Run monorepo scanner
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
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