Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/prek.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- run: curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | sudo bash
- uses: j178/prek-action@v3.0.0
34 changes: 24 additions & 10 deletions prek.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ exclude = { glob = [
"**/*.ps",
"**/*.ps-*",
"**/*.svg",
"**/COPYING",
"**/*expected*",
"**/COPYING",
"src/main/resources/specifications/jdk/*",
"src/test/resources/end-to-end/**/*",
"tests/kvasir-tests/povray/*",
] }

[[repos]]
Expand All @@ -36,9 +38,7 @@ hooks = [
] } },
{ id = "check-json" },
{ id = "check-merge-conflict" },
{ id = "check-shebang-scripts-are-executable", exclude = { glob = [
"tests/kvasir-tests/povray/source/**",
] } },
{ id = "check-shebang-scripts-are-executable" },
{ id = "check-symlinks", exclude = { glob = [
".subversion/auth",
"dots/.subversion/auth",
Expand All @@ -59,7 +59,6 @@ hooks = [
"**/tests/squeeze-blank-lines-test/**",
"bugs/jikes-patches/*",
"java/jtb/**",
"src/main/resources/specifications/jdk",
"tests/kvasir-tests/**",
] } },
{ id = "file-contents-sorter", files = { glob = [
Expand Down Expand Up @@ -87,6 +86,17 @@ hooks = [
] } },
]

## CircleCI

# This doesn't install the tool! It fails with "Circleci CLI could not be
# found." unless you have installed the CircleCI CLI. Using `snap` to install
# leads to permission problems due to snap confinement. To install:
# - run: curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | sudo bash
[[repos]]
repo = "https://github.com/zahorniak/pre-commit-circleci"
rev = "v1.3.0"
hooks = [{ id = "circleci_validate" }]
Comment on lines +91 to +98

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 4 \
  'circleci_validate|CIRCLECI|circleci config validate|prek run' \
  prek.toml .circleci/config.yml

Repository: plume-lib/run-google-java-format

Length of output: 970


🌐 Web query:

https://raw.githubusercontent.com/zahorniak/pre-commit-circleci/v1.3.0/circleci_validate.py

💡 Result:

The file circleci_validate.py from the zahorniak/pre-commit-circleci repository is a Python script that functions as a pre-commit git hook [1]. Its primary purpose is to automatically validate a CircleCI configuration file by invoking the circleci config validate command provided by the circleci-cli tool [1]. By including this hook in a project's .pre-commit-config.yaml file, developers ensure that their CircleCI configuration is checked for errors before changes are committed [1]. Key details include: - Functionality: It runs circleci config validate to ensure the configuration file is well-formed and valid according to CircleCI's requirements [1]. - Usage: It is configured within the .pre-commit-config.yaml file, allowing users to pass additional arguments (such as --org-slug) or specify custom configuration file paths [1]. - Prerequisites: This hook requires the official CircleCI CLI (circleci-cli) to be installed and available in the environment where pre-commit is running [1][2]. - Related Hooks: The repository also includes other hooks for CircleCI operations, such as circleci_process (to process configuration) and circleci_pack (to pack modular configurations) [1].

Citations:


🌐 Web query:

raw.githubusercontent.com/zahorniak/pre-commit-circleci/v1.3.0/circleci_validate.py "CIRCLECI" "sys.exit"

💡 Result:

The file circleci_validate.py in the zahorniak/pre-commit-circleci repository [1] is a Python script designed to act as a pre-commit hook for validating CircleCI configuration files [1]. When this script uses sys.exit() in the context of CIRCLECI environment detection or validation failure, it is implementing standard command-line interface (CLI) signaling [2][3][4]. Specifically: 1. Signaling Failure: If the validation process (typically via the circleci config validate command) fails, the script uses sys.exit(1) (or another non-zero exit code) to signal to the pre-commit framework that the hook has failed [5][1][4]. 2. Blocking Commits: Because the pre-commit framework monitors the exit code of its hooks, a sys.exit(1) call causes the pre-commit tool to halt the Git commit process, preventing invalid or misconfigured CircleCI configuration files from being committed to the repository [5][1][6]. 3. Execution Environment: The script relies on the official CircleCI CLI being installed on the local system to perform the actual validation [5][1]. It functions by wrapping the circleci config validate command and propagating that command's exit status through its own sys.exit() call [1]. In general Python CLI script usage, sys.exit(0) indicates successful execution, while any non-zero value (commonly 1) is used to indicate an error or validation failure [7][2][8][4]. Top results: [5][1]

Citations:


🌐 Web query:

site:raw.githubusercontent.com/zahorniak/pre-commit-circleci/v1.3.0/circleci_validate.py "CIRCLECI"

💡 Result:

The file checks the CIRCLECI environment variable:

if os.getenv("CIRCLECI"):
    print("Circleci environment detected, skipping validation.")
    sys.exit(0)

When CIRCLECI is set, validation is skipped. [1]


Run circleci validation outside the circleci_validate pre-commit hook.

Pre-commit is configured to run prek run -q --all-files in CircleCI, while this hook exits successfully when CIRCLECI is set and skips circleci config validate. Add an explicit circleci config validate step after installing the CircleCI CLI, or document that this hook is local-only.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@prek.toml` around lines 91 - 98, Update the CircleCI workflow so validation
runs independently of the `circleci_validate` hook: after installing the
CircleCI CLI, add an explicit `circleci config validate` step. Do not rely on
the pre-commit hook, which skips validation when `CIRCLECI` is set.

Source: MCP tools


## GitHub Actions

[[repos]]
Expand All @@ -105,6 +115,8 @@ hooks = [
"**/pubs-bytopic-headfoot.html",
"**/pubs-bytopic-underreview-headfoot.html",
"google04aaa4eb05fd668b.html",
"pubs/*-abstract.html",
"pubs/index.html",
"tests/sources/six170/huffman.html",
"tools/hierarchical/clustering.html",
] } },
Expand All @@ -117,13 +129,16 @@ hooks = [
[[repos]]
repo = "local"
hooks = [
{ id = "gradle-spotless", name = "spotless formatting", language = "unsupported", entry = "bash -c 'if [ -f ./gradlew ] ; then ./gradlew spotlessApply; fi'", files = "\\.java$", pass_filenames = false },
{ id = "gradle-spotless", name = "spotless formatting", language = "unsupported", entry = "bash -c 'if [ -f ./gradlew ] ; then ./gradlew spotlessApply; fi'", files = { glob = [
"**/*.java",
"**/*.gradle.kts",
] }, pass_filenames = false },
]

## Makefiles

[[repos]]
repo = "https://github.com/checkmake/checkmake.git"
repo = "https://github.com/checkmake/checkmake"
rev = "0.2.2"
hooks = [
{ id = "checkmake", args = [
Expand Down Expand Up @@ -214,7 +229,6 @@ hooks = [
"tests/kvasir-tests/tot_info/tests.sh",
"cronic-orig",
"classfile_check_version",
"tests/kvasir-tests/povray/**/*",
] } },
]

Expand Down Expand Up @@ -321,6 +335,6 @@ hooks = [
]

[[repos]]
repo = "https://github.com/adrienverge/yamllint.git"
rev = "v1.29.0"
repo = "https://github.com/adrienverge/yamllint"
rev = "v1.38.0"
hooks = [{ id = "yamllint" }]