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

Switch from Travis CI to GitHub Actions #504

Merged
merged 20 commits into from Feb 11, 2020
Merged

Switch from Travis CI to GitHub Actions #504

merged 20 commits into from Feb 11, 2020

Conversation

voxpelli
Copy link
Contributor

@voxpelli voxpelli commented Jan 25, 2020

Some benefits:

  • More granular representation in the UI of which tests fails and which passes
  • Very easy to run tests on Windows as well

Example runs can be seen here:

https://github.com/voxpelli/eslint-plugin-unicorn/actions?query=branch%3Atooling%2Fgithub-workflows

Badges like these ones can be added to readme after workflows has been added:

Tests
Other

@sindresorhus
Copy link
Owner

I dunno. GH Actions is promising, but that’s a fairly large amount of config for something the Travis file does in 19 lines.

@voxpelli
Copy link
Contributor Author

voxpelli commented Jan 25, 2020

@sindresorhus You can do it in fewer files, but I myself has opted for splitting them up in my repositories, to get them as fully separate workflows in the UI and logs.

It would be possible to fully replicate the Travis CI one I believe, but then the bonus of more granular feedback would get lost.

Edit: The Basic example here is eg. very small: https://github.com/actions/setup-node#usage

@voxpelli
Copy link
Contributor Author

I gave it a second look to see whether I could slim the files down. Now they are pretty much are the simplest bare minimum that I can figure out, where one stills gets granular feedback in the UI.

One could smash the three different tests together even more, but I'm not sure whether it will become more readable or worse + you likely/easily lose some of the feedback in the UI.

One thing though: I do know that Other as a label is pretty useless, but it's all my brain can come up with right now 😝

@fisker
Copy link
Collaborator

fisker commented Jan 26, 2020

@sindresorhus
Copy link
Owner

Use actions/checkout@v2.

@voxpelli
Copy link
Contributor Author

@sindresorhus Done 👍

@fisker Nice, my only feedback on that one is that it doesn't give granular feedback on whether it's the linting/integration that fails or something else – just like the Travis tests ;) Any takeaways from when you made that one?

