Skip to content

Commit

Permalink
Add per-platform CI jobs to enable Windows tests, multiple Node.js ve…
Browse files Browse the repository at this point in the history
…rsions

Summary:
Enables Windows test runs in CircleCI. Partially resolves this discussion: facebook#876 (comment).

- Adds `test-windows` job via the `circleci/windows` orb (inspired by the main react-native repo CircleCI config: https://fburl.com/hxyx4han).
    - `test-linux` job continues to use fast `cimg/node` images.
- Parametarises `node-version` on the `test-linux` and `test-windows` jobs, and assigns as a matrix of versions (remains a single run against `14.17.0` for now).
- Drops the `yarn_run` command in favour of YAML anchor to explicitly mix in `&secure_unset_publish_token` behaviour using CircleCI's `environment` option, which is cross platform (see test plan).

NOTE: Since Windows tests are failing en masse, the branch filter `only: /windows\/.*/` is added, effectively disabling this job except on `windows/`-prefixed branches (which will provide a hook for fixing these in future).

```
Test Suites: 18 failed, 92 passed, 110 total
Tests:       232 failed, 1 skipped, 1286 passed, 1519 total
Snapshots:   20 failed, 403 passed, 423 total
Time:        87.927 s
Ran all test suites.
```

Changelog: [Internal]

Differential Revision: D40805193

fbshipit-source-id: a86689f6fc864483c12677e573df5c287aa63181
  • Loading branch information
huntie authored and facebook-github-bot committed Oct 31, 2022
1 parent 04db377 commit 18752d0
Showing 1 changed file with 55 additions and 26 deletions.
81 changes: 55 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CircleCI configuration
# https://circleci.com/docs/configuration-reference/

version: 2.1

orbs:
win: circleci/windows@2.4.0

secure_unset_publish_token: &secure_unset_publish_token
environment:
NPM_TOKEN: ''

commands:
yarn_install:
description: "A wrapper to yarn install with caching"
Expand All @@ -11,52 +21,62 @@ commands:
- restore_cache:
keys:
- dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
# Fallback in case checksum fails
- dependencies-{{ .Branch }}-
- run:
name: Installing dependencies
command: NPM_TOKEN= yarn --frozen-lockfile --non-interactive
command: yarn --frozen-lockfile --non-interactive
working_directory: << parameters.working_directory >>
- save_cache:
paths:
- node_modules
key: dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}

yarn_run:
description: "A wrapper to execute yarn commands in a safe way"
parameters:
working_directory:
type: string
default: ""
command:
type: string
install_and_run_tests:
description: |
Install dependencies and run tests (common steps for test-<platform> jobs)
steps:
- run:
command: NPM_TOKEN= yarn run << parameters.command >>
working_directory: << parameters.working_directory >>
- yarn_install
- run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit
- store_test_results:
path: ./reports/

jobs:
run-js-checks:
<<: *secure_unset_publish_token
docker:
- image: cimg/node:14.17
steps:
- checkout
- yarn_install
- yarn_run:
command: test-ci
- yarn_run:
command: test-smoke
- run: yarn test-ci
- run: yarn test-smoke

test-node-14:
test-linux:
<<: *secure_unset_publish_token
parameters:
node-version:
type: string
docker:
- image: cimg/node:14.17
- image: cimg/node:<< parameters.node-version >>
steps:
- checkout
- yarn_install
- yarn_run:
command: jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit
- store_test_results:
path: ./reports/
- install_and_run_tests

test-windows:
<<: *secure_unset_publish_token
parameters:
node-version:
type: string
executor:
name: win/default
steps:
- checkout
- run:
name: Install Node.js and Yarn
command: |
choco install -y nodejs --version << parameters.node-version >>
choco install -y yarn
- install_and_run_tests

publish-to-npm:
docker:
Expand All @@ -68,12 +88,21 @@ jobs:
- run: npm run publish
- run: rm ~/.npmrc

# Workflows enables us to run multiple jobs in parallel
workflows:
build-and-deploy:
jobs:
- run-js-checks
- test-node-14
- test-linux:
matrix:
parameters:
node-version: ["14.17.0"]
- test-windows:
matrix:
parameters:
node-version: ["14.17.0"]
filters:
branches:
only: /windows\/.*/
- publish-to-npm:
filters:
branches:
Expand Down

0 comments on commit 18752d0

Please sign in to comment.