From 7e6e75d3b98de855dc66d110519ecc448d26723e Mon Sep 17 00:00:00 2001
From: Nick McCurdy
Date: Sat, 14 Nov 2020 03:05:57 -0500
Subject: [PATCH 1/3] chore: switch to github actions
---
.travis.yml | 38 ---------------
README.md | 15 +++---
github/workflows/validate.yml | 88 +++++++++++++++++++++++++++++++++++
other/MAINTAINING.md | 8 ++--
4 files changed, 101 insertions(+), 48 deletions(-)
delete mode 100644 .travis.yml
create mode 100644 github/workflows/validate.yml
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 026c7f4b..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-language: node_js
-cache: npm
-notifications:
- email: false
-node_js:
- # technically we support 10.0.0, but some of our tooling doesn't
- - 10.14.2
- - 12
- - 14
- - 15
-env:
- - REACT_DIST=latest
- - REACT_DIST=next
- - REACT_DIST=experimental
-before_install:
- - nvm install-latest-npm
-install:
- - npm install
- # as requested by the React team :)
- # https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
- - npm install react@$REACT_DIST react-dom@$REACT_DIST
-script:
- - npm run validate
- - npx codecov@3
-branches:
- only:
- - master
- - beta
-
-jobs:
- allow_failures:
- - REACT_DIST=next
- - REACT_DIST=experimental
- include:
- - stage: release
- node_js: 14
- script: kcd-scripts travis-release
- if: fork = false
diff --git a/README.md b/README.md
index c7033e52..73e421bb 100644
--- a/README.md
+++ b/README.md
@@ -26,11 +26,12 @@ practices.
[![Build Status][build-badge]][build]
[![Code Coverage][coverage-badge]][coverage]
-[![version][version-badge]][package] [![downloads][downloads-badge]][npmtrends]
+[![version][version-badge]][package]
+[![downloads][downloads-badge]][npmtrends]
[![MIT License][license-badge]][license]
-
-[](#contributors)
-[![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc]
+[![All Contributors][all-contributors-badge]](#contributors)
+[![PRs Welcome][prs-badge]][prs]
+[![Code of Conduct][coc-badge]][coc]
[![Discord][discord-badge]][discord]
[![Watch on GitHub][github-watch-badge]][github-watch]
@@ -608,6 +609,7 @@ Thanks goes to these people ([emoji key][emojis]):
+
This project follows the [all-contributors][all-contributors] specification.
@@ -622,8 +624,8 @@ Contributions of any kind welcome!
[npm]: https://www.npmjs.com/
[yarn]: https://classic.yarnpkg.com
[node]: https://nodejs.org
-[build-badge]: https://img.shields.io/travis/testing-library/react-testing-library.svg?style=flat-square
-[build]: https://travis-ci.org/testing-library/react-testing-library
+[build-badge]: https://img.shields.io/github/workflow/status/testing-library/react-testing-library/validate?logo=github&style=flat-square
+[build]: https://github.com/testing-library/react-testing-library/actions?query=workflow%3Avalidate
[coverage-badge]: https://img.shields.io/codecov/c/github/testing-library/react-testing-library.svg?style=flat-square
[coverage]: https://codecov.io/github/testing-library/react-testing-library
[version-badge]: https://img.shields.io/npm/v/@testing-library/react.svg?style=flat-square
@@ -644,6 +646,7 @@ Contributions of any kind welcome!
[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/testing-library/react-testing-library.svg?style=social
[emojis]: https://github.com/all-contributors/all-contributors#emoji-key
[all-contributors]: https://github.com/all-contributors/all-contributors
+[all-contributors-badge]: https://img.shields.io/github/all-contributors/testing-library/react-testing-library?color=orange&style=flat-square
[guiding-principle]: https://twitter.com/kentcdodds/status/977018512689455106
[bugs]: https://github.com/testing-library/react-testing-library/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Acreated-desc
[requests]: https://github.com/testing-library/react-testing-library/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+label%3Aenhancement+is%3Aopen
diff --git a/github/workflows/validate.yml b/github/workflows/validate.yml
new file mode 100644
index 00000000..dcb53ad2
--- /dev/null
+++ b/github/workflows/validate.yml
@@ -0,0 +1,88 @@
+name: validate
+on:
+ push:
+ branches:
+ [
+ '+([0-9])?(.{+([0-9]),x}).x',
+ 'master',
+ 'next',
+ 'next-major',
+ 'beta',
+ 'alpha',
+ '!all-contributors/**',
+ ]
+ pull_request:
+ branches-ignore: ['all-contributors/**']
+jobs:
+ main:
+ continue-on-error: ${{ matrix.react != 'latest' }}
+ strategy:
+ matrix:
+ node: [10.13, 12, 14, 15]
+ react: [latest, next, experimental]
+ runs-on: ubuntu-latest
+ steps:
+ - name: ⬇️ Checkout repo
+ uses: actions/checkout@v2
+
+ - name: ⎔ Setup node
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node }}
+
+ - name: 📥 Download deps
+ uses: bahmutov/npm-install@v1
+ with:
+ useLockFile: false
+
+ # as requested by the React team :)
+ # https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
+ - name: ⚛️ Setup react
+ run: npm install react@${{matrix.react}} react-dom@${{matrix.react}}
+
+ - name: ▶️ Run validate script
+ run: npm run validate
+
+ - name: ⬆️ Upload coverage report
+ uses: codecov/codecov-action@v1
+
+ release:
+ needs: main
+ runs-on: ubuntu-latest
+ if:
+ ${{ github.repository == 'testing-library/react-testing-library' &&
+ contains('refs/heads/master,refs/heads/beta,refs/heads/next,refs/heads/alpha',
+ github.ref) && github.event_name == 'push' }}
+ steps:
+ - name: ⬇️ Checkout repo
+ uses: actions/checkout@v2
+
+ - name: ⎔ Setup node
+ uses: actions/setup-node@v1
+ with:
+ node-version: 14
+
+ - name: 📥 Download deps
+ uses: bahmutov/npm-install@v1
+ with:
+ useLockFile: false
+
+ - name: 🏗 Run build script
+ run: npm run build
+
+ - name: 🚀 Release
+ uses: cycjimmy/semantic-release-action@v2
+ with:
+ semantic_version: 17
+ branches: |
+ [
+ '+([0-9])?(.{+([0-9]),x}).x',
+ 'master',
+ 'next',
+ 'next-major',
+ {name: 'beta', prerelease: true},
+ {name: 'alpha', prerelease: true}
+ ]
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/other/MAINTAINING.md b/other/MAINTAINING.md
index 703126da..cade1c2a 100644
--- a/other/MAINTAINING.md
+++ b/other/MAINTAINING.md
@@ -32,9 +32,9 @@ any more of you than that.
As a maintainer, you're fine to make your branches on the main repo or on your
own fork. Either way is fine.
-When we receive a pull request, a travis build is kicked off automatically (see
-the `.travis.yml` for what runs in the travis build). We avoid merging anything
-that breaks the travis build.
+When we receive a pull request, a github action is kicked off automatically (see
+the `.github/workflows/validate.yml` for what runs in the action). We avoid
+merging anything that breaks the validate action.
Please review PRs and focus on the code rather than the individual. You never
know when this is someone's first ever PR and we want their experience to be as
@@ -49,7 +49,7 @@ to release. See the next section on Releases for more about that.
## Release
Our releases are automatic. They happen whenever code lands into `master`. A
-travis build gets kicked off and if it's successful, a tool called
+github action gets kicked off and if it's successful, a tool called
[`semantic-release`](https://github.com/semantic-release/semantic-release) is
used to automatically publish a new release to npm as well as a changelog to
GitHub. It is only able to determine the version and whether a release is
From f00a025165d66b2bc208311b51e30095af2252d8 Mon Sep 17 00:00:00 2001
From: Nick McCurdy
Date: Sat, 14 Nov 2020 04:12:15 -0500
Subject: [PATCH 2/3] chore: merge github into .github
---
{github => .github}/workflows/validate.yml | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {github => .github}/workflows/validate.yml (100%)
diff --git a/github/workflows/validate.yml b/.github/workflows/validate.yml
similarity index 100%
rename from github/workflows/validate.yml
rename to .github/workflows/validate.yml
From ffe456adff1fa2449954f8e885ebc0c5b9be7ead Mon Sep 17 00:00:00 2001
From: "Kent C. Dodds"
Date: Sat, 14 Nov 2020 09:14:29 -0700
Subject: [PATCH 3/3] upgrade to the latest of everything and fix a few linting
issues
---
package.json | 15 ++++++++-------
types/test.tsx | 26 ++++++++++++++++++--------
2 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/package.json b/package.json
index 96c7df0f..086e82bc 100644
--- a/package.json
+++ b/package.json
@@ -43,18 +43,19 @@
"author": "Kent C. Dodds (https://kentcdodds.com)",
"license": "MIT",
"dependencies": {
- "@babel/runtime": "^7.12.1",
+ "@babel/runtime": "^7.12.5",
"@testing-library/dom": "^7.26.6"
},
"devDependencies": {
- "@testing-library/jest-dom": "^5.11.5",
- "@types/react-dom": "^16.9.8",
+ "@testing-library/jest-dom": "^5.11.6",
+ "@types/estree": "0.0.45",
+ "@types/react-dom": "^16.9.9",
"dotenv-cli": "^4.0.0",
- "dtslint": "4.0.4",
- "kcd-scripts": "^6.6.0",
+ "dtslint": "4.0.5",
+ "kcd-scripts": "^7.0.3",
"npm-run-all": "^4.1.5",
- "react": "^16.13.1",
- "react-dom": "^16.13.1",
+ "react": "^17.0.1",
+ "react-dom": "^17.0.1",
"rimraf": "^3.0.2",
"typescript": "^4.0.5"
},
diff --git a/types/test.tsx b/types/test.tsx
index c273feb0..3971037d 100644
--- a/types/test.tsx
+++ b/types/test.tsx
@@ -2,7 +2,7 @@ import * as React from 'react'
import {render, fireEvent, screen, waitFor} from '@testing-library/react'
import * as pure from '@testing-library/react/pure'
-async function testRender() {
+export async function testRender() {
const page = render()
// single queries
@@ -17,9 +17,10 @@ async function testRender() {
// helpers
const {container, rerender, debug} = page
+ return {container, rerender, debug}
}
-async function testPureRender() {
+export async function testPureRender() {
const page = pure.render()
// single queries
@@ -34,20 +35,21 @@ async function testPureRender() {
// helpers
const {container, rerender, debug} = page
+ return {container, rerender, debug}
}
-async function testRenderOptions() {
+export function testRenderOptions() {
const container = document.createElement('div')
const options = {container}
render(, options)
}
-async function testFireEvent() {
+export function testFireEvent() {
const {container} = render()
fireEvent.click(container)
}
-async function testDebug() {
+export function testDebug() {
const {debug, getAllByTestId} = render(
<>
Hello World
@@ -57,14 +59,22 @@ async function testDebug() {
debug(getAllByTestId('testid'))
}
-async function testScreen() {
+export async function testScreen() {
render()
- screen.findByRole('button')
+ await screen.findByRole('button')
}
-async function testWaitFor() {
+export async function testWaitFor() {
const {container} = render()
fireEvent.click(container)
await waitFor(() => {})
}
+
+/*
+eslint
+ testing-library/prefer-explicit-assert: "off",
+ testing-library/no-wait-for-empty-callback: "off",
+ testing-library/no-debug: "off",
+ testing-library/prefer-screen-queries: "off"
+*/