forked from litmuschaos/litmusctl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pre commit Hook added. (litmuschaos#203)
* Added Workflow script. Signed-off-by: Aryan <[email protected]> * Added pre commit script. Signed-off-by: Aryan <[email protected]> * Modified build with pre-commit hook. Signed-off-by: Aryan <[email protected]> * Removed check. Signed-off-by: Aryan Bhokare <[email protected]> * Added pre-commit prerequisite. Signed-off-by: Aryan Bhokare <[email protected]> --------- Signed-off-by: Aryan <[email protected]> Signed-off-by: Aryan Bhokare <[email protected]>
- Loading branch information
1 parent
9fe2a37
commit 95fad15
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Extract steps containing special env variable COMMIT_HOOKS from Github workflow""" | ||
import yaml | ||
import argparse | ||
|
||
# Parse command-line arguments | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("workflow_file", | ||
help="Path to the GitHub Actions workflow file") | ||
|
||
args = parser.parse_args() | ||
|
||
# Load the GitHub Actions workflow file as YAML | ||
with open(args.workflow_file, "r") as file: | ||
data = yaml.safe_load(file) | ||
|
||
print("#!/bin/bash") | ||
# Loop over all jobs | ||
for job_name, job in data["jobs"].items(): | ||
# Loop over all steps in the job | ||
for step in job["steps"]: | ||
# Check if the step has a KCIDB_HOOKS environment variable | ||
if "env" in step and step["env"].get("COMMIT_HOOKS") == "pre-commit": | ||
# Print the name of the step | ||
print(f"\n# {step['name']}") | ||
# Extract the command(s) from the step | ||
command = step.get("run", []) | ||
# Print the command(s) | ||
for line in command if isinstance(command, list) else [command]: | ||
print(line) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# If there are whitespace errors, print the offending file names and fail. | ||
# git diff-index --check --cached $against -- | ||
|
||
# Execute steps extracted from GitHub Actions | ||
. <(./.github-workflow-script .github/workflows/build.yml) |
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
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