From 4a1b31e3efaba541b427f1ba523d169aa5eb38c9 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Mon, 14 Dec 2020 12:10:15 -0800 Subject: [PATCH] Use GitHub workflows for CI Close #1845 Fix #1841 --- .../{compressed-size.yml => performance.yml} | 6 ++- .github/workflows/test.yml | 53 +++++++++++++++++++ .travis.yml | 17 ------ README.md | 4 +- package.json | 7 +-- .../src/exports/Modal/__tests__/index.js | 8 ++- .../src/modules/useMergeRefs/index.js | 1 - 7 files changed, 69 insertions(+), 27 deletions(-) rename .github/workflows/{compressed-size.yml => performance.yml} (90%) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/compressed-size.yml b/.github/workflows/performance.yml similarity index 90% rename from .github/workflows/compressed-size.yml rename to .github/workflows/performance.yml index a996efcc..2f8b4bcd 100644 --- a/.github/workflows/compressed-size.yml +++ b/.github/workflows/performance.yml @@ -1,7 +1,9 @@ -name: compressed-size +name: performance + on: [pull_request] + jobs: - build: + compressed-size: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..d968441f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +name: test + +on: + push: + branches: + - "master" + pull_request: + types: [opened, synchronize, reopened] + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - run: npm install -g yarn + - run: yarn install + - run: yarn fmt:report + + type-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - run: npm install -g yarn + - run: yarn install + - run: yarn flow + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - run: npm install -g yarn + - run: yarn install + - run: yarn lint:report + + unit-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - run: npm install -g yarn + - run: yarn install + - run: yarn jest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6d02779b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: node_js - -node_js: - - "10" - -before_install: - # Install Yarn - - curl -o- -L https://yarnpkg.com/install.sh | bash - - export PATH=$HOME/.yarn/bin:$PATH - -cache: - yarn: true - directories: - - node_modules - -script: - - yarn test diff --git a/README.md b/README.md index f137c329..d7225e6d 100644 --- a/README.md +++ b/README.md @@ -208,8 +208,8 @@ MIT license. [package-badge]: https://img.shields.io/npm/v/react-native-web.svg?style=flat [package-url]: https://yarnpkg.com/en/package/react-native-web -[ci-badge]: https://travis-ci.org/necolas/react-native-web.svg?branch=master -[ci-url]: https://travis-ci.org/necolas/react-native-web +[ci-badge]: https://github.com/necolas/react-native-web/workflows/test/badge.svg +[ci-url]: https://github.com/necolas/react-native-web/actions [react-native-url]: https://facebook.github.io/react-native/ [contributing-url]: https://github.com/necolas/react-native-web/blob/master/.github/CONTRIBUTING.md [good-first-issue-url]: https://github.com/necolas/react-native-web/labels/good%20first%20issue diff --git a/package.json b/package.json index 8fb5925a..64b76e6c 100644 --- a/package.json +++ b/package.json @@ -13,14 +13,15 @@ "docs:release": "cd packages/docs && yarn release", "flow": "flow", "fmt": "prettier --write \"**/*.js\"", + "fmt:report": "prettier --check \"**/*.js\"", "jest": "jest --config ./scripts/jest/config.js", - "lint": "yarn lint:check --fix", - "lint:check": "eslint packages scripts", + "lint": "yarn lint:report --fix", + "lint:report": "eslint packages scripts", "precommit": "lint-staged", "prerelease": "yarn test && yarn compile && yarn compile:commonjs", "release": "node ./scripts/release/publish.js", "postrelease": "yarn benchmarks:release && yarn docs:release", - "test": "yarn flow && yarn lint:check && yarn jest --runInBand" + "test": "yarn flow && yarn lint:report && yarn jest --runInBand" }, "devDependencies": { "@babel/cli": "^7.8.4", diff --git a/packages/react-native-web/src/exports/Modal/__tests__/index.js b/packages/react-native-web/src/exports/Modal/__tests__/index.js index 1078a542..605bd23d 100644 --- a/packages/react-native-web/src/exports/Modal/__tests__/index.js +++ b/packages/react-native-web/src/exports/Modal/__tests__/index.js @@ -418,10 +418,14 @@ describe('components/Modal', () => { function TestComponent() { React.useEffect(() => spy('mount'), []); - return ref ? spy('ref') : spy('noref')} />; + return ( + + (ref ? spy('ref') : spy('noref'))} /> + + ); } - render() + render(); expect(spy).toHaveBeenNthCalledWith(1, 'ref'); expect(spy).toHaveBeenNthCalledWith(2, 'mount'); diff --git a/packages/react-native-web/src/modules/useMergeRefs/index.js b/packages/react-native-web/src/modules/useMergeRefs/index.js index 01837c2b..7bb9fd6c 100644 --- a/packages/react-native-web/src/modules/useMergeRefs/index.js +++ b/packages/react-native-web/src/modules/useMergeRefs/index.js @@ -11,7 +11,6 @@ import * as React from 'react'; import mergeRefs from '../mergeRefs'; export default function useMergeRefs(...args: $ReadOnlyArray>) { - // TODO(memoize) #1755 return React.useMemo( () => mergeRefs(...args), // eslint-disable-next-line