Skip to content

Commit

Permalink
Merge pull request #23 from homalg-project/PackageJanitor-1630408805
Browse files Browse the repository at this point in the history
Apply PackageJanitor
  • Loading branch information
mohamed-barakat authored Aug 31, 2021
2 parents 6855cee + acbb5d0 commit 8599572
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
test:
Expand All @@ -31,6 +32,7 @@ jobs:
sudo apt update
sudo apt dist-upgrade -y
sudo apt install -y texlive-latex-extra texlive-fonts-extra
cp ./CatReps/ci_gaprc /home/gap/.gap/gaprc
git clone --depth 1 https://github.com/gap-packages/AutoDoc.git
git clone --depth 1 https://github.com/homalg-project/homalg_project.git
git clone --depth 1 https://github.com/homalg-project/CAP_project.git
Expand Down
12 changes: 12 additions & 0 deletions ci_gaprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Prefer GAPInfo.UserGapRoot over other package directories to prevent accidentally testing package
# versions distributed with GAP.
(function()
local name, package_info, pos;
for name in RecNames( GAPInfo.PackagesInfo ) do
package_info := GAPInfo.PackagesInfo.(name);
pos := PositionProperty( package_info, info -> StartsWith( info.InstallationPath, GAPInfo.UserGapRoot ) );
if pos <> fail then
SetPackagePath( name, package_info[pos].InstallationPath );
fi;
od;
end)();
12 changes: 8 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ test-with-coverage: doc
echo 'LoadPackage("profiling"); OutputJsonCoverage("stats", "coverage.json");' | gap --quitonbreak

test-spacing:
grep -R "[^ [] " gap/*.gi && echo "Duplicate spaces found" && exit 1 || exit 0
grep -R "[^ [\"] " gap/*.gi && echo "Duplicate spaces found" && exit 1 || exit 0
grep -RE '[^ ] +$$' gap/* && echo "Trailing whitespace found" && exit 1 || exit 0
for filename in gap/*; do \
echo $$filename; \
echo "LoadPackage(\"CatReps\"); SizeScreen([4096]); func := ReadAsFunction(\"$$filename\"); FileString(\"gap_spacing\", PrintString(func));" | gap --quitonbreak --banner; \
echo "LoadPackage(\"CatReps\"); SizeScreen([4096]); func := ReadAsFunction(\"$$filename\"); FileString(\"gap_spacing\", DisplayString(func));" | gap --quitonbreak --banner; \
echo -e "\033[0m"; \
cat "gap_spacing" | sed 's/^function ( ) //g' | sed 's/ return; end$$//g' | sed 's/;/;\n/g' > modified_gap_spacing; \
cat "$$filename" | grep -v "^ *[#]" | sed 's/^ *//' | grep -v "^$$" | tr "\n" " " | sed "s/;/;\n/g" | head -c -1 > modified_custom_spacing; \
# In a perfect world, the DisplayString of a function would exactly match our code. However, our line breaks and indentation might differ from the GAP ones, \
# so we remove all indentation, line breaks, and empty lines, and afterwards insert line breaks at semicolons again for better readability. \
cat "gap_spacing" | tail -n +2 | head -n -2 | sed 's/\[ \]/[ ]/g' | sed 's/( )/( )/g' | sed 's/( :/( :/g' | sed 's/ *$$//' | sed 's/^ *//' | grep -v "^$$" | tr "\n" " " | sed 's/;/;\n/g' > modified_gap_spacing; \
cat "$$filename" | grep -v "^ *[#]" | sed 's/^ *//' | grep -v "^$$" | tr "\n" " " | sed "s/;/;\n/g" > modified_custom_spacing; \
# Our code might still differ from the GAP code, for example because of additional brackets. \
# Thus, we diff the code once as expected and once ignoring all space. Diffing the two diffs then shows lines which only differ by spacing. \
diff modified_gap_spacing modified_custom_spacing > spacing_diff; \
diff modified_gap_spacing modified_custom_spacing --ignore-all-space --ignore-space-change --ignore-trailing-space --ignore-blank-lines > spacing_diff_no_blanks; \
diff spacing_diff_no_blanks spacing_diff || exit; \
Expand Down
29 changes: 15 additions & 14 deletions release-gap-package
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ Actions
-p, --push perform the final push, completing the release [Default]
-P, --no-push do not perform the final push
-f, --force if a release with the same name already exists: overwrite it
--skip-existing-release if a release with the same name already exists: exit without error
Paths
--srcdir <path> path of directory containing PackageInfo.g [Default: current directory]
--tmpdir <path> path of temporary directory [Default: tmp subdirectory of srcdir]
--webdir <path> path of web directory [Default: gh-pages subdirectory of srcdir]
--update-file <file> path of the update.g file [Default: update.g in webdir]
--update-script <file> path of the update script [Default: update.g in webdir]
Custom settings
--token <oauth> GitHub access token
Expand Down Expand Up @@ -145,12 +146,12 @@ while [ x"$1" != x ]; do
--srcdir ) SRC_DIR="$1"; shift ;;
--webdir ) WEB_DIR="$1"; shift ;;
--tmpdir ) TMP_DIR="$1"; shift ;;
--update-file ) UPDATE_FILE="$1"; shift ;;
--update-script ) UPDATE_SCRIPT="$1"; shift ;;

