Check GitHub Actions workflow with actionlint (#921)

This commit is contained in:
Casey Rodarmor 2021-07-26 17:14:20 -07:00 committed by GitHub
parent 1b0fafea75
commit 4ada364ede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 20 deletions

View File

@ -47,13 +47,22 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Download actionlint
id: actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
- name: Check Github Actions Workflow
env:
SHELLCHECK_OPTS: "-e SC2006 -e SC2002 -e SC2050"
run: ${{ steps.actionlint.outputs.executable }} -color
# An issue with BSD Tar causes sporadic failures on macOS. # An issue with BSD Tar causes sporadic failures on macOS.
# c.f https://github.com/actions/cache/issues/403 # c.f https://github.com/actions/cache/issues/403
- name: Install GNU Tar - name: Install GNU Tar
if: matrix.os == 'macos-latest' if: ${{ matrix.os == 'macos-latest' }}
run: | run: |
brew install gnu-tar brew install gnu-tar
echo /usr/local/opt/gnu-tar/libexec/gnubin > $GITHUB_PATH echo /usr/local/opt/gnu-tar/libexec/gnubin > "$GITHUB_PATH"
- name: Cache Cargo - name: Cache Cargo
uses: actions/cache@v2 uses: actions/cache@v2
@ -62,10 +71,10 @@ jobs:
~/.cargo/registry ~/.cargo/registry
~/.cargo/git ~/.cargo/git
target target
key: ${{ matrix.configration.os }}-${{ matrix.target }} cargo-${{ hashFiles('**/Cargo.lock') }} key: ${{ matrix.os }}-${{ matrix.target }} cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Update Ubuntu Packages - name: Update Ubuntu Packages
if: matrix.os == 'ubuntu-latest' if: ${{ matrix.os == 'ubuntu-latest' }}
run: | run: |
sudo apt-get update sudo apt-get update
@ -73,10 +82,10 @@ jobs:
run: | run: |
rustup component add clippy rustup component add clippy
rustup target add ${{ matrix.target }} rustup target add ${{ matrix.target }}
rustup default `cat rust-toolchain`-${{ matrix.target }} rustup default "`cat rust-toolchain`-${{ matrix.target }}"
- name: Install AArch64 Toolchain - name: Install AArch64 Toolchain
if: matrix.target == 'aarch64-unknown-linux-gnu' if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: sudo apt-get install gcc-aarch64-linux-gnu run: sudo apt-get install gcc-aarch64-linux-gnu
- name: Info - name: Info
@ -93,7 +102,7 @@ jobs:
run: cargo build --all --target ${{ matrix.target }} run: cargo build --all --target ${{ matrix.target }}
- name: Test - name: Test
if: matrix.native if: ${{ matrix.native }}
run: cargo test --all --target ${{ matrix.target }} run: cargo test --all --target ${{ matrix.target }}
- name: Clippy - name: Clippy
@ -111,13 +120,13 @@ jobs:
run: cargo +nightly fmt --all -- --check run: cargo +nightly fmt --all -- --check
- name: Completion Scripts - name: Completion Scripts
if: matrix.os != 'windows-2016' if: ${{ matrix.os != 'windows-2016' }}
run: | run: |
./bin/generate-completions ./bin/generate-completions
git diff --no-ext-diff --quiet --exit-code git diff --no-ext-diff --quiet --exit-code
- name: Check for Forbidden Words - name: Check for Forbidden Words
if: matrix.os == 'ubuntu-latest' if: ${{ matrix.os == 'ubuntu-latest' }}
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install ripgrep sudo apt-get install ripgrep
@ -128,30 +137,30 @@ jobs:
run: cargo run --package ref-type -- --reference ${{ github.ref }} run: cargo run --package ref-type -- --reference ${{ github.ref }}
- name: Test Install Script With Explicit Target - name: Test Install Script With Explicit Target
if: matrix.os != 'windows-2016' && steps.ref-type.outputs.value != 'release' if: ${{ matrix.os != 'windows-2016' && steps.ref-type.outputs.value != 'release' }}
run: | run: |
cd `mktemp -d` cd "`mktemp -d`"
cat $GITHUB_WORKSPACE/docs/install.sh | bash -s -- --target ${{ matrix.target }} --to . cat "$GITHUB_WORKSPACE/docs/install.sh" | bash -s -- --target ${{ matrix.target }} --to .
if [[ ${{ matrix.native }} == true ]]; then if [[ ${{ matrix.native }} == true ]]; then
./just --version ./just --version
fi fi
- name: Test Install Script Without Explicit Target - name: Test Install Script Without Explicit Target
if: matrix.os != 'windows-2016' && steps.ref-type.outputs.value != 'release' if: ${{ matrix.os != 'windows-2016' && steps.ref-type.outputs.value != 'release' }}
run: | run: |
cd `mktemp -d` cd "`mktemp -d`"
cat $GITHUB_WORKSPACE/docs/install.sh | bash -s -- --to . cat "$GITHUB_WORKSPACE/docs/install.sh" | bash -s -- --to .
./just --version ./just --version
- name: Package - name: Package
id: package id: package
if: startsWith(github.ref, 'refs/tags/') if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{ matrix.target }} run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{ matrix.target }}
shell: bash shell: bash
- name: Publish Archive - name: Publish Archive
uses: softprops/action-gh-release@v0.1.5 uses: softprops/action-gh-release@v0.1.5
if: startsWith(github.ref, 'refs/tags/') if: ${{ startsWith(github.ref, 'refs/tags/') }}
with: with:
draft: false draft: false
files: ${{ steps.package.outputs.archive }} files: ${{ steps.package.outputs.archive }}
@ -161,7 +170,11 @@ jobs:
- name: Publish Changelog - name: Publish Changelog
uses: softprops/action-gh-release@v0.1.5 uses: softprops/action-gh-release@v0.1.5
if: startsWith(github.ref, 'refs/tags/') && matrix.target == 'x86_64-unknown-linux-musl' if: >-
${{
startsWith(github.ref, 'refs/tags/')
&& matrix.target == 'x86_64-unknown-linux-musl'
}}
with: with:
draft: false draft: false
files: CHANGELOG.md files: CHANGELOG.md

View File

@ -61,7 +61,7 @@ version := `sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.tom
changes: changes:
git log --pretty=format:%s >> CHANGELOG.md git log --pretty=format:%s >> CHANGELOG.md
check: clippy fmt test forbid check: actionlint fmt clippy test forbid
git diff --no-ext-diff --quiet --exit-code git diff --no-ext-diff --quiet --exit-code
grep '^\[{{ version }}\]' CHANGELOG.md grep '^\[{{ version }}\]' CHANGELOG.md
cargo +nightly generate-lockfile -Z minimal-versions cargo +nightly generate-lockfile -Z minimal-versions
@ -108,7 +108,11 @@ install-dev-deps:
# install system development dependencies with homebrew # install system development dependencies with homebrew
install-dev-deps-homebrew: install-dev-deps-homebrew:
brew install help2man brew tap "rhysd/actionlint" "https://github.com/rhysd/actionlint"
brew install actionlint help2man shellcheck
actionlint:
SHELLCHECK_OPTS='-e SC2006 -e SC2002 -e SC2050' actionlint
# everyone's favorite animate paper clip # everyone's favorite animate paper clip
clippy: clippy: