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..286c9db 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);