From 5bf4dc13e3eac5d5049afe5f8b1f76b85ac7a3c2 Mon Sep 17 00:00:00 2001 From: Techassi Date: Wed, 4 Sep 2024 15:53:05 +0200 Subject: [PATCH] ci: Replace reviewdog with pre-commit --- .github/workflows/pr_pre-commit.yml | 27 ++++++++++++++ .github/workflows/pr_reviewdog.yml | 55 ----------------------------- .pre-commit-config.yaml | 37 ++++++++++--------- 3 files changed, 48 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/pr_pre-commit.yml delete mode 100644 .github/workflows/pr_reviewdog.yml diff --git a/.github/workflows/pr_pre-commit.yml b/.github/workflows/pr_pre-commit.yml new file mode 100644 index 00000000..a5436bd9 --- /dev/null +++ b/.github/workflows/pr_pre-commit.yml @@ -0,0 +1,27 @@ +--- +name: pre-commit + +on: + pull_request: + +env: + CARGO_TERM_COLOR: always + RUST_TOOLCHAIN_VERSION: "1.80.1" + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: '3.12' + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} + components: rustfmt,clippy + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 + with: + extra_args: "--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}" diff --git a/.github/workflows/pr_reviewdog.yml b/.github/workflows/pr_reviewdog.yml deleted file mode 100644 index c4d70776..00000000 --- a/.github/workflows/pr_reviewdog.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- -name: Pull Request Reviewdog - -on: workflow_call - -permissions: - contents: read - checks: write - pull-requests: write - issues: write - -jobs: - actionlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - uses: reviewdog/action-actionlint@89a03f6ba8c0a9fd238e82c075ffb34b86e40291 # v1.46.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - flake8: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 - with: - python-version: "3.11" - - uses: reviewdog/action-flake8@51c2708ac3e9463b4d27d0ba7d9e3ded608a6ad3 # v3.8.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - markdownlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - uses: reviewdog/action-markdownlint@5bc6ad5ba9e1250878f351bafcc7ac0a11dc050f # v0.18.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - markdownlint_flags: "-i README.md ." - - shellcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - uses: reviewdog/action-shellcheck@72365a51bf6476fe952a117c3ff703eb7775e40a # v1.20.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - yamllint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - uses: reviewdog/action-yamllint@8d79c3d034667db2792e328936811ed44953d691 # v1.14.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8bf3fab3..a8bc9c36 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,8 @@ --- -# See https://pre-commit.com for more information fail_fast: true -# See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # 4.6.0 hooks: - id: trailing-whitespace # Generated file @@ -16,7 +14,7 @@ repos: - id: detect-private-key - repo: https://github.com/doublify/pre-commit-rust - rev: v1.0 + rev: eeee35a89e69d5772bdee97db1a6a898467b686e # 1.0 hooks: - id: fmt args: ["--all", "--", "--check"] @@ -24,28 +22,30 @@ repos: args: ["--all-targets", "--", "-D", "warnings"] - repo: https://github.com/adrienverge/yamllint - rev: v1.26.3 + rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # 1.35.1 hooks: - id: yamllint - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.31.1 + rev: f295829140d25717bc79368d3f966fc1f67a824f # 0.41.0 hooks: - id: markdownlint - - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + - repo: https://github.com/koalaman/shellcheck-precommit + rev: 2491238703a5d3415bb2b7ff11388bf775372f29 # 0.10.0 hooks: - - id: flake8 + - id: shellcheck + args: ["--severity=info"] - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.7.1 + - repo: https://github.com/rhysd/actionlint + rev: 62dc61a45fc95efe8c800af7a557ab0b9165d63b # 1.7.1 hooks: - - id: prettier - files: ^web/ - additional_dependencies: - # This should match prettier devDependency in web/package.json - - prettier@2.8.8 + - id: actionlint + + - repo: https://github.com/hadolint/hadolint + rev: b3555ba9c2bfd9401e79f2f0da68dd1ae38e10c7 # 2.12.0 + hooks: + - id: hadolint - repo: local hooks: @@ -56,6 +56,7 @@ repos: entry: cargo xtask gen-man stages: [commit, merge-commit, manual] pass_filenames: false + - id: gen-comp name: gen-comp files: ^rust/stackablectl/ @@ -63,6 +64,7 @@ repos: entry: cargo xtask gen-comp stages: [commit, merge-commit, manual] pass_filenames: false + - id: gen-openapi name: gen-openapi files: ^web/ @@ -70,6 +72,7 @@ repos: entry: cargo xtask gen-openapi stages: [commit, merge-commit, manual] pass_filenames: false + - id: gen-ctl-readme name: gen-ctl-readme files: ^rust/stackablectl/ @@ -77,6 +80,7 @@ repos: entry: cargo xtask gen-ctl-readme stages: [commit, merge-commit, manual] pass_filenames: false + - id: gen-docs name: gen-docs files: ^rust/stackablectl/ @@ -84,6 +88,7 @@ repos: entry: cargo xtask gen-docs stages: [commit, merge-commit, manual] pass_filenames: false + - id: gen-cargo-nix name: gen-cargo-nix files: ^Cargo\.lock|go\.mod$