Skip to content

Commit

Permalink
chore: switch to github actions (#826)
Browse files Browse the repository at this point in the history
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
  • Loading branch information
nickserv and kentcdodds authored Nov 14, 2020
1 parent 007b0b7 commit 3af1b4b
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 63 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -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 }}
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ practices.</p>
<!-- prettier-ignore-start -->
[![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]

[![All Contributors](https://img.shields.io/badge/all_contributors-102-orange.svg?style=flat-square)](#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]
Expand Down Expand Up @@ -608,6 +609,7 @@ Thanks goes to these people ([emoji key][emojis]):
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors][all-contributors] specification.
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions other/MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@
"author": "Kent C. Dodds <me@kentcdodds.com> (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"
},
Expand Down
26 changes: 18 additions & 8 deletions types/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<div />)

// single queries
Expand All @@ -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(<div />)

// single queries
Expand All @@ -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(<div />, options)
}

async function testFireEvent() {
export function testFireEvent() {
const {container} = render(<button />)
fireEvent.click(container)
}

async function testDebug() {
export function testDebug() {
const {debug, getAllByTestId} = render(
<>
<h2 data-testid="testid">Hello World</h2>
Expand All @@ -57,14 +59,22 @@ async function testDebug() {
debug(getAllByTestId('testid'))
}

async function testScreen() {
export async function testScreen() {
render(<button />)

screen.findByRole('button')
await screen.findByRole('button')
}

async function testWaitFor() {
export async function testWaitFor() {
const {container} = render(<button />)
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"
*/

0 comments on commit 3af1b4b

Please sign in to comment.