-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add testing groups and browser testing environment #728
Changes from all commits
9ee8d19
28fbf75
df2e508
5ccf2b6
8799f16
4abf41b
b647cca
5aa382a
8e50548
63d54a8
51d4bb4
f4e8481
b790b7b
4bc2268
35faf15
7677df5
79b3bb0
1aa45ce
df94fce
9127f1c
a49de06
c3338b6
05d748b
75665c1
ca11124
1b1e7e2
6e9f289
b49503d
3e0262b
db9e535
a37da5d
3d0d4b6
9e434b0
44d5c29
a60c542
3cf3d9b
e96513b
3549d51
ab2f3b6
3bc6561
9058236
131fbcd
7a3e7ff
8b460f4
25f416c
bd5354e
863f636
4f32fa5
1a79736
0b1086a
7ac4759
5e7427c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "Browser e2e tests" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
browser-e2e-tests: | ||
# only run this job if the base branch is dp/testing-groups | ||
if: ${{github.ref_name == '728/merge'}} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
status: ${{ job.status }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: CI Setup | ||
uses: ./.github/actions/ci-setup | ||
|
||
- name: Build | ||
run: | | ||
BUILD_VERSION="0.0.0-${{ github.ref_name }}-$(git rev-parse --short $GITHUB_SHA)" pnpm build | ||
- name: Run services | ||
run: pnpm services:run | ||
|
||
- name: Browser e2e tests | ||
run: npx jest -- "**/*.common.e2e.test.ts" --setupFilesAfterEnv=./setup-puppeteer.ts --testTimeout=30000 --coverage | ||
|
||
- name: Upload coverage to Github artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: browser-e2e-coverage | ||
path: coverage | ||
|
||
- name: Stop services | ||
run: pnpm services:clean |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: "Browser unit tests" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
browser-unit-tests: | ||
# only run this job if the base branch is dp/testing-groups | ||
if: ${{github.ref_name == '728/merge'}} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
status: ${{ job.status }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: CI Setup | ||
uses: ./.github/actions/ci-setup | ||
|
||
- name: Build | ||
run: | | ||
BUILD_VERSION="0.0.0-${{ github.ref_name }}-$(git rev-parse --short $GITHUB_SHA)" pnpm build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned, still need to at very least move these into an action |
||
- name: Browser unit tests | ||
run: npx jest -- "**/*.common.unit.test.ts" --setupFilesAfterEnv=./setup-puppeteer.ts --testTimeout=30000 --coverage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just launches puppeteer and then runs the tests on node? |
||
|
||
- name: Upload coverage to Github artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: browser-unit-coverage | ||
path: coverage |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "Node e2e tests" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
node-e2e-tests: | ||
# only run this job if the base branch is dp/testing-groups | ||
if: ${{github.ref_name == '728/merge'}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove this check from all the files as this action only exists on your PR anyways, unless you had noticed some kind of weird side effect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are having to keep this here because we will need to merge this PR in before being fully done with this whole setup, as things stand. Please see: #728 (comment) |
||
runs-on: ubuntu-latest | ||
outputs: | ||
status: ${{ job.status }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: CI Setup | ||
uses: ./.github/actions/ci-setup | ||
|
||
- name: Build | ||
run: | | ||
BUILD_VERSION="0.0.0-${{ github.ref_name }}-$(git rev-parse --short $GITHUB_SHA)" pnpm build | ||
- name: Run services | ||
run: pnpm services:run | ||
|
||
- name: Node e2e tests | ||
run: npx jest -- "**/*.node.e2e.test.ts" --coverage | ||
|
||
- name: Upload coverage to Github artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: node-e2e-coverage | ||
path: coverage | ||
|
||
- name: Stop services | ||
run: pnpm services:clean |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: "Node unit tests" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
node-unit-tests: | ||
# only run this job if the base branch is dp/testing-groups | ||
if: ${{github.ref_name == '728/merge'}} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
status: ${{ job.status }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: CI Setup | ||
uses: ./.github/actions/ci-setup | ||
|
||
- name: Build | ||
run: | | ||
BUILD_VERSION="0.0.0-${{ github.ref_name }}-$(git rev-parse --short $GITHUB_SHA)" pnpm build | ||
- name: Node unit tests | ||
run: npx jest -- "**/*.node.unit.test.ts" --coverage | ||
|
||
- name: Upload coverage to Github artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: node-unit-coverage | ||
path: coverage |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: "Test coverage" | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
[Node unit tests, Node e2e tests, Browser unit tests, Browser e2e tests] | ||
types: [completed] | ||
|
||
jobs: | ||
collect-coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download coverage report for Browser unit tests | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: browser-unit-tests.yaml | ||
name: browswer-unit-coverage | ||
path: browser-unit-coverage | ||
|
||
- name: Download coverage report for Browser e2e tests | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: browser-e2e-tests.yaml | ||
name: browswer-e2e-coverage | ||
path: browser-e2e-coverage | ||
|
||
- name: Download coverage report for Node unit tests | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: node-unit-tests.yaml | ||
name: node-unit-coverage | ||
path: node-unit-coverage | ||
|
||
- name: Download coverage report for Node e2e tests | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: node-e2e-tests.yaml | ||
name: node-e2e-coverage | ||
path: node-e2e-coverage | ||
|
||
- name: Merge all coverage reports | ||
run: npx istanbul-merge --out coverage-merged.json browser-unit-coverage/coverage-final.json browser-e2e-coverage/coverage-final.json node-unit-coverage/coverage-final.json node-e2e-coverage/coverage-final.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
- name: Upload coverage report to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: coverage-merged.json | ||
token: ${{ secrets.CODECOV_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,11 +26,9 @@ jobs: | |
- name: Build | ||
run: | | ||
BUILD_VERSION="0.0.0-${{ github.ref_name }}-$(git rev-parse --short $GITHUB_SHA)" pnpm build | ||
- name: Lint | ||
run: | | ||
pnpm lint | ||
- name: Checking PR Number | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we merge this PR, we still want the rest of the repo to use this old That's why I have kept it intact still. |
||
uses: jwalton/gh-find-current-pr@v1 | ||
id: findPr | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { Browser } from 'puppeteer'; | ||
import puppeteer from 'puppeteer'; | ||
|
||
let browser: Browser; | ||
|
||
beforeAll(async () => { | ||
browser = await puppeteer.launch(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await browser.close(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These steps are repeated and should all be abstracted away into composite actions, such as a wrapper like this:
https://github.com/FuelLabs/fuels-ts/blob/master/.github/actions/ci-setup/action.yaml
That would apply to all of these "setup" steps as well as the "coverage" and "teardown" steps after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also have you looked at using the advanced GitHub action called a test matrix?
Alongside the test matrix idea, you could also investigate
fail-fast
or the similarcontinue-on-error
to let builds find the bad linting first, then bad unit tests, then get into the meaty stuff like e2e