Skip to content

Commit 3af1b4b

Browse files
nickservkentcdodds
andauthored
chore: switch to github actions (#826)
Co-authored-by: Kent C. Dodds <[email protected]>
1 parent 007b0b7 commit 3af1b4b

File tree

6 files changed

+127
-63
lines changed

6 files changed

+127
-63
lines changed

.github/workflows/validate.yml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: validate
2+
on:
3+
push:
4+
branches:
5+
[
6+
'+([0-9])?(.{+([0-9]),x}).x',
7+
'master',
8+
'next',
9+
'next-major',
10+
'beta',
11+
'alpha',
12+
'!all-contributors/**',
13+
]
14+
pull_request:
15+
branches-ignore: ['all-contributors/**']
16+
jobs:
17+
main:
18+
continue-on-error: ${{ matrix.react != 'latest' }}
19+
strategy:
20+
matrix:
21+
node: [10.13, 12, 14, 15]
22+
react: [latest, next, experimental]
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: ⬇️ Checkout repo
26+
uses: actions/checkout@v2
27+
28+
- name: ⎔ Setup node
29+
uses: actions/setup-node@v1
30+
with:
31+
node-version: ${{ matrix.node }}
32+
33+
- name: 📥 Download deps
34+
uses: bahmutov/npm-install@v1
35+
with:
36+
useLockFile: false
37+
38+
# as requested by the React team :)
39+
# https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
40+
- name: ⚛️ Setup react
41+
run: npm install react@${{matrix.react}} react-dom@${{matrix.react}}
42+
43+
- name: ▶️ Run validate script
44+
run: npm run validate
45+
46+
- name: ⬆️ Upload coverage report
47+
uses: codecov/codecov-action@v1
48+
49+
release:
50+
needs: main
51+
runs-on: ubuntu-latest
52+
if:
53+
${{ github.repository == 'testing-library/react-testing-library' &&
54+
contains('refs/heads/master,refs/heads/beta,refs/heads/next,refs/heads/alpha',
55+
github.ref) && github.event_name == 'push' }}
56+
steps:
57+
- name: ⬇️ Checkout repo
58+
uses: actions/checkout@v2
59+
60+
- name: ⎔ Setup node
61+
uses: actions/setup-node@v1
62+
with:
63+
node-version: 14
64+
65+
- name: 📥 Download deps
66+
uses: bahmutov/npm-install@v1
67+
with:
68+
useLockFile: false
69+
70+
- name: 🏗 Run build script
71+
run: npm run build
72+
73+
- name: 🚀 Release
74+
uses: cycjimmy/semantic-release-action@v2
75+
with:
76+
semantic_version: 17
77+
branches: |
78+
[
79+
'+([0-9])?(.{+([0-9]),x}).x',
80+
'master',
81+
'next',
82+
'next-major',
83+
{name: 'beta', prerelease: true},
84+
{name: 'alpha', prerelease: true}
85+
]
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.travis.yml

-38
This file was deleted.

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ practices.</p>
2626
<!-- prettier-ignore-start -->
2727
[![Build Status][build-badge]][build]
2828
[![Code Coverage][coverage-badge]][coverage]
29-
[![version][version-badge]][package] [![downloads][downloads-badge]][npmtrends]
29+
[![version][version-badge]][package]
30+
[![downloads][downloads-badge]][npmtrends]
3031
[![MIT License][license-badge]][license]
31-
32-
[![All Contributors](https://img.shields.io/badge/all_contributors-102-orange.svg?style=flat-square)](#contributors)
33-
[![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc]
32+
[![All Contributors][all-contributors-badge]](#contributors)
33+
[![PRs Welcome][prs-badge]][prs]
34+
[![Code of Conduct][coc-badge]][coc]
3435
[![Discord][discord-badge]][discord]
3536

3637
[![Watch on GitHub][github-watch-badge]][github-watch]
@@ -608,6 +609,7 @@ Thanks goes to these people ([emoji key][emojis]):
608609
609610
<!-- markdownlint-enable -->
610611
<!-- prettier-ignore-end -->
612+
611613
<!-- ALL-CONTRIBUTORS-LIST:END -->
612614
613615
This project follows the [all-contributors][all-contributors] specification.
@@ -622,8 +624,8 @@ Contributions of any kind welcome!
622624
[npm]: https://www.npmjs.com/
623625
[yarn]: https://classic.yarnpkg.com
624626
[node]: https://nodejs.org
625-
[build-badge]: https://img.shields.io/travis/testing-library/react-testing-library.svg?style=flat-square
626-
[build]: https://travis-ci.org/testing-library/react-testing-library
627+
[build-badge]: https://img.shields.io/github/workflow/status/testing-library/react-testing-library/validate?logo=github&style=flat-square
628+
[build]: https://github.com/testing-library/react-testing-library/actions?query=workflow%3Avalidate
627629
[coverage-badge]: https://img.shields.io/codecov/c/github/testing-library/react-testing-library.svg?style=flat-square
628630
[coverage]: https://codecov.io/github/testing-library/react-testing-library
629631
[version-badge]: https://img.shields.io/npm/v/@testing-library/react.svg?style=flat-square
@@ -644,6 +646,7 @@ Contributions of any kind welcome!
644646
[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/testing-library/react-testing-library.svg?style=social
645647
[emojis]: https://github.com/all-contributors/all-contributors#emoji-key
646648
[all-contributors]: https://github.com/all-contributors/all-contributors
649+
[all-contributors-badge]: https://img.shields.io/github/all-contributors/testing-library/react-testing-library?color=orange&style=flat-square
647650
[guiding-principle]: https://twitter.com/kentcdodds/status/977018512689455106
648651
[bugs]: https://github.com/testing-library/react-testing-library/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Acreated-desc
649652
[requests]: https://github.com/testing-library/react-testing-library/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+label%3Aenhancement+is%3Aopen

other/MAINTAINING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ any more of you than that.
3232
As a maintainer, you're fine to make your branches on the main repo or on your
3333
own fork. Either way is fine.
3434

35-
When we receive a pull request, a travis build is kicked off automatically (see
36-
the `.travis.yml` for what runs in the travis build). We avoid merging anything
37-
that breaks the travis build.
35+
When we receive a pull request, a github action is kicked off automatically (see
36+
the `.github/workflows/validate.yml` for what runs in the action). We avoid
37+
merging anything that breaks the validate action.
3838

3939
Please review PRs and focus on the code rather than the individual. You never
4040
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.
4949
## Release
5050

5151
Our releases are automatic. They happen whenever code lands into `master`. A
52-
travis build gets kicked off and if it's successful, a tool called
52+
github action gets kicked off and if it's successful, a tool called
5353
[`semantic-release`](https://github.com/semantic-release/semantic-release) is
5454
used to automatically publish a new release to npm as well as a changelog to
5555
GitHub. It is only able to determine the version and whether a release is

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,19 @@
4343
"author": "Kent C. Dodds <[email protected]> (https://kentcdodds.com)",
4444
"license": "MIT",
4545
"dependencies": {
46-
"@babel/runtime": "^7.12.1",
46+
"@babel/runtime": "^7.12.5",
4747
"@testing-library/dom": "^7.26.6"
4848
},
4949
"devDependencies": {
50-
"@testing-library/jest-dom": "^5.11.5",
51-
"@types/react-dom": "^16.9.8",
50+
"@testing-library/jest-dom": "^5.11.6",
51+
"@types/estree": "0.0.45",
52+
"@types/react-dom": "^16.9.9",
5253
"dotenv-cli": "^4.0.0",
53-
"dtslint": "4.0.4",
54-
"kcd-scripts": "^6.6.0",
54+
"dtslint": "4.0.5",
55+
"kcd-scripts": "^7.0.3",
5556
"npm-run-all": "^4.1.5",
56-
"react": "^16.13.1",
57-
"react-dom": "^16.13.1",
57+
"react": "^17.0.1",
58+
"react-dom": "^17.0.1",
5859
"rimraf": "^3.0.2",
5960
"typescript": "^4.0.5"
6061
},

types/test.tsx

+18-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22
import {render, fireEvent, screen, waitFor} from '@testing-library/react'
33
import * as pure from '@testing-library/react/pure'
44

5-
async function testRender() {
5+
export async function testRender() {
66
const page = render(<div />)
77

88
// single queries
@@ -17,9 +17,10 @@ async function testRender() {
1717

1818
// helpers
1919
const {container, rerender, debug} = page
20+
return {container, rerender, debug}
2021
}
2122

22-
async function testPureRender() {
23+
export async function testPureRender() {
2324
const page = pure.render(<div />)
2425

2526
// single queries
@@ -34,20 +35,21 @@ async function testPureRender() {
3435

3536
// helpers
3637
const {container, rerender, debug} = page
38+
return {container, rerender, debug}
3739
}
3840

39-
async function testRenderOptions() {
41+
export function testRenderOptions() {
4042
const container = document.createElement('div')
4143
const options = {container}
4244
render(<div />, options)
4345
}
4446

45-
async function testFireEvent() {
47+
export function testFireEvent() {
4648
const {container} = render(<button />)
4749
fireEvent.click(container)
4850
}
4951

50-
async function testDebug() {
52+
export function testDebug() {
5153
const {debug, getAllByTestId} = render(
5254
<>
5355
<h2 data-testid="testid">Hello World</h2>
@@ -57,14 +59,22 @@ async function testDebug() {
5759
debug(getAllByTestId('testid'))
5860
}
5961

60-
async function testScreen() {
62+
export async function testScreen() {
6163
render(<button />)
6264

63-
screen.findByRole('button')
65+
await screen.findByRole('button')
6466
}
6567

66-
async function testWaitFor() {
68+
export async function testWaitFor() {
6769
const {container} = render(<button />)
6870
fireEvent.click(container)
6971
await waitFor(() => {})
7072
}
73+
74+
/*
75+
eslint
76+
testing-library/prefer-explicit-assert: "off",
77+
testing-library/no-wait-for-empty-callback: "off",
78+
testing-library/no-debug: "off",
79+
testing-library/prefer-screen-queries: "off"
80+
*/

0 commit comments

Comments
 (0)