Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ran `pre-commit` on all files
4398e580de062e7d273f162bd14d16c1cbe5b464
18 changes: 10 additions & 8 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
---
version: 2

updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: "monthly"
interval: monthly
groups:
ci-dependencies:
patterns:
- "*"
- '*'

- package-ecosystem: "cargo"
directory: "/"
- package-ecosystem: cargo
directory: /
schedule:
interval: "monthly"
interval: monthly
groups:
rust-dependencies:
patterns:
- "*"
- '*'
19 changes: 12 additions & 7 deletions .github/workflows/container-build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ name: Container Build and Push

on:
push:
branches: [main]
tags: [v*]
branches:
- main
tags:
- v*
pull_request:

permissions:
Expand All @@ -30,7 +32,8 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [linux/amd64]
platform:
- linux/amd64

runs-on: ubuntu-22.04
steps:
Expand Down Expand Up @@ -138,7 +141,8 @@ jobs:

merge:
if: ${{ github.ref == 'refs/heads/main' || startswith(github.event.ref, 'refs/tags/v') }}
needs: [build-push]
needs:
- build-push

runs-on: ubuntu-22.04
steps:
Expand Down Expand Up @@ -173,12 +177,13 @@ jobs:
- name: Create manifest list and push
shell: bash
working-directory: /tmp/digests
run: |
run: >
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "${DOCKER_METADATA_OUTPUT_JSON}") \
$(printf ' ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)

- name: Inspect image
shell: bash
run: |-
docker buildx imagetools inspect '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }}'
run: >-
docker buildx imagetools inspect \
'${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }}'
18 changes: 11 additions & 7 deletions .github/workflows/rust-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Rust CI

on:
Expand Down Expand Up @@ -79,7 +80,9 @@ jobs:
YARA_LIBRARY_PATH: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.library-path }}

test:
needs: [yara, yara-output]
needs:
- yara
- yara-output

strategy:
matrix:
Expand Down Expand Up @@ -111,11 +114,12 @@ jobs:
run: cargo test --no-fail-fast

docs-build:
needs: [yara]
needs:
- yara
runs-on: ubuntu-22.04

steps:
- name: "Checkout repository"
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Cache dependencies
Expand All @@ -129,23 +133,23 @@ jobs:
name: ${{ needs.yara.outputs.artifacts }}
path: .yara

- name: "Build docs with cargo"
- 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"
- 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"
- name: Add redirect index.html
run: echo '<meta http-equiv="refresh" content="0; url=dragonfly_client_rs">' > target/doc/index.html

- name: "Upload artifact"
- name: Upload artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: ./target/doc
Expand Down
5 changes: 5 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
MD013:
line_length: 120

MD024: false
115 changes: 109 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,111 @@
---
default_language_version:
python: python3
node: system

repos:
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
- repo: meta
hooks:
- id: fmt
- id: cargo-check
- id: clippy
args: ["--", "-D", "clippy:all", "-D", "clippy::pedantic", "-D", "clippy::cargo", "-A", "clippy::cargo_common_metadata", "-A", "clippy::multiple_crate_versions"]
- id: check-hooks-apply
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
args:
- --markdown-linebreak-ext=md
exclude: \.gitignore

- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt
description: Format Rust files
language: system
entry: cargo fmt
types:
- rust
pass_filenames: false

- id: cargo-check
name: cargo check
description: Check Rust files
language: system
entry: cargo check
types:
- rust
pass_filenames: false

- id: cargo-clippy
name: cargo clippy
description: Lint Rust files using Clippy
language: system
entry: cargo clippy
args:
- --
- -D
- clippy::all
- -D
- clippy::cargo
- -D
- clippy::pedantic
- -A
- clippy::cargo_common_metadata
- -A
- clippy::multiple_crate_versions
types:
- rust
pass_filenames: false

- repo: https://github.com/hadolint/hadolint
rev: 80e0d3d0c58dcdcbced97854ab7c5cf00a5f1a86 # frozen: v2.13.0-beta
hooks:
- id: hadolint
args:
- --failure-threshold
- error

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: e2dde74d0702d15f4f43e4f4fb93e301b4bc1e30 # frozen: 0.29.1
hooks:
- id: check-github-workflows

- repo: https://github.com/lyz-code/yamlfix
rev: 47039c9bf8039e81f092c9777a1bc8be32fb7870 # frozen: 1.16.0
hooks:
- id: yamlfix
args:
- --config-file
- .yamlfix.toml

- repo: https://github.com/adrienverge/yamllint
rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # frozen: v1.35.1
hooks:
- id: yamllint
args:
- --strict

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: f295829140d25717bc79368d3f966fc1f67a824f # frozen: v0.41.0
hooks:
- id: markdownlint-fix

- repo: https://github.com/ComPWA/mirrors-taplo
rev: 4ef242b660e0f7c7c953b9d8289e302c3f49bfbc # frozen: v0.8.1
hooks:
- id: taplo

- repo: https://github.com/sirwart/ripsecrets
rev: 033ec5192b738b6712701be920cba545c2775050 # frozen: v0.1.8
hooks:
- id: ripsecrets

- repo: https://github.com/crate-ci/typos
rev: cc99b94246254c1b3dfa6ea6111aa212b814a486 # frozen: v1.23.6
hooks:
- id: typos
args: []
4 changes: 4 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[formatting]
column_width = 120
compact_inline_tables = true
indent_tables = true
4 changes: 4 additions & 0 deletions .yamlfix.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
line_length = 120
section_whitelines = 1
sequence_style = 'block_style'
whitelines = 1
15 changes: 15 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
extends: default

ignore-from-file:
- .git/info/exclude
- .gitignore

rules:
line-length:
max: 120
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true

truthy:
check-keys: false
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ edition = "2021"
[dependencies]
chrono = "0.4.38"
color-eyre = "0.6.3"
figment = { version = "0.10.19", features = ["env", "toml"] }
figment = {version = "0.10.19", features = ["env", "toml"]}
flate2 = "1.0.30"
log = "0.4.21"
once_cell = "1.19.0"
parking_lot = "0.12.3"
reqwest = { version = "0.12.4", features = ["blocking", "json", "gzip"] }
serde = { version = "1.0.203", features = ["derive"] }
reqwest = {version = "0.12.4", features = ["blocking", "json", "gzip"]}
serde = {version = "1.0.203", features = ["derive"]}
serde_json = "1.0.121"
tar = "0.4.40"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-subscriber = {version = "0.3.18", features = ["env-filter"]}
yara = "0.27.0"
yara-sys = { version = "0.27.0", features = ["yara-static"] }
yara-sys = {version = "0.27.0", features = ["yara-static"]}
zip = "2.1.6"

[profile.release]
Expand Down
Loading
Loading