-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add an opt-in linter job to the main workflow #8
Conversation
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.
lgtm
This could be added to the existing workflows as a job, similar to what we had for the now removed coveralls input, rather than as a separate workflow? |
I agree with both solutions. Keeping the lint into a dedicated file is fine, but we should add it here on the ci* files like https://github.com/fastify/workflows/blob/main/.github/workflows/plugins-ci.yml
Note the |
Unfortunately we can't use reusable workflows within reusable workflows 😞 |
Oh, fine then. Thanks for pointing out. So I think integrating it into the main plaugin-ci-* is more "comfortable" for the plugins' configuration and we are forcing a unified and optimized standard across all the repos. |
Hmmmm 🤔 Right we can't use reusable workflows within reusable workflows 😢 🤯 I will make the linter a part of the plugins-ci workflow (note that this will certainly require some adjustments in repos where it is deployed) Here are some thoughts :
Here is an example of what can become a starter workflow : name: CI workflow
on:
push:
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
jobs:
# runs first and if errors are detected it doesn't waste resources because it will stop the dependent workflows
linter:
uses: darkgl0w/workflows/.github/workflows/ci-linter.yml@linter-ci
# the test runner (currently node 10, 12, 14, 16) - when we drop a node version we remove it in one file only
test:
needs: linter
uses: darkgl0w/workflows/.github/workflows/plugins-ci.yml@linter-ci
# the test runner (only node current branch 17 - and we just need to change the version inside this workflow)
experimental:
needs: linter
uses: darkgl0w/workflows/.github/workflows/plugins-ci-node-current.yml@linter-ci https://github.com/darkgl0w/fastify-swagger/actions/runs/1738731030 |
@darkgl0w, i'd probably add it as an input which is off by default. This is so if certain repos don't need/want linting then we can disable it: on:
workflow_call:
inputs:
lint:
description: 'Set to true to run linting scripts.'
required: false
type: boolean
jobs:
lint:
if: inputs.lint == true
# rest of job goes here Then it would be called like so: name: CI workflow
on: [push, pull_request]
jobs:
test:
uses: darkgl0w/workflows/.github/workflows/plugins-ci.yml@main
with:
lint: true |
Gotcha ! |
@Fdawgs > I ran some sample runs following your suggestions and this is what I've come up with due to the limitations of GitHub Actions workflows : jobs:
test:
needs: linter
# workaround to always run this job
if: ${{ always() }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [10, 12, 14, 16]
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
# workaround to fail if linter fail
- name: Stop on linter job failure
if: ${{ needs.linter.result == 'failure' }}
run: exit 1
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts
- name: Run Tests
run: npm test Some thoughts :
for reference - workflow CI runs: |
Cheers @darkgl0w, I've been busy finishing up some work pieces today, so will have a look tomorrow. |
Do you know why this is happening? |
This is a limitations that comes with the conditional start of the linter job and its requirement for starting the test job. In order to be able to bypass the need of the linter job by the test job when the # workaround to fail if linter fail
- name: Stop on linter job failure
if: ${{ needs.linter.result == 'failure' }}
run: exit 1 With the linter included in the main workflow behind an optional activation input that's the best we can do to reduce the waste of resources. The other solution would be to split the jobs and to use GitHub Starter workflows. (cf. #8 (comment), this is an example of what we can achieve by combining reusable workflows and starter workflows across the org repos). Both have their pros and their cons. |
Thanks for explaining.
So I would go for the non-skippable lint step (this should solve the need for this We could add an input option to set the |
@Eomm > applied your suggestion and with |
Had completely forgotten this existed, this makes it so much easier. |
I have found a better solution directly inside the Github actions :P |
With this lint is actually optional and the waste of resources is minimal 😃 CI sample runs: |
Co-authored-by: Manuel Spigolon <[email protected]>
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.
...Where's the chef's kiss emoji? 👨🍳
LGTM, thanks @darkgl0w.
I think that we can push those workflows even further and choose to exclude/include some node/os versions. [edit] |
Co-authored-by: Manuel Spigolon <[email protected]>
* fix #8 * Update plugins-ci-redis.yml
Hello.
Following fastify/fastify-swagger#531 (review), this PR aims to :
Checklist
and the Code of conduct