Skip to content

Commit

Permalink
[#143] Added linting of the GitHub actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Apr 21, 2024
1 parent 0b61efd commit 1d03ed5
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .github/.yamllint-for-gha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Yamllint configuration file used to check GitHub Actions configuration files.
extends: default

rules:
comments:
min-spaces-from-content: 1
document-start:
present: false
empty-lines:
max: 1
max-start: 0
max-end: 0
line-length:
max: 255
truthy:
allowed-values: ['true', 'false']
check-keys: false
6 changes: 3 additions & 3 deletions .github/workflows/release-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ jobs:
- name: Install dependencies
run: composer install

#;< PHP_PHAR
# yamllint disable-line #;< PHP_PHAR
- name: Build PHAR
run: composer build

- name: Test PHAR
run: ./.build/php-command.phar || exit 1
#;> PHP_PHAR
# yamllint disable-line #;> PHP_PHAR

- name: Get tag name
id: get-version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"

- name: Create Release
uses: softprops/action-gh-release@v2
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Actions

on:
push:
branches:
- main
pull_request:
branches:
- main
- 'feature/**'

jobs:
test-actions:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check coding standards with yamllint
run: yamllint --config-file .github/.yamllint-for-gha.yml .github/workflows
continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }}

- name: Check coding standards with actionlint
run: docker run --rm -v "${GITHUB_WORKSPACE:-.}":/app --workdir /app rhysd/actionlint:1.6.27
continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }}
4 changes: 2 additions & 2 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

#;< PHP_PHAR
# yamllint disable-line #;< PHP_PHAR
build-php:
runs-on: ubuntu-latest
steps:
Expand All @@ -83,4 +83,4 @@ jobs:

- name: Test PHAR
run: ./.build/php-command.phar || exit 1
#;> PHP_PHAR
# yamllint disable-line #;> PHP_PHAR
2 changes: 1 addition & 1 deletion .github/workflows/test-scaffold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: npm --prefix=tests/scaffold ci

- name: Run tests
run: kcov --include-pattern=.sh,.bash --bash-parse-files-in-dir=. --exclude-pattern=vendor,node_modules,.scaffold-coverage-html $(pwd)/.scaffold-coverage-html ./tests/scaffold/node_modules/.bin/bats tests/scaffold
run: kcov --include-pattern=.sh,.bash --bash-parse-files-in-dir=. --exclude-pattern=vendor,node_modules,.scaffold-coverage-html "$(pwd)"/.scaffold-coverage-html ./tests/scaffold/node_modules/.bin/bats tests/scaffold

- name: Upload coverage report as an artifact
uses: actions/upload-artifact@v4
Expand Down
13 changes: 12 additions & 1 deletion docs/content/ci/test.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The workflow includes steps for linting, testing, and code coverage.

[//]: # (#;< SHELL)

## Node.js job
## Shell job

- Runs on a matrix of several OSes.
- Checks out code.
Expand All @@ -71,6 +71,17 @@ The workflow includes steps for linting, testing, and code coverage.

[//]: # (#;> SHELL)

## Actions job

Used to validate the GitHub Actions workflow files in the repository.

- Checks out code.
- Runs code linting with [`yamllint`](https://github.com/adrienverge/yamllint) using [configuration](https://github.com/AlexSkrypnyk/scaffold/blob/main/.github/.yamllint-for-gha.yml) file.
- Runs code linting with [`actionlint`](https://github.com/rhysd/actionlint).

Add `CI_LINT_IGNORE_FAILURE` with a value of `1` to your repository's variables
to ignore linting failures.

## Code coverage

The workflow publishes code coverage reports for PHP and Node.js projects to
Expand Down

1 comment on commit 1d03ed5

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.