diff --git a/.github/workflows/lint-actionlint.yml b/.github/workflows/lint-actionlint.yml deleted file mode 100644 index 48d066f..0000000 --- a/.github/workflows/lint-actionlint.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: lint -on: - pull_request: - paths: - - ".github/workflows/*.yml" - -jobs: - actionlint: - name: actionlint - runs-on: ubuntu-22.04 - 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 diff --git a/.github/workflows/lint-prettier.yml b/.github/workflows/lint-prettier.yml deleted file mode 100644 index 457c840..0000000 --- a/.github/workflows/lint-prettier.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: lint -on: - pull_request: - paths: - - "**.md" - - "**.yml" - -jobs: - prettier: - runs-on: ubuntu-22.04 - name: prettier - 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 . diff --git a/.github/workflows/lint-shellcheck.yml b/.github/workflows/lint-shellcheck.yml deleted file mode 100644 index db6620e..0000000 --- a/.github/workflows/lint-shellcheck.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: lint -on: - pull_request: - paths: - - "**.sh" - - .github/workflows/lint-shellcheck.yml - -jobs: - shellcheck: - runs-on: ubuntu-22.04 - name: shellcheck - 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 diff --git a/.github/workflows/lint-shfmt.yml b/.github/workflows/lint-shfmt.yml deleted file mode 100644 index 3ea5d83..0000000 --- a/.github/workflows/lint-shfmt.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: lint -on: - pull_request: - paths: - - "**.sh" - - .github/workflows/lint-shfmt.yml - -jobs: - shfmt: - runs-on: ubuntu-22.04 - name: shfmt - 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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..2e255a5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -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