Skip to content

Commit

Permalink
chore: Remove jbang. It falls apart randomly during dependency resolu…
Browse files Browse the repository at this point in the history
…tion (#5754)
  • Loading branch information
I-Al-Istannen committed Apr 15, 2024
1 parent bdc6b99 commit ca107db
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 39 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ jobs:

- name: Time nix setup
run: nix develop ${{ env.NIX_OPTIONS }} .#extraChecks --command true
- name: Build spoon
run: nix develop ${{ env.NIX_OPTIONS }} .#extraChecks --command mvn -f spoon-pom -B install -Dmaven.test.skip=true -DskipDepClean
- name: Run Javadoc quality check
run: nix develop ${{ env.NIX_OPTIONS }} .#extraChecks --command ci-javadoc-quality
run: nix develop ${{ env.NIX_OPTIONS }} .#extraChecks --command javadoc-quality

reproducible-builds:
runs-on: ubuntu-latest
Expand Down
41 changes: 22 additions & 19 deletions chore/check-javadoc-regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,25 @@ def print_quality_check_not_parseable_error():
)


def run_quality_check(config_path: Path, target_branch: Optional[str] = None) -> str:
def run_quality_check(target_branch: Optional[str] = None) -> str:
"""
Runs the quality check and returns the output as a decoded string.
Optionally you can pass a branch to borrow the quality check from, if
it does not exist locally.
"""
check_path = Path("chore/CheckJavadoc.java")
runner_helper = Path("chore/run-with-spoon-javadoc-classpath.sh")

if target_branch:
print(warn(f"Borrowing quality script from '{target_branch}'"))
run_command(["git", "checkout", target_branch, "--", str(check_path)])

if not runner_helper.exists():
print(warn(f"Borrowing runner script from '{target_branch}'"))
run_command(["git", "checkout", target_branch, "--", str(runner_helper)])

return run_command([
"jbang",
"--verbose",
str(runner_helper),
str(check_path)
])

Expand Down Expand Up @@ -176,17 +181,16 @@ def command_compare_with_branch(target_branch: str) -> None:
# Switch to the root, so the quality check will run against the whole project
os.chdir(run_command(["git", "rev-parse", "--show-toplevel"]).strip())

with temporary_path(suffix=".xml") as config_path:
original_branch = run_command(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip()
if original_branch == "HEAD":
original_branch = run_command(["git", "rev-parse", "HEAD"]).strip()
run_command(["git", "checkout", target_branch], stderr=PIPE)
reference_output = run_quality_check(config_path, original_branch)
original_branch = run_command(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip()
if original_branch == "HEAD":
original_branch = run_command(["git", "rev-parse", "HEAD"]).strip()
run_command(["git", "checkout", target_branch], stderr=PIPE)
reference_output = run_quality_check(original_branch)

run_command(["git", "checkout", original_branch], stderr=PIPE)
other_output = run_quality_check(config_path)
run_command(["git", "checkout", original_branch], stderr=PIPE)
other_output = run_quality_check()

handle_compare_with_branch_output(target_branch, reference_output, other_output)
handle_compare_with_branch_output(target_branch, reference_output, other_output)


def handle_compare_with_branch_output(target_branch: str, reference_output: str, other_output: str):
Expand Down Expand Up @@ -236,15 +240,14 @@ def command_filtered_quality_check_errors(regex_str: str) -> None:
Runs the quality check in the current working directory and filters the output using the passed regex.
"""
regex: Pattern = re.compile(regex_str)
with temporary_path(suffix=".xml") as config_path:
quality_check_output = run_quality_check(config_path)
quality_check_output = run_quality_check()

for line in quality_check_output.splitlines():
if regex.search(line):
print(line)
for line in quality_check_output.splitlines():
if regex.search(line):
print(line)

if extract_violation_count(quality_check_output) is None:
print_quality_check_not_parseable_error()
if extract_violation_count(quality_check_output) is None:
print_quality_check_not_parseable_error()


def fix_colors_windows_cmd():
Expand Down
20 changes: 20 additions & 0 deletions chore/run-with-spoon-javadoc-classpath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# If anything fails we are done for
set -eu

# Our dependencies
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
export CLASSPATH="$(cd "$SCRIPT_DIR/../spoon-javadoc" && mvn dependency:build-classpath -Dmdep.outputFile="/dev/stderr" 2>&1 > /dev/null)"

# Ourselves
LOCAL_REPO="$(mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout)"
SPOON_VERSION="$(cd "$SCRIPT_DIR/../spoon-javadoc" && mvn help:evaluate -Dexpression=project.parent.version -q -DforceStdout)"
export CLASSPATH="$CLASSPATH:$LOCAL_REPO/fr/inria/gforge/spoon/spoon-javadoc/$SPOON_VERSION/spoon-javadoc-$SPOON_VERSION.jar"

# A simple logger to disable the warning
mvn dependency:get -Dartifact=org.slf4j:slf4j-nop:1.7.36
export CLASSPATH="$CLASSPATH:$LOCAL_REPO/org/slf4j/slf4j-nop/1.7.36/slf4j-nop-1.7.36.jar"

# Delegate
java "$@"
20 changes: 1 addition & 19 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -168,24 +168,6 @@
chore/check-reproducible-builds.sh
'';
ciJavadocQuality = pkgs.writeScriptBin "ci-javadoc-quality" ''
set -eu
# Help jbang. Build locally and update the version. Otherwise it fails to resolve sometimes.
pushd spoon-pom || exit 1
mvn clean install -Dmaven.test.skip=true -DskipDepClean &>/dev/null
popd || exit 2
# Use concrete version
sed -i "s/:RELEASE/:$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)/" chore/CheckJavadoc.java
git add chore/CheckJavadoc.java
git config user.email "jbang-fixup@example.com"
git config user.name "Jbang fixup"
git commit -m "Fixup version"
# Delegate
javadoc-quality
'';
javadocQuality = pkgs.writeScriptBin "javadoc-quality" ''
set -eu
Expand All @@ -200,7 +182,7 @@
])
else [ ];
packages = with pkgs;
[ jdk maven test codegen coverage mavenPomQuality javadocQuality ciJavadocQuality reproducibleBuilds ]
[ jdk maven test codegen coverage mavenPomQuality javadocQuality reproducibleBuilds ]
++ (if extraChecks then [ gradle pythonEnv extra extraRemote jbang ] else [ ])
++ (if release then [ semver jreleaser ] else [ ]);
};
Expand Down

0 comments on commit ca107db

Please sign in to comment.