From 24faae928d498c07148aca81a04ac844c28fe11a Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Fri, 21 Nov 2025 00:07:19 +0100 Subject: [PATCH 1/3] Cleanup, more CI testing for scripts, validate inputs --- .github/workflows/CI.yml | 33 ++++++- action.yml | 95 ++++++++++--------- .../check_absolute_paths.sh | 0 scripts/check_date.sh | 18 ++++ .../check_filenames.sh | 0 scripts/check_symlinks.sh | 7 ++ .../pkginfo_to_json.g | 11 ++- 7 files changed, 114 insertions(+), 50 deletions(-) rename check_absolute_paths.sh => scripts/check_absolute_paths.sh (100%) create mode 100755 scripts/check_date.sh rename check_filenames.sh => scripts/check_filenames.sh (100%) create mode 100755 scripts/check_symlinks.sh rename pkginfo_to_json.g => scripts/pkginfo_to_json.g (77%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3523fc1..6f59531 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -65,14 +65,15 @@ jobs: - name: "Shellcheck" shell: bash + working-directory: scripts run: shellcheck -o all *.sh - name: "Test check_filenames.sh" shell: bash + working-directory: scripts run: | - mkdir -p filename-dir + mkdir -p filename-dir/doc cd filename-dir - mkdir -p doc touch :q \\Users\\GillBates AUX COM².tar.gz period. space\ DOC \ PackageInfo.g doc/manual.pdf manual.pdf README readme.txt auxiliary .gaplint.yml ../check_filenames.sh > $RUNNER_TEMP/filenames_run.txt || true # suppress expected error here @@ -89,6 +90,7 @@ jobs: - name: "Test check_absolute_paths.sh" shell: bash + working-directory: scripts run: | mkdir -p paths-dir/doc cd paths-dir @@ -101,3 +103,30 @@ jobs: ./doc/chap1_mj.html ./doc/chap2_mj.html EOF + + - name: "Test check_symlinks.sh" + shell: bash + working-directory: scripts + run: | + mkdir -p symlinks-dir + cd symlinks-dir + echo "THIS FILE IS NOT A SYMLINK" > actual.file + ../check_symlinks.sh > $RUNNER_TEMP/symlinks_run.txt # should not give error + ln -s actual.file sym.link + ../check_symlinks.sh > $RUNNER_TEMP/symlinks_run.txt || true # suppress expected error here + diff <(sort $RUNNER_TEMP/symlinks_run.txt) - < "$ASSETS/$ARCHIVENAME" ;; .tar.bz2) tar cf - "$BASENAME" | bzip2 -9c > "$ASSETS/$ARCHIVENAME" ;; .zip) zip -r9 --quiet "$ASSETS/$ARCHIVENAME" "$BASENAME" ;; *) - echo "::error::Unsupported archive format $EXT" - exit 1 - ;; - esac - if [ ! -f "$ASSETS/$ARCHIVENAME" ] ; then - echo "::error::Failed at creating "$ARCHIVENAME"" - exit 1 - fi - echo "Created $ARCHIVENAME" + echo "::error::Unsupported archive format $EXT" + exit 1 + ;; + esac + if [ ! -f "$ASSETS/$ARCHIVENAME" ] ; then + echo "::error::Failed at creating '$ARCHIVENAME'" + exit 1 + fi + echo "Created $ARCHIVENAME" done - name: "Copy manual(s)" diff --git a/check_absolute_paths.sh b/scripts/check_absolute_paths.sh similarity index 100% rename from check_absolute_paths.sh rename to scripts/check_absolute_paths.sh diff --git a/scripts/check_date.sh b/scripts/check_date.sh new file mode 100755 index 0000000..9000236 --- /dev/null +++ b/scripts/check_date.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e +set -o pipefail + +DATE="$1" + +# Convert DD/MM/YYYY to YYYY-MM-DD +if [[ "${DATE}" =~ ^[0-9]{2}/[0-9]{2}/[0-9]{4}$ ]]; then + DATE=$(echo "${DATE}" | awk -F/ '{print $3"-"$2"-"$1}') +fi + +TODAY=$(date +%Y-%m-%d) +YESTERDAY=$(date -d "yesterday" +%Y-%m-%d) +TOMORROW=$(date -d "tomorrow" +%Y-%m-%d) + +if [[ "${DATE}" != "${TODAY}" && "${DATE}" != "${YESTERDAY}" && "${DATE}" != "${TOMORROW}" ]]; then + exit 1 +fi diff --git a/check_filenames.sh b/scripts/check_filenames.sh similarity index 100% rename from check_filenames.sh rename to scripts/check_filenames.sh diff --git a/scripts/check_symlinks.sh b/scripts/check_symlinks.sh new file mode 100755 index 0000000..a7fa45f --- /dev/null +++ b/scripts/check_symlinks.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e +set -o pipefail + +if find . -type l | grep .; then + exit 1 +fi diff --git a/pkginfo_to_json.g b/scripts/pkginfo_to_json.g similarity index 77% rename from pkginfo_to_json.g rename to scripts/pkginfo_to_json.g index 93f7fee..8b6d1d1 100644 --- a/pkginfo_to_json.g +++ b/scripts/pkginfo_to_json.g @@ -3,14 +3,15 @@ LoadPackage("json"); InstallMethod(RecNames, [IsRecord and IsInternalRep], x -> AsSSortedList(REC_NAMES(x))); InstallMethod(_GapToJsonStreamInternal, [IsOutputStream, IsObject], -function(o, x) + function(o, x) PrintTo(o, "null"); -end); + end +); Read("PackageInfo.g"); if not IsBound(GAPInfo.PackageInfoCurrent) then - Print("Reading PackageInfo.g failed\n"); - FORCE_QUIT_GAP(2); + Exec("echo ::error::Reading PackageInfo.g failed"); + ForceQuitGap(2); fi; pkginfo := GAPInfo.PackageInfoCurrent; @@ -19,7 +20,7 @@ if IsBound(pkginfo.PackageDoc) and not IsList(pkginfo.PackageDoc) then pkginfo.PackageDoc := [pkginfo.PackageDoc]; fi; -output := OutputTextFile("package-info.json", false ); +output := OutputTextFile("package-info.json", false); GapToJsonStream(output, pkginfo); CloseStream(output); From 902a3a8a2dcd577245f7dc58a3604e932265cbe9 Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Fri, 21 Nov 2025 00:10:03 +0100 Subject: [PATCH 2/3] Add missing quotes in pkginfo_to_json.g --- scripts/pkginfo_to_json.g | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pkginfo_to_json.g b/scripts/pkginfo_to_json.g index 8b6d1d1..286c9db 100644 --- a/scripts/pkginfo_to_json.g +++ b/scripts/pkginfo_to_json.g @@ -10,7 +10,7 @@ InstallMethod(_GapToJsonStreamInternal, [IsOutputStream, IsObject], Read("PackageInfo.g"); if not IsBound(GAPInfo.PackageInfoCurrent) then - Exec("echo ::error::Reading PackageInfo.g failed"); + Exec("echo \"::error::Reading PackageInfo.g failed\""); ForceQuitGap(2); fi; pkginfo := GAPInfo.PackageInfoCurrent; From 5968236367dc820eb2adb65f898e1c1571a2ad89 Mon Sep 17 00:00:00 2001 From: stertooy <5571903+stertooy@users.noreply.github.com> Date: Sun, 23 Nov 2025 20:22:17 +0100 Subject: [PATCH 3/3] Add linebreak Co-authored-by: Kamil Zabielski <50334623+limakzi@users.noreply.github.com> --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 9293a2a..06f99f4 100644 --- a/action.yml +++ b/action.yml @@ -147,6 +147,7 @@ runs: run: | echo "::group::Cleanup git and github related files" rm -rvf .git* .hg* .cvs* .circleci + echo "::group::Cleanup codecov, travis, azure-pipelines" rm -fv .codecov.* .travis.* .appveyor.* azure-pipelines.* rm -fv .gaplint.*