.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
package.json Outdated
@@ -15,7 +15,8 @@
},
"scripts": {
"test": "xo && nyc ava",
"lint": "node ./test/lint/lint.js",
"test-coverage": "nyc --reporter=lcov ava",
"lint": "node ./test/lint/lint.js && xo",
Copy link
Owner

Choose a reason for hiding this comment

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

XO is now run twice, both on test and lint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sindresorhus Yes and no. In the GitHub CI pipe test-coverage is run rather than test. Partly to get coverage report and partly to move the xo part from being run on every Node.js version to being run just once as part of the linting flow.

So, test.yml runs test-coverage while other.yml (suggestion on better name?) runs lint and integration

I thought it was best to leave the test as is, as that's likely the one that gets run manually the most.

@sindresorhus
Copy link
Owner

Alright, let's do this. Can you drop the Travis file and integrate the badges?

Copy link
Collaborator

@fisker fisker left a comment

Choose a reason for hiding this comment

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

We should use songle yml for all jobs

@voxpelli
Copy link
Contributor Author

voxpelli commented Feb 1, 2020

Alright, let's do this. Can you drop the Travis file and integrate the badges?

Done 👍

We should use songle yml for all jobs

I don't see the benefit of mashing them all together in one file.

Now there's at least just two files: One for those tests that don't care about which node.js version they run on and another that tests across all supported node.js versions. So all tests that are similar to one another are in the same file and those that don't really share any similarity, they are kept in separate files.

@fisker
Copy link
Collaborator

fisker commented Feb 1, 2020

@voxpelli use one file we can use one badge, and they are not that much

@voxpelli
Copy link
Contributor Author

voxpelli commented Feb 1, 2020

@voxpelli use one file we can use one badge, and they are not that much

@fisker I don't think having two badges are a bug but a feature. It's to me two very different things whether linting fails or whether tests fails. Tests verifies functionality while linting verifies code quality. Getting good indicators around which one is failing is a benefit on top of Travis CI I think. (Though I do recognize that I haven't contributed a good name for the Other badge and that coupling integration and linting in the same file kind of defeats the purpose of the separation, hence why I had three files initially)

@sindresorhus I did a rebase + squash as well as removed Node 8 to match master + added Node.js 13 as a separate commit. Any reason why Node.js 13 isn't included right now?

- uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
Copy link
Collaborator

@fisker fisker Feb 1, 2020

Choose a reason for hiding this comment

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

On my experience, this not right, seem need another job wait for matrix, not sure. I tried in this way before.

So I dont use parallel https://github.com/fisker/id-placeholder/blob/ae506a0069bb459f6100f2c317f377ba9f8651de/.github/workflows/continuous-integration.yml#L52

Also, this action some times fail for no reason, issue can found on their repo, so I use continue-on-error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parallel-finished is what they document should be used when running multiple tests in parallel: https://github.com/coverallsapp/github-action#inputs

I added the continue-on-error on error now 👍 Good feedback!

.github/workflows/test.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@fisker fisker left a comment

Choose a reason for hiding this comment

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

I know that, also here says

Set to true in the last job, after the other parallel jobs steps have completed, this will send a webhook to Coveralls to set the build complete.

on matrix, the other parallel jobs steps have not completed.

@fisker
Copy link
Collaborator

fisker commented Feb 1, 2020

Like I said, I'm not sure how to make it work, I tried this way before, but seems not right

@voxpelli
Copy link
Contributor Author

voxpelli commented Feb 1, 2020

Yeah, in the example it does like what I did: https://github.com/coverallsapp/github-action/blob/master/README.md#complete-parallel-job-example 🤔

@sindresorhus
Copy link
Owner

I don't really see the value of two badges either. You have to click the badge regardless to see the details, and neither should be failing.

@fisker
Copy link
Collaborator

fisker commented Feb 1, 2020

But this example is not on matrix.

We can skip changing this part, just keep them.
If we find any problem later, we can fix then.

@fisker
Copy link
Collaborator

fisker commented Feb 1, 2020

One more thing eslint-plugin-ava already did this

https://github.com/avajs/eslint-plugin-ava/blob/master/.github/workflows/ci.yml

name: Node.js ${{ matrix.node_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Copy link
Collaborator

Choose a reason for hiding this comment

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

fail-fast: false is needed here

@fisker
Copy link
Collaborator

fisker commented Feb 1, 2020

@voxpelli found a project use parallel, check the commit history of this file, guess I am right

https://github.com/lo1tuma/eslint-plugin-mocha/blob/e40722d1691f087550a1146b781bcf25631f74c8/.github/workflows/ci.yml

Comment on lines +96 to +98
"rules": {
"import/order": "off"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

@fisker
Copy link
Collaborator

fisker commented Feb 11, 2020

CI

@voxpelli I did some adjustment.

@sindresorhus You may want take a look.

continue-on-error: true
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
Copy link
Owner

Choose a reason for hiding this comment

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

Why cannot this just be part of the test job? I don't see what it does differently from the code in the test job either.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This job send a webhook to coveralls, need wait for all test job finished.

See #504 (comment) and #504 (comment)

Copy link
Owner

Choose a reason for hiding this comment

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

Why though? We only need coveralls to run in one of the test job, not all.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I removed parallel, and add a condition. only run on node.js 12 on linux

package.json Outdated Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Draft on possibly using GitHub CI/Actions rather than Travis CI Switch from Travis CI to GitHub Actions Feb 11, 2020
@fisker
Copy link
Collaborator

fisker commented Feb 11, 2020

@sindresorhus Do you want a nice title on each task? If not, I think we are good to go

readme.md Outdated
@@ -1,4 +1,4 @@
# eslint-plugin-unicorn [![Build Status](https://travis-ci.org/sindresorhus/eslint-plugin-unicorn.svg?branch=master)](https://travis-ci.org/sindresorhus/eslint-plugin-unicorn) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/eslint-plugin-unicorn/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/eslint-plugin-unicorn?branch=master)
# eslint-plugin-unicorn ![Build Status](https://github.com/sindresorhus/eslint-plugin-unicorn/workflows/CI/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/eslint-plugin-unicorn/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/eslint-plugin-unicorn?branch=master)
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't the badge be linkified?

@sindresorhus
Copy link
Owner

Do you want a nice title on each task?

Nah

@fisker fisker merged commit 34de844 into sindresorhus:master Feb 11, 2020
@fisker
Copy link
Collaborator

fisker commented Feb 11, 2020

Thanks @voxpelli

@fisker fisker mentioned this pull request Feb 11, 2020
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.

None yet

3 participants