Skip to content

Commit

Permalink
feat: add an opt-in linter job to the main workflow (#8)
Browse files Browse the repository at this point in the history
* ci: add swagger plugin workflow

* ci: add linter workflow

* docs: add linter workflow documentation

* refactor (docs): fix format

* fix: apply suggestions from @mcollina code review

* ci: move linter job inside `plugins-ci.yml`

* ci: make linter job optional

* docs: update documentation

* ci: apply suggestions from @Eomm code review

* ci: make linter job optional

* docs: apply suggestions from @Eomm code review

Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>

* docs: apply suggestions from @Eomm code review

Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>

Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>
  • Loading branch information
darkgl0w and Eomm authored Jan 26, 2022
1 parent df77472 commit 79f3bba
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
32 changes: 27 additions & 5 deletions .github/workflows/plugins-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,49 @@ name: Plugin CI

on:
workflow_call:
inputs:
lint:
description: 'Set to true to run linting scripts.'
required: false
default: false
type: boolean

jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Skip lint
if: ${{ inputs.lint == false}}
run: exit 0
- uses: actions/checkout@v2
if: ${{ inputs.lint == true}}
- name: Use Node.js
if: ${{ inputs.lint == true}}
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install Dependencies
if: ${{ inputs.lint == true}}
run: npm i --ignore-scripts
- name: Lint code
if: ${{ inputs.lint == true}}
run: npm run lint

test:
needs: linter
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [10, 12, 14, 16]
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
- 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

Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,33 @@ jobs:
Included in this repo is a [basic workflow](.github/workflows/plugins-ci.yml) for use across the majority of plugins, as well as variants with service containers.
### Enable workflow Linter job
By setting the `lint` option to `true` when using the [basic workflow](.github/workflows/plugins-ci.yml) the CI will first run the linter job once.


__Example:__ running the linter job first with the [basic workflow](.github/workflows/plugins-ci.yml)

```yml
name: CI
on:
push:
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v2
with:
lint: true
```

## Acknowledgements

This project is kindly sponsored by:
Expand Down

0 comments on commit 79f3bba

Please sign in to comment.