Skip to content
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

build: adds GitHub Actions for test/integration/lint #1059

Merged
merged 3 commits into from
Apr 16, 2020

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Apr 12, 2020

Description of proposed changes

Follow on from #1057, adds GitHub actions for lint, test, integration. If #1057 is landed, it might be worth combining it into the single ci.yaml.

Related issue(s)

Related to #1057

Testing

I've tested the configuration here.

Notes

Relationship between integration tests and #1057:

I noticed when wiring up integration-test, that it has many similarities with #1057 (in that, it requires the datasets, the server is running, asserts against text) -- the advantage is that folks can simply enumerate a variety of URLs in urls.txt (it's a nice little abstraction)...

I'd argue it might be worth dropping integration-test, in favor of the approach in #1057, and the E2E work happening in #917 around E2E visual testing.

Requiring tests on PRs:

I recommend enforcing branch protection if this lands:

Screen Shot 2020-04-11 at 11 57 42 PM

.github/workflows/ci.yaml Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated
@@ -135,6 +137,7 @@
"jest": "^25.1.0",
"jest-puppeteer": "^4.4.0",
"puppeteer": "^2.1.1",
"start-server-and-test": "^1.10.11",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used the same trick as #1058, which has been working nicely (I've had the smoke tests pass in actions 10 or so times now, on my testing repo).

@@ -30,7 +30,7 @@ class Language extends React.Component {
{value: "lt", label: "Lietuvių"},
{value: "pt", label: "Português"},
{value: "fr", label: "Français"},
{value: "ja", label: "日本語"},
{value: "ja", label: "日本語"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gets lint actually passing.

@jameshadfield jameshadfield temporarily deployed to auspice-pr-1059-test-ytdggeteb April 15, 2020 10:48 Inactive
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this (and the lint job) should use ${{ matrix.node }}. Eventually I can see us testing on multiple node versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a matrix for both lint and integration 👍

@jameshadfield
Copy link
Member

jameshadfield commented Apr 15, 2020

This is really cool. I pushed up a copy of this branch as this temporary PR to test the CI. It is looking really good, but I have a couple of questions:

  1. The workflow doesn't actually run on the PR itself, rather it runs on a merge of the PR into master (see this part of the actions/checkout@v2 docs). This creates a confusing failure in the above PR, where linting fails on a recent introduction in master which isn't in this PR (https://github.com/nextstrain/auspice/pull/1064/checks?check_run_id=588632308#step:5:10).

Is this normal practice? I imagine that after implementing this CI we avoid linting errors so this shouldn't be a problem, and in more complicated situations it favors a rebase-onto-master approach.

  1. The unit tests fail CI with ReferenceError: page is not define which I think is addressed by a comment of yours on test: text-based dataset smoke test #1057. Would you mind adding that to this PR?

I recommend enforcing branch protection if this lands

👍 will do

@bcoe
Copy link
Contributor Author

bcoe commented Apr 15, 2020

The workflow doesn't actually run on the PR itself, rather it runs on a merge of the PR into master

I'm using a similar configuration to what I use on yargs (seen here). I believe it will run on pull requests once merged, and part of the repos main workflow:

on:
  push:
    branches:
      - master
  pull_request:

☝️ indicates, run on all pull_request, only run on push to master. This is so, for pull_request, you don't get a suite of tests for both the push and the PR changes.

@jameshadfield
Copy link
Member

jameshadfield commented Apr 15, 2020

Looking back at it my comment didn't quite explain what I was trying to get at:

My understanding is that the CI will run on each PR, and so you'll get a "checks" tab like you see in #1064. But the actual code the CI tests are being run on (i.e. the GitHub runner set-up, which has the auspice code available via actions/checkout@v2) is a merge of the PR into master, i.e. you're testing the world that would exist were the PR to me merged. This is why you get failures such as 👇 where the line which fails has been introduced in master upstream of where this PR branched off.

image

P.S. Do you know why the CI is running on this PR? I thought they didn't run for PRs from forks. Still trying to wrap my head around actions.

Copy link
Member

@jameshadfield jameshadfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this direction. If you could address the following we can get this merged ASAP:

  • add ${{ matrix.node }} to node-version
  • rename the fix npm rule
  • rebase onto master, which now has 0 lint errors, so the lint job should pass
  • modify the test rule to "test": "jest test/*.js", so that only unit tests are run and thus the job passes. An alternate solution would be to modify the job description in the workflow.
  • Confirm that the tests for a PR should be run on a checked-out codebase which is itself a merge of the PR into master, as it is currently doing.

@bcoe
Copy link
Contributor Author

bcoe commented Apr 16, 2020

i.e. you're testing the world that would exist were the PR to me merged

I think this is good default behavior, because you need to know that your PR doesn't fail tests if it's landed on top of master.

In practice, on my team's repos, we require that you're up to date with master before you can merge:

Screen Shot 2020-04-15 at 10 37 12 PM

So at any given time, it's equivalent to the PR having being rebased with master prior to testing.


I think I've addressed the other review 👌

@bcoe
Copy link
Contributor Author

bcoe commented Apr 16, 2020

P.S. Do you know why the CI is running on this PR

I'm not 100% sure, I could have sworn it needed to be blessed by the maintainer by being merged first (maybe the fact that you forked the branch had an effect?).

Copy link
Member

@jameshadfield jameshadfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic. Going to merge now & then we can add in further tests etc in later PRs. I'll also move us away from TravisCI by creating a workflow which only runs when the release branch changes, but that's not pressing. Thanks again!

@jameshadfield jameshadfield merged commit f01cf85 into nextstrain:master Apr 16, 2020
@bcoe bcoe deleted the actions branch April 17, 2020 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants