-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add reusable GitHub workflows "lint & tests" and "tag & publish" for JS projects #2
Conversation
f47d3f9
to
8470112
Compare
160a864
to
bca5f8f
Compare
@@ -0,0 +1,105 @@ | |||
name: CI |
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.
Even if it is a reusable workflow, the file must be located in:
<my_repo>/.github/workflows/<my_workflow>.yml
Otherwise we get the error:
https://github.com/peopledoc/ember-feature-controls/actions/runs/1399317821
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.
Following this comment, declaring concurrency
is not yet supported at the root of a called workflow file:
https://github.com/peopledoc/ember-feature-controls/actions/runs/1399155003
It must be declared in the caller workflow.
bca5f8f
to
759853d
Compare
e84b9cb
to
b0e1e31
Compare
6f9f0a4
to
a2b7bd7
Compare
body: "\ | ||
Changelog: \ | ||
${{ github.server_url }}/${{ github.repository }}\ | ||
/compare/\ | ||
v${{ needs.create_git_tag.outputs.old_version }}...v${{ needs.create_git_tag.outputs.new_version }}\ | ||
" |
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.
Why this syntax? => In order to split a long string over multiple lines, without getting a whitespace between each line.
In comparison to:
body: >
Changelog:
my_repo
/compare/
v1...v2
Which would result in the following string: (notice the whitespaces between each section)
Changelog: my_repo /compare/ v1...v2
65ae485
to
6624128
Compare
511ef5b
to
5ff168c
Compare
# GitHub Actions documentation: | ||
# https://docs.github.com/en/actions | ||
|
||
name: Create new `git tag`, create new GitHub release and publish to NPM |
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.
Should we rename it js-tag-release-publish
?
If I'm correct we don't have any EmberJS related code in this workflow?
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.
Ah true true, good remark.
That would require an update to the CODEOWNERS file.
Following your suggestion, what about this @GreatWizard :
-
Move the workflow
.github/workflows/emberjs-addons-ci.yml
to.github/workflows/js/emberjs-addons-ci.yml
-
Move the workflow
.github/workflows/emberjs-addons-tag-release-publish.yml
to.github/workflows/js/tag-release-publish.yml
⬆️. Your suggestion
-
Update the CODEOWNERS to make the Tribe owner of the pattern:
# To match the directory `js` and all its subdirectories
/.github/workflows/js/ @peopledoc/tribe-js
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.
We can't put workflows into subdirectories è_é.
See commit b4c7f08 .
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
cache: yarn |
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.
We should be possible to override this option.
Probabbly use npm by default and let the integration specify "yarn"
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.
We can indeed, many other things could be parametised but do we want it in this first version? As all our repo use yarn
.
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.
right , I'm fine with it tbh :) at least add it in inputs with yarn by default ? just to be future proof
registry-url: https://registry.npmjs.org | ||
|
||
- name: Install Dependencies | ||
run: yarn install --frozen-lockfile |
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.
this command should be yarn/npm agnostic too?
In addition, we don't even specify the package manager for the cache
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.
Again, as decided together, it is a first version that only targets our public add-ons on npm, which all use yarn
. I did not feel the need to make the workflows more complex than they really need 🤔 .
4ac1b6f
to
c101c6c
Compare
Workflows cannot be nested in subdirectories. See this error: https://github.com/peopledoc/ember-feature-controls/actions/runs/1412237054 ``` invalid value workflow reference: workflows must be defined at the top level of the .github/workflows/ directory ```
c101c6c
to
4c25fc1
Compare
Add a reusable GitHub workflow "lint & tests" for Ember.js add-ons (#2)
This reusable workflow runs the typical jobs that Ember.js add-ons should run (as already implemented in ember-cli-embedded) to lint and test their codebase.
It accepts 3 inputs from the caller workflow1:
ember_try_scenarios
(optional)A list of test scenarios to run with
ember-try
,If not specified, a predefined list of scenarios will be used.
This can be used, for instance, to force
ember-try
not to run Embroider scenarios when it is not yet installed in the add-on. (see an example)nodejs_version
(optional)The version of Node.js to use.
If not specified, the version 12 will be used (which is still a LTS for the moment)
package_manager
(optional)Which package manager to use between
npm
andyarn
.If not specified,
yarn
will be used.One information, the step
Lint lockfile
is a custom addition in order to spot eventual malicious attacks (see https://github.com/lirantal/lockfile-lint).Add a reusable GitHub workflow "tag & publish" for JS projects (#2)
When this new workflow can run it does:
git tag
if a new version is detected inpackage.json
git tag
npm
using the newly createdgit tag
Note: the jobs
2-a
and2-b
run in parallel.It accepts 2 inputs from the caller workflow1:
nodejs_version
(optional)The version of Node.js to use.
If not specified, the version 12 will be used (which is still a LTS for the moment)
package_manager
(optional)Which package manager to use between
npm
andyarn
.If not specified,
yarn
will be used.It accepts 1 secret from the caller workflow1:
npm_automation_token
(required)An NPM automation token authorised to publish versions.
Currently implemented in the repositories
Footnotes
GitHub terminology
See https://docs.github.com/en/actions/learn-github-actions/reusing-workflows ↩ ↩2 ↩3