feat: add code ci #2
Workflow file for this run
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
name: Lint and Test Code | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- src/** | |
- .github/workflows/ci-code.yaml | |
jobs: | |
rustfmt: | |
name: rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- name: harden runner | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- name: checkout repository | |
uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 # v4.2.0 | |
with: | |
submodules: recursive | |
persist-credentials: false | |
- name: 'Install stable rust toolchain with rustfmt' | |
run: | | |
rustup update --no-self-update stable | |
rustup default stable | |
rustup component add rustfmt | |
- name: 'cargo fmt' | |
run: cargo fmt --all -- --check | |
shfmt: | |
name: shfmt | |
runs-on: ubuntu-latest | |
steps: | |
- name: harden runner | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- name: checkout repository | |
uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 # v4.2.0 | |
with: | |
submodules: recursive | |
persist-credentials: false | |
- name: shfmt | |
run: | | |
GOBIN=/usr/local/bin go install mvdan.cc/sh/v3/cmd/shfmt@latest | |
if ! ./hack/code/shfmt.sh; then | |
echo "" | |
echo "Please run \`PROTECT_SHFMT_WRITE=true ./hack/code/shfmt.sh\`" | |
fi | |
shellcheck: | |
name: shellcheck | |
runs-on: ubuntu-latest | |
steps: | |
- name: harden runner | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- name: checkout repository | |
uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 # v4.2.0 | |
with: | |
submodules: recursive | |
persist-credentials: false | |
- name: shellcheck | |
run: ./hack/code/shellcheck.sh | |
full-build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- x86_64 | |
env: | |
TARGET_ARCH: "${{ matrix.arch }}" | |
name: 'Full build linux-${{ matrix.arch }}' | |
steps: | |
- name: harden runner | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- name: checkout repository | |
uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 # v4.2.0 | |
with: | |
submodules: recursive | |
persist-credentials: false | |
- name: 'Install stable rust toolchain' | |
run: | | |
rustup update --no-self-update stable | |
rustup default stable | |
- name: cargo build | |
run: cargo build | |
full-test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- x86_64 | |
env: | |
TARGET_ARCH: "${{ matrix.arch }}" | |
name: 'Full test linux-${{ matrix.arch }}' | |
steps: | |
- name: harden runner | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- name: checkout repository | |
uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 # v4.2.0 | |
with: | |
submodules: recursive | |
persist-credentials: false | |
- name: 'Install stable rust toolchain' | |
run: | | |
rustup update --no-self-update stable | |
rustup default stable | |
- name: 'cargo test' | |
run: cargo test | |
full-clippy: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: | |
- x86_64 | |
env: | |
TARGET_ARCH: "${{ matrix.arch }}" | |
name: 'Full clippy linux-${{ matrix.arch }}' | |
steps: | |
- name: harden runner | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- name: checkout repository | |
uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 # v4.2.0 | |
with: | |
submodules: recursive | |
persist-credentials: false | |
- name: 'Install stable rust toolchain with clippy' | |
run: | | |
rustup update --no-self-update stable | |
rustup default stable | |
rustup component add clippy | |
- name: 'cargo clippy' | |
run: cargo clippy |