Skip to content

Add yaml, md, and toml linters to pre-commit config and also update it #342

Add yaml, md, and toml linters to pre-commit config and also update it

Add yaml, md, and toml linters to pre-commit config and also update it #342

Workflow file for this run

---
name: Rust CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Check format
run: cargo fmt --check
yara:
needs: lint
strategy:
fail-fast: true
matrix:
runs-on:
- ubuntu-22.04
uses: ./.github/workflows/yara.yaml
with:
runs-on: ${{ matrix.runs-on }}
yara-output:
needs: yara
runs-on: ubuntu-22.04
steps:
- name: Read Matrix Output
id: read
uses: cloudposse/github-action-matrix-outputs-read@main
with:
matrix-step-name: yara
outputs:
result: ${{ steps.read.outputs.result }}
clippy:
needs: yara
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Download YARA
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: ${{ needs.yara.outputs.artifacts }}
path: .yara
- name: Cache dependencies
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
key: x86_64-unknown-linux-gnu
- name: Run Clippy
run: >
cargo clippy -- \
-D clippy::all \
-D clippy::cargo \
-D clippy::pedantic \
-A clippy::cargo_common_metadata \
-A clippy::multiple_crate_versions
env:
YARA_INCLUDE_DIR: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.include-dir }}
YARA_LIBRARY_PATH: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.library-path }}
test:
needs:
- yara
- yara-output
strategy:
matrix:
triple:
- runs-on: ubuntu-22.04
target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.triple.runs-on }}
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Download YARA
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: ${{ fromJson(needs.yara-output.outputs.result).artifacts[matrix.triple.runs-on] }}
path: .yara
- name: Cache dependencies
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
key: ${{ matrix.triple.target }}
- name: Run tests
env:
RUST_BACKTRACE: full
YARA_INCLUDE_DIR: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.include-dir }}
YARA_LIBRARY_PATH: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.library-path }}
run: cargo test --no-fail-fast
docs-build:
needs:
- yara
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Cache dependencies
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
key: x86_64-unknown-linux-gnu
- name: Download YARA
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: ${{ needs.yara.outputs.artifacts }}
path: .yara
- name: Build docs with cargo
run: cargo doc --no-deps --document-private-items
env:
YARA_INCLUDE_DIR: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.include-dir }}
YARA_LIBRARY_PATH: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.library-path }}
# `.lock` is set to to rw-------, which causes actions/deploy-pages to fail
# because it's expecting all files to be at least rw-r--r--
- name: Remove '.lock' file
run: rm ./target/doc/.lock
# `cargo doc` builds the docs without a top level `index.html`, so add
# a barebones one to redirect to the generated one.
- name: Add redirect index.html
run: echo '<meta http-equiv="refresh" content="0; url=dragonfly_client_rs">' > target/doc/index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: ./target/doc
docs-deploy:
needs: docs-build
if: github.ref == 'refs/heads/main'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
steps:
- name: Deploy docs to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5