Skip to content
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

chore: merge lint workflows #89

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/workflows/lint-actionlint.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/lint-prettier.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/lint-shellcheck.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/lint-shfmt.yml

This file was deleted.

96 changes: 96 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: lint
on:
pull_request:
paths:
# actionlint
- ".github/workflows/*.yml"
# prettier
- "**.md"
- "**.yml"
# shellcheck & shfmt
- "**.sh"

jobs:
# This job fetches changed files that others will use to see if they should be run or not.
# If this file changes, any script should also fire.
changed:
runs-on: ubuntu-22.04
outputs:
files: ${{ steps.all.outputs.all_changed_files }}
self_changed: ${{ steps.lint.outputs.any_changed }}
steps:
- uses: actions/checkout@v3.0.2
with:
fetch-depth: 0
- name: Get a list of changed files
id: all
uses: tj-actions/changed-files@v29.0.9
- name: Check if this file is changed
id: lint
uses: tj-actions/changed-files@v29.0.9
with:
files: ".github/workflows/lint.yml"

actionlint:
name: actionlint
runs-on: ubuntu-22.04
needs: changed
if: ${{ contains(needs.changed.outputs.files, '.github/workflows') }}
steps:
- uses: actions/checkout@v3.0.2
- name: Install Actionlint
env:
ACTIONLINT_VERSION: 1.6.18
run: |
wget -q -O- "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" | tar -x -z -C . actionlint && \
mv actionlint /usr/local/bin
- name: Run Actionlint
run: |
actionlint -format '{{range $err := .}}::error file={{$err.Filepath}},line={{$err.Line}},col={{$err.Column}}::{{$err.Message}}{{end}}' -ignore 'SC2016:' .github/workflows/*.yml
prettier:
name: prettier
runs-on: ubuntu-22.04
needs: changed
if: ${{ contains(needs.changed.outputs.files, '.md') || contains(needs.changed.outputs.files, '.yml') || needs.changed.outputs.self_changed }}
steps:
- uses: actions/checkout@v3.0.2
- uses: actions/setup-node@v3.4.1
with:
node-version: 18
- name: install prettier
run: npm install -g prettier
- name: run prettier
run: prettier -c .
shellcheck:
name: shellcheck
runs-on: ubuntu-22.04
needs: changed
if: ${{ contains(needs.changed.outputs.files, '.sh') || needs.changed.outputs.self_changed }}
env:
SHELLCHECK_VERSION: 0.8.0
steps:
- uses: actions/checkout@v3.0.2
- name: install shellcheck
run: |
wget -q -O - "https://github.com/koalaman/shellcheck/releases/download/v${{ env.SHELLCHECK_VERSION }}/shellcheck-v${{ env.SHELLCHECK_VERSION }}.linux.x86_64.tar.xz" | tar -x -J --strip-components=1 -C . shellcheck-v${{ env.SHELLCHECK_VERSION }}/shellcheck && \
sudo mv shellcheck /usr/local/bin/
- name: verify shell scripts
# shellcheck source path is assumed to be the "root" git directory
run: shellcheck hadolint.sh lib/*.sh test/*.sh
shfmt:
name: shfmt
runs-on: ubuntu-22.04
needs: changed
if: ${{ contains(needs.changed.outputs.files, '.sh') || needs.changed.outputs.self_changed }}
env:
SHFMT_VERSION: 3.5.1
steps:
- uses: actions/checkout@v3.0.2
- name: install shfmt
run: |
wget -q -O shfmt "https://github.com/mvdan/sh/releases/download/v${{ env.SHFMT_VERSION }}/shfmt_v${{ env.SHFMT_VERSION }}_linux_amd64" && \
chmod +x shfmt && \
sudo mv shfmt /usr/local/bin/
- name: lint shell scripts
run: shfmt -i 2 -d hadolint.sh lib/*.sh test/*.sh