--srcdir=*) SRC_DIR=${option#--srcdir=}; shift ;;
--webdir=*) WEB_DIR=${option#--webdir=}; shift ;;
--tmpdir=*) TMP_DIR=${option#--tmpdir=}; shift ;;
--update-file=*) UPDATE_FILE=${option#--update-file=}; shift ;;
--update-script=*) UPDATE_SCRIPT=${option#--update-script=}; shift ;;

--token ) TOKEN="$1"; shift ;;

Expand Down Expand Up @@ -189,12 +190,12 @@ if [ ! -d "$WEB_DIR" ] ; then
error "could not find 'webdir' with clone of your gh-pages branch"
fi

# Check for presence of update.g file
if [ "x$UPDATE_FILE" = x ] ; then
UPDATE_FILE="$WEB_DIR/update.g"
# Check for presence of the update script
if [ "x$UPDATE_SCRIPT" = x ] ; then
UPDATE_SCRIPT="$WEB_DIR/update.g"
fi
if [ ! -f "$UPDATE_FILE" ] ; then
error "could not find update.g file"
if [ ! -f "$UPDATE_SCRIPT" ] ; then
error "could not find update script \"${UPDATE_SCRIPT}\""
fi

# Check whether GAP is usable
Expand Down Expand Up @@ -416,8 +417,8 @@ sed "s;Date := .*;Date := \"$(date +%d/%m/%Y)\",;" PackageInfo.g > PackageInfo.g
mv PackageInfo.g.bak PackageInfo.g

notice "Removing unnecessary files"
rm -rf .github .circleci
rm -f .git* .hg* .cvs*
# Remove recursively in case there is a .github directory
rm -rf .git* .hg* .cvs* .circleci
rm -f .appveyor.yml .codecov.yml .travis.yml

# execute .release script, if present
Expand Down Expand Up @@ -447,7 +448,7 @@ fi;
PushOptions(rec(relativePath:="../../.."));
Read("makedoc.g");
GAPInput
rm -f doc/*.lab doc/*.tex
rm -f doc/*.tex
rm -f doc/*.aux doc/*.bbl doc/*.blg doc/*.brf doc/*.idx doc/*.ilg doc/*.ind doc/*.log doc/*.out doc/*.pnr doc/*.tst
elif [ -f doc/make_doc ] ; then
notice "Copying GAP package documentation for archives (using doc/make_doc)"
Expand Down Expand Up @@ -565,7 +566,7 @@ fi
DATA=$(cat <<EOF
{
"tag_name": "$TAG",
"name": "$PKG-$VERSION",
"name": "$PKG $VERSION",
"body": "Release for $PKG",
"draft": false,
"prerelease": false
Expand Down Expand Up @@ -627,7 +628,7 @@ if [ ! -f "$FULLNAME" ] ; then
error "could not find PDF"
fi
notice "Uploading PDF"
response=$(curl --fail --progress-bar -o "$TMP_DIR/upload.log" \
response=$(curl --fail --progress-bar -o "$TMP_DIR/upload_pdf.log" \
-X POST "$UPLOAD_URL/$RELEASE_ID/assets?name=$BASENAME.pdf" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $TOKEN" \
Expand Down Expand Up @@ -666,7 +667,7 @@ for f in ./*/*.htm* ; do
done

run_gap <<GAPInput
Read("$UPDATE_FILE");
Read("$UPDATE_SCRIPT");
GAPInput

git add -A
Expand Down

0 comments on commit 8599572

Please sign in to comment.