<commit_before>#!/bin/bash

set -e

# Some defaults so we can run outside Jenkins
echo "target branch: ${ghprbTargetBranch:=master}"
echo "head commit: ${ghprbActualCommit:=$(git rev-parse --verify HEAD)}"

# Clear out old results
rm -f *junit.xml

export PR_BRANCH_BASE=$(git show-branch --sha1-name --current --merge-base origin/$ghprbTargetBranch)
echo "$PR_BRANCH_BASE..$ghprbActualCommit"

if git diff --name-only "$PR_BRANCH_BASE..$ghprbActualCommit" | grep "^docs/" ;then 
	echo "testing docs changes"
	echo "===================="
else 
	echo "no docs changes"
	echo '<testsuite tests="1"><testcase classname="markdownlint" name="NoDocChanges"><skipped /></testcase></testsuite>' > junit.xml
	exit 0
fi

JOBIMAGE="$BUILD_TAG:$ghprbActualCommit"
JOBCONTAINER="$BUILD_TAG-$ghprbActualCommit"

git log --format=oneline "$PR_BRANCH_BASE..$ghprbActualCommit"
set -x # echo on
docker pull $(grep FROM docs/Dockerfile | sed s/FROM//)
docker build -t "$JOBIMAGE" docs
# lots more Dockerfile changes needed to improve this.
docker run --name "$JOBCONTAINER" "$JOBIMAGE"

# some older branches may not have the xml output yet, so fornow we'll skip them
docker cp "$JOBCONTAINER:/validate.junit.xml" . \
	|| echo '<testsuite tests="1"><testcase classname="validate" name="NoJunitFile"><skipped /></testcase></testsuite>' > junit.xml


docker rm -vf "$JOBCONTAINER"  || true
docker rmi "$JOBIMAGE" || true

# Show what we're sending to Jenkins/GH in the console log
more *junit.xml | cat<commit_msg>Ignore validate.sh error code, as we're gettingback the XML instead<commit_after>#!/bin/bash

set -e

# Some defaults so we can run outside Jenkins
echo "target branch: ${ghprbTargetBranch:=master}"
echo "head commit: ${ghprbActualCommit:=$(git rev-parse --verify HEAD)}"

# Clear out old results
rm -f *junit.xml

export PR_BRANCH_BASE=$(git show-branch --sha1-name --current --merge-base origin/$ghprbTargetBranch)
echo "$PR_BRANCH_BASE..$ghprbActualCommit"

if git diff --name-only "$PR_BRANCH_BASE..$ghprbActualCommit" | grep "^docs/" ;then 
	echo "testing docs changes"
	echo "===================="
else 
	echo "no docs changes"
	echo '<testsuite tests="1"><testcase classname="markdownlint" name="NoDocChanges"><skipped /></testcase></testsuite>' > junit.xml
	exit 0
fi

JOBIMAGE="$BUILD_TAG:$ghprbActualCommit"
JOBCONTAINER="$BUILD_TAG-$ghprbActualCommit"

git log --format=oneline "$PR_BRANCH_BASE..$ghprbActualCommit"
set -x # echo on
docker pull $(grep FROM docs/Dockerfile | sed s/FROM//)
docker build -t "$JOBIMAGE" docs
# lots more Dockerfile changes needed to improve this.
docker run --name "$JOBCONTAINER" "$JOBIMAGE" || true

# some older branches may not have the xml output yet, so fornow we'll skip them
docker cp "$JOBCONTAINER:/validate.junit.xml" . \
	|| echo '<testsuite tests="1"><testcase classname="validate" name="NoJunitFile"><skipped /></testcase></testsuite>' > junit.xml


docker rm -vf "$JOBCONTAINER"  || true
docker rmi "$JOBIMAGE" || true

# Show what we're sending to Jenkins/GH in the console log
more *junit.xml | cat
{'fraction_non_alphanumeric': 0.14918032786885246, 'fraction_numerical': 0.002622950819672131, 'mean_word_length': 5.188640973630831, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6112235', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1018, 'n_words': 305}