From 12963d73040f0a4f41b89dfe0e651f419b4c2fdb Mon Sep 17 00:00:00 2001 From: Mohamed Barakat Date: Sun, 1 Jan 2023 23:01:27 +0100 Subject: [PATCH] applied PackageJanitor --- .github/workflows/Tests.yml | 17 +++++++++++++---- PackageInfo.g | 2 +- makefile | 14 +++++++------- process_coverage.py | 2 +- tst/100_LoadPackage.tst | 8 ++++++++ upload_codecov.sh | 2 +- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index ba1dae9..5021927 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -10,6 +10,12 @@ on: - cron: "0 4 * * *" # after gap-docker(-master) is rebuilt workflow_dispatch: +# cancel runs for pull requests on force push +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}-${{ github.run_attempt }} + cancel-in-progress: true + jobs: test: strategy: @@ -23,6 +29,10 @@ jobs: # keep workflow active even if repository has no activity for 60 days (do not execute for pull requests) - run: '[ "$GITHUB_EVENT_NAME" = "pull_request" ] || curl --fail -X PUT -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows/Tests.yml/enable' - uses: actions/checkout@v3 + with: + # the persisted token interferes with the subsplit token used below + persist-credentials: false + fetch-depth: 0 - run: cp -a $GITHUB_WORKSPACE /home/gap/.gap/pkg/ - run: | export HOME="/home/gap" @@ -52,12 +62,11 @@ jobs: [ -d "homalg_project/Modules" ] && make -C "homalg_project/Modules" doc [ -d "Toposes" ] && make -C "Toposes" doc make -C CatReps -j $(nproc) --output-sync ci-test - cp ./CatReps/.codecov.yml ./ - (cd CatReps && LANG=C.UTF-8 python3 process_coverage.py) - [ "$GITHUB_EVENT_NAME" != "schedule" ] && [ "${{ matrix.image }}" = "ghcr.io/homalg-project/gap-docker-master:latest" ] && ./CatReps/upload_codecov.sh + cd CatReps + LANG=C.UTF-8 python3 process_coverage.py + [ "$GITHUB_EVENT_NAME" != "schedule" ] && [ "${{ matrix.image }}" = "ghcr.io/homalg-project/gap-docker-master:latest" ] && ./upload_codecov.sh git config --global user.name "Bot" git config --global user.email "empty" - cd CatReps CUR_SHA=$(git rev-parse --verify HEAD) if [ "${{ matrix.image }}" = "ghcr.io/homalg-project/gap-docker:latest" ] && [ "$CUR_SHA" = "$(git rev-parse origin/master)" ] && [ $(dirname "$GITHUB_REPOSITORY") = "homalg-project" ]; then \ git fetch origin gh-pages; \ diff --git a/PackageInfo.g b/PackageInfo.g index 14415dc..ae09a72 100644 --- a/PackageInfo.g +++ b/PackageInfo.g @@ -10,7 +10,7 @@ SetPackageInfo( rec( PackageName := "CatReps", Subtitle := "Representations and cohomology of finite categories", -Version := "2022.12-02", +Version := "2022.01-01", Date := ~.Version{[ 1 .. 10 ]}, Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ), diff --git a/makefile b/makefile index 1917f69..80a7acd 100644 --- a/makefile +++ b/makefile @@ -17,10 +17,10 @@ test: doc gap tst/testall.g test-basic-spacing: - grep -RPl "\t" examples/ gap/ && echo "Tabs found" && exit 1 || exit 0 - grep -RPl "\r" examples/ gap/ && echo "Windows line-endings found" && exit 1 || exit 0 - # the second grep is a hack to fix the exit code with -L for grep <= 3.1 - grep -RPzL "\n\z" examples/ gap/ | grep "" && echo "File with no newline at end of file found" && exit 1 || exit 0 + # exit code 1 means no match, which is what we want here (exit code 2 signals an error) + grep -RPl "\t" examples/ gap/; test $$? -eq 1 || (echo "Tabs found" && exit 1) + grep -RPl "\r" examples/ gap/; test $$? -eq 1 || (echo "Windows line-endings found" && exit 1) + grep -RPzL "\n\z" examples/ gap/ | grep ""; test $$? -eq 1 || (echo "File with no newline at end of file found" && exit 1) test-doc: doc cp -aT doc/ doc_tmp/ @@ -44,12 +44,12 @@ test-notebooks: done test-spacing: - grep -R "[^ [\"] " gap/*.gi && echo "Duplicate spaces found" && exit 1 || exit 0 - grep -RE '[^ ] +$$' gap/* && echo "Trailing whitespace found" && exit 1 || exit 0 + # exit code 1 means no match, which is what we want here (exit code 2 signals an error) + grep -R "[^ [\"] " gap/*.gi; test $$? -eq 1 || (echo "Duplicate spaces found" && exit 1) + grep -RE '[^ ] +$$' gap/*; test $$? -eq 1 || (echo "Trailing whitespace found" && exit 1) for filename in gap/*; do \ echo $$filename; \ gap --quitonbreak --norepl --banner -c "LoadPackage(\"CatReps\"); SizeScreen([4096]); func := ReadAsFunction(\"$$filename\"); FileString(\"gap_spacing\", DisplayString(func));"; \ - echo -e "\033[0m"; \ # 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; \ diff --git a/process_coverage.py b/process_coverage.py index aad9f71..7635a75 100755 --- a/process_coverage.py +++ b/process_coverage.py @@ -31,7 +31,7 @@ data = json.load(json_file) files = data["coverage"] for filename, lines_covered in files.items(): - if filename.startswith(os.getcwd() + "/"): + if filename.startswith(os.getcwd() + "/") and not filename.endswith("manual.six"): print(" processing code file " + filename) # ignored lines will be delete from lines_covered in-place new_data["coverage"][filename.replace(os.getcwd() + "/", "", 1)] = lines_covered diff --git a/tst/100_LoadPackage.tst b/tst/100_LoadPackage.tst index 92cd7c6..3f35b53 100644 --- a/tst/100_LoadPackage.tst +++ b/tst/100_LoadPackage.tst @@ -7,9 +7,17 @@ gap> PushOptions( rec( OnlyNeeded := true ) ); gap> package_loading_info_level := InfoLevel( InfoPackageLoading );; gap> SetInfoLevel( InfoPackageLoading, PACKAGE_ERROR );; +gap> LoadPackage( "FreydCategoriesForCAP", false ); +true +gap> LoadPackage( "Toposes", false ); +true gap> LoadPackage( "CatReps", false ); true gap> SetInfoLevel( InfoPackageLoading, PACKAGE_INFO );; +gap> LoadPackage( "FreydCategoriesForCAP" ); +true +gap> LoadPackage( "Toposes" ); +true gap> LoadPackage( "CatReps" ); true gap> SetInfoLevel( InfoPackageLoading, package_loading_info_level );; diff --git a/upload_codecov.sh b/upload_codecov.sh index 41e8aad..5c3edc9 100755 --- a/upload_codecov.sh +++ b/upload_codecov.sh @@ -23,4 +23,4 @@ shasum -a 256 -c codecov.SHA256SUM # execute chmod +x codecov -./codecov -Z || (sleep 30; ./codecov -Z || (sleep 30; ./codecov -Z)) +./codecov -Z -v -s ../ || (sleep 30; ./codecov -Z -v -s ../ || (sleep 30; ./codecov -Z -v -s ../))