Skip to content

General Checks

General Checks #11

# This is ci/actions-templates/centos-fmt-clippy.yaml
# Do not edit this file in .github/workflows
name: General Checks
on:
pull_request:
branches:
- "*"
push:
branches:
- master
- stable
- renovate/*
schedule:
- cron: "30 0 * * 1" # Every Monday at half past midnight
jobs:
check:
name: Checks
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Clone repo
uses: actions/checkout@v3
with:
# v2 defaults to a shallow checkout, but we need at least to the previous tag
fetch-depth: 0
- name: Acquire tags for the repo
run: |
git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/*
- name: Display the current git status
run: |
git status
git describe
- name: Prep cargo dirs
run: |
mkdir -p ~/.cargo/{registry,git}
- name: Set environment variables appropriately for the build
run: |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Cache cargo registry and git trees
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Get rustc commit hash
id: cargo-target-cache
run: |
echo "{rust_hash}={$(rustc -Vv | grep commit-hash | awk '{print $2}')}" >> $GITHUB_OUTPUT
shell: bash
- name: Cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ github.base_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rustup using ./rustup-init.sh
run: |
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y
- name: Ensure Beta is up to date
run: |
if rustc +beta -vV >/dev/null 2>/dev/null; then
rustup toolchain uninstall beta
fi
rustup toolchain install --profile=minimal beta
rustup default beta
- name: Ensure we have the components we need
run: |
rustup component add rustfmt
rustup component add clippy
- name: Run the centos check within the docker image
run: |
docker run \
--volume "$PWD":/checkout:ro \
--workdir /checkout \
--tty \
--init \
--rm \
centos:7 \
sh ./ci/raw_init.sh
- name: Run shell checks
run: |
shellcheck -x -s dash -- rustup-init.sh
git ls-files -- '*.sh' | xargs shellcheck -x -s dash
git ls-files -- '*.bash' | xargs shellcheck -x -s bash
- name: Run formatting checks
run: |
cargo fmt --all --check
- name: Run cargo check and clippy
run: |
cargo check --all --all-targets --features test
git ls-files -- '*.rs' | xargs touch
cargo clippy --all --all-targets --features test