-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some reusable GH Actions workflows
... for tasks used by the majority of repos and for which there is next to no differentiation between the steps in the workflows.
- Loading branch information
Showing
4 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Markdownlint | ||
|
||
on: | ||
workflow_call: | ||
|
||
# Cancels all previous workflow runs for the same branch that have not yet completed. | ||
concurrency: | ||
# The concurrency group contains the workflow name and the branch name. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
markdownlint: | ||
name: 'Lint Markdown' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check for existence of a Yamllint config file | ||
id: has_config | ||
uses: andstor/file-existence-action@v3 | ||
with: | ||
files: ".markdownlint-cli2.y*ml" | ||
|
||
# @link https://github.com/marketplace/actions/problem-matcher-for-markdownlint-cli | ||
- name: Enable showing issue in PRs | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
uses: xt0rted/markdownlint-problem-matcher@v3 | ||
|
||
# @link https://github.com/marketplace/actions/markdownlint-cli2-action | ||
- name: Check markdown with CLI2 | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
uses: DavidAnson/markdownlint-cli2-action@v17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Yamllint | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
strict: | ||
description: 'Whether to enable strict mode.' | ||
type: boolean | ||
required: false | ||
default: false | ||
|
||
# Cancels all previous workflow runs for the same branch that have not yet completed. | ||
concurrency: | ||
# The concurrency group contains the workflow name and the branch name. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
yamllint: | ||
name: 'Lint Yaml' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check for existence of a Yamllint config file | ||
id: has_config | ||
uses: andstor/file-existence-action@v3 | ||
with: | ||
files: ".yamllint.y*ml" | ||
|
||
- name: Run Yamllint on all yaml files in repo | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
run: yamllint . --format colored ${{ inputs.strict && '--strict' || '' }} | ||
|
||
- name: Pipe Yamllint results on to GH for inline display | ||
if: ${{ failure() && github.event_name == 'pull_request' }} | ||
run: yamllint . --format github ${{ inputs.strict && '--strict' || '' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: PHPStan | ||
|
||
on: | ||
workflow_call: | ||
|
||
# Cancels all previous workflow runs for the same branch that have not yet completed. | ||
concurrency: | ||
# The concurrency group contains the workflow name and the branch name. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
phpstan: | ||
name: "PHPStan" | ||
runs-on: "ubuntu-latest" | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check for existence of a PHPStan config file | ||
id: has_config | ||
uses: andstor/file-existence-action@v3 | ||
with: | ||
files: "phpstan.neon*" | ||
|
||
- name: Install PHP | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 'latest' | ||
coverage: none | ||
tools: phpstan | ||
|
||
# Install dependencies and handle caching in one go. | ||
# Dependencies need to be installed to make sure the PHPUnit classes are recognized. | ||
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer | ||
- name: Install Composer dependencies | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
uses: "ramsey/composer-install@v3" | ||
with: | ||
# Bust the cache at least once a month - output format: YYYY-MM. | ||
custom-cache-suffix: $(date -u "+%Y-%m") | ||
|
||
- name: Run PHPStan | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
run: phpstan analyse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Remark | ||
|
||
on: | ||
workflow_call: | ||
|
||
# Cancels all previous workflow runs for the same branch that have not yet completed. | ||
concurrency: | ||
# The concurrency group contains the workflow name and the branch name. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
remark: | ||
name: 'QA Markdown' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check for existence of a Yamllint config file | ||
id: has_config | ||
uses: andstor/file-existence-action@v3 | ||
with: | ||
files: ".remarkrc" | ||
|
||
- name: Set up node and enable caching of dependencies | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
|
||
# To make the command available on CLI, it needs to be installed globally. | ||
- name: Install Remark CLI globally | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
run: npm install --global remark-cli --foreground-scripts true --fund false | ||
|
||
# To allow for creating a custom config which references rules which are included | ||
# in the presets, without having to install all rules individually, a local install | ||
# works best (and installing the presets in the first place, of course). | ||
# | ||
# Note: the first group of packages are all part of the mono "Remark lint" repo. | ||
# The second group of packages (heading-whitespace and down) are additional | ||
# "external" rules/plugins. | ||
- name: Install Remark rules locally | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
run: > | ||
npm install --foreground-scripts true --fund false | ||
remark-lint | ||
remark-gfm | ||
remark-preset-lint-consistent | ||
remark-preset-lint-recommended | ||
remark-preset-lint-markdown-style-guide | ||
remark-lint-checkbox-content-indent | ||
remark-lint-linebreak-style | ||
remark-lint-no-dead-urls | ||
remark-lint-no-duplicate-defined-urls | ||
remark-lint-no-empty-url | ||
remark-lint-no-heading-like-paragraph | ||
remark-lint-no-reference-like-url | ||
remark-lint-no-unneeded-full-reference-image | ||
remark-lint-no-unneeded-full-reference-link | ||
remark-lint-strikethrough-marker | ||
remark-lint-heading-whitespace | ||
remark-lint-list-item-punctuation | ||
remark-lint-match-punctuation | ||
remark-lint-no-hr-after-heading | ||
remark-lint-are-links-valid-duplicate | ||
remark-validate-links | ||
- name: Run Remark-lint | ||
if: ${{ steps.has_config.outputs.files_exists == 'true' }} | ||
run: remark . --frail | ||
|
||
# @link https://github.com/reviewdog/action-remark-lint | ||
- name: Show Remark-lint annotations in PR | ||
if: ${{ failure() && github.event_name == 'pull_request' }} | ||
uses: reviewdog/action-remark-lint@v5 | ||
with: | ||
fail_on_error: true | ||
install_deps: false | ||
level: info | ||
reporter: github-pr-check |