Skip to content

Commit

Permalink
Merge pull request #42 from zickgraf/master
Browse files Browse the repository at this point in the history
Apply PackageJanitor and adjust to homalg-project/CAP_project#1073
  • Loading branch information
zickgraf authored Sep 30, 2022
2 parents 2a8bbf4 + 32b6040 commit dfdba55
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 29 deletions.
4 changes: 0 additions & 4 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
codecov:
disable_default_path_fixes: true
require_ci_to_pass: false
fixes:
- "/home/gap/.gap/pkg/FinGSetsForCAP/::"
ignore:
- "home/"
15 changes: 9 additions & 6 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
steps:
# 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@v1
- run: mkdir -p /home/gap/.gap/pkg/
- run: sudo cp -a $GITHUB_WORKSPACE /home/gap/.gap/pkg/
- run: sudo chown -R gap:gap /home/gap/.gap/pkg/
# checkout needs access to temporary directory
- run: sudo chmod 1777 $RUNNER_TEMP
- run: sudo chown gap:gap $GITHUB_WORKSPACE
- uses: actions/checkout@v3
- run: cp -a $GITHUB_WORKSPACE /home/gap/.gap/pkg/
- run: |
export HOME="/home/gap"
cd /home/gap/.gap/pkg/
Expand All @@ -40,21 +41,23 @@ jobs:
# build documentation of packages which we might want to reference, keep this in sync with `release-gap-package`
[ -d "CAP_project/CAP" ] && make -C "CAP_project/CAP" doc
[ -d "CAP_project/CompilerForCAP" ] && make -C "CAP_project/CompilerForCAP" doc
[ -d "CAP_project/FreydCategoriesForCAP" ] && make -C "CAP_project/FreydCategoriesForCAP" doc
[ -d "CAP_project/MonoidalCategories" ] && make -C "CAP_project/MonoidalCategories" doc
[ -d "CAP_project/CartesianCategories" ] && make -C "CAP_project/CartesianCategories" doc
[ -d "CAP_project/FreydCategoriesForCAP" ] && make -C "CAP_project/FreydCategoriesForCAP" doc
[ -d "HigherHomologicalAlgebra/ToolsForHigherHomologicalAlgebra" ] && make -C "HigherHomologicalAlgebra/ToolsForHigherHomologicalAlgebra" doc
[ -d "homalg_project/homalg" ] && make -C "homalg_project/homalg" doc
[ -d "homalg_project/Modules" ] && make -C "homalg_project/Modules" doc
[ -d "Toposes" ] && make -C "Toposes" doc
TERM=dumb make -C FinGSetsForCAP -j $(nproc) --output-sync ci-test
cp ./FinGSetsForCAP/.codecov.yml ./
(cd FinGSetsForCAP && LANG=C.UTF-8 python3 process_coverage_ignored_lines.py)
(cd FinGSetsForCAP && LANG=C.UTF-8 python3 process_coverage.py)
[ "$GITHUB_EVENT_NAME" != "schedule" ] && [ "${{ matrix.image }}" = "ghcr.io/homalg-project/gap-docker-master:latest" ] && ./FinGSetsForCAP/upload_codecov.sh
git config --global user.name "Bot"
git config --global user.email "empty"
cd FinGSetsForCAP
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; \
git worktree add gh-pages/ gh-pages || (echo "There was an error. Make sure there is a branch named 'gh-pages'. See https://github.com/homalg-project/PackageJanitor#error-there-was-an-error-make-sure-there-is-a-branch-named-gh-pages"; exit 1); \
git checkout master; \
LANG=C.UTF-8 ./make_dist.sh --token "${{ secrets.GITHUB_TOKEN }}"; \
Expand Down
4 changes: 2 additions & 2 deletions PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "FinGSetsForCAP",
Subtitle := "The elementary topos of (skeletal) finite G-sets",
Version := "2021.05-02",
Version := "2022.09-01",

Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
License := "GPL-2.0-or-later",
Expand Down Expand Up @@ -99,7 +99,7 @@ Dependencies := rec(
GAP := ">= 4.11.1",
NeededOtherPackages := [
[ "GAPDoc", ">= 1.5" ],
[ "CAP", ">= 2021.05-02" ],
[ "CAP", ">= 2022.09-23" ],
[ "Toposes", ">= 2021.03-01" ],
],
SuggestedOtherPackages := [
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ To obtain current versions of all dependencies, `git clone` (or `git pull` to up
[date-img]: https://img.shields.io/endpoint?url=https://homalg-project.github.io/FinGSetsForCAP/badge_date.json&label=🔗%20released%20on&color=yellow
[date-url]: https://homalg-project.github.io/FinGSetsForCAP/view_release.html

[tests-img]: https://github.com/homalg-project/FinGSetsForCAP/workflows/Tests/badge.svg?branch=master
[tests-url]: https://github.com/homalg-project/FinGSetsForCAP/actions?query=workflow%3ATests+branch%3Amaster
[tests-img]: https://github.com/homalg-project/FinGSetsForCAP/actions/workflows/Tests.yml/badge.svg?branch=master
[tests-url]: https://github.com/homalg-project/FinGSetsForCAP/actions/workflows/Tests.yml?query=branch%3Amaster

[codecov-img]: https://codecov.io/gh/homalg-project/FinGSetsForCAP/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/homalg-project/FinGSetsForCAP
Expand Down
2 changes: 1 addition & 1 deletion gap/EndAsEqualizer.gi
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ InstallGlobalFunction( EndAsEqualizer, function ( C, HomC, ForgetfulFunctor, Ind
LambdaComponents := Concatenation( List( [ 1 .. Size( IndexSet ) ], c_1 -> List( [ 1 .. Size( IndexSet ) ], c_2 -> GetLambdaComponent( IndexSet, Projections, c_1, c_2 ) ) ) );
Lambda := UniversalMorphismIntoDirectProduct( LambdaComponents );

iota := EmbeddingOfEqualizer( [ Rho, Lambda ] );
iota := EmbeddingOfEqualizer( S, [ Rho, Lambda ] );
EndSkeletal := Source( iota );

# each element x in EndSkeletal corresponds to a tuple of integers by taking all projections of the image of x under the embedding iota
Expand Down
13 changes: 5 additions & 8 deletions gap/SkeletalFinGSetsForCAP.gi
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,11 @@ InstallMethod( SkeletalFinGSets,

##
AddEmbeddingOfEqualizer( SkeletalFinGSets,
function ( cat, D )
local phi_1, S, positions;
function ( cat, S, D )
local phi_1, positions;

phi_1 := D[1];

S := Source( phi_1 );

D := D{[ 2 .. Length( D ) ]};

positions := Filtered( Positions( S ), p -> ForAll( D, phi -> Component( phi_1, p ) = Component( phi, p ) ) );
Expand Down Expand Up @@ -956,12 +954,11 @@ InstallMethod( SkeletalFinGSets,

##
AddProjectionOntoCoequalizer( SkeletalFinGSets,
function ( cat, D )
local S, T, M, N, Cq, rangePositions, imgs, j, r, previousImagePositions, preimagePositions, imagePositions, iota, preimageEmbedding, imageEmbedding, projection, imageEmbeddings, projections, tau, alpha, pi;
function ( cat, T, D )
local S, M, N, Cq, rangePositions, imgs, j, r, previousImagePositions, preimagePositions, imagePositions, iota, preimageEmbedding, imageEmbedding, projection, imageEmbeddings, projections, tau, alpha, pi;

S := Source( D[1] );
T := Range( D[1] );


M := AsList( S );
N := AsList( T );

Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ test-doc: doc

test-with-coverage: doc
gap --quitonbreak --cover stats tst/testall.g
echo 'LoadPackage("profiling"); OutputJsonCoverage("stats", "coverage.json");' | gap --quitonbreak
gap --quitonbreak --norepl -c 'LoadPackage("profiling"); OutputJsonCoverage("stats", "coverage.json");'

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
for filename in gap/*; do \
echo $$filename; \
echo "LoadPackage(\"FinGSetsForCAP\"); SizeScreen([4096]); func := ReadAsFunction(\"$$filename\"); FileString(\"gap_spacing\", DisplayString(func));" | gap --quitonbreak --banner; \
gap --quitonbreak --norepl --banner -c "LoadPackage(\"FinGSetsForCAP\"); 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. \
Expand Down
16 changes: 13 additions & 3 deletions process_coverage_ignored_lines.py → process_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
# c) calls of `TryNextMethod` leading to external code.
#######################################################

# This script applies three rules to all coverage*.json files below the current working directory:
# a) Remove all coverage information of files not below the current working directory
# (this technically includes "tst/testall.g" because it is not referenced by an absolute path).
# b) Strip the current working directory from the paths of files below the current working directory.
# c) Ignore lines with one of the "COVERAGE_IGNORE_..." annotations (see below).

import json
import re
import os
Expand All @@ -17,14 +23,18 @@
regex_next_line = re.compile("^\s*# COVERAGE_IGNORE_NEXT_LINE$")
regex_return_void = re.compile("^\s*return;$")

for coverage_filename in Path(".").glob("**/coverage*.json"):
for coverage_filename in Path("../").glob("**/coverage*.json"):
print("processing coverage file " + str(coverage_filename))
new_data = {}
new_data["coverage"] = {}
with open(coverage_filename) as json_file:
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() + "/"):
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
line_number = 0
ignoring = False
ignored_lines = []
Expand Down Expand Up @@ -77,4 +87,4 @@
del lines_covered[str(line_number)]

with open(coverage_filename, "w") as outfile:
json.dump(data, outfile, indent=0)
json.dump(new_data, outfile, indent=0)
2 changes: 1 addition & 1 deletion release-gap-package
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ fi
chmod -R a+r .

# replace links to packages which are possibly referenced in the documentation, keep this in sync with `Tests.yml.j2`
for package in CAP_project/CAP CAP_project/CompilerForCAP CAP_project/FreydCategoriesForCAP CAP_project/MonoidalCategories HigherHomologicalAlgebra/ToolsForHigherHomologicalAlgebra homalg_project/homalg homalg_project/Modules Toposes; do
for package in CAP_project/CAP CAP_project/CompilerForCAP CAP_project/MonoidalCategories CAP_project/CartesianCategories CAP_project/FreydCategoriesForCAP HigherHomologicalAlgebra/ToolsForHigherHomologicalAlgebra homalg_project/homalg homalg_project/Modules Toposes; do

# adjust links to other manuals
# Note that we cannot use sed's `-i` option for in-place editing, as
Expand Down
19 changes: 19 additions & 0 deletions tst/testall.g
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ options := rec(
),
);

# reverse RecNames 50% of the time to detect code relying on the order of RecNames
if Random( RandomSource( IsMersenneTwister, NanosecondsSinceEpoch( ) ), [ false, true ] ) then

Display( "Executing with reversed RecNames" );

MakeReadWriteGlobal( "RecNames" );

old_RecNames := RecNames;

RecNames := record -> Reversed( old_RecNames( record ) );

MakeReadOnlyGlobal( "RecNames" );

else

Display( "Executing with non-reversed RecNames" );

fi;

TestDirectory( DirectoriesPackageLibrary( "FinGSetsForCAP", "tst" ), options );

FORCE_QUIT_GAP( 1 ); # if we ever get here, there was an error

0 comments on commit dfdba55

Please sign in to comment.