-
Notifications
You must be signed in to change notification settings - Fork 2
184 lines (161 loc) · 6.18 KB
/
CI.yml
File metadata and controls
184 lines (161 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: CI
# Trigger the workflow on push to main, or on pull request
on:
push:
branches:
- main
pull_request:
jobs:
test-action:
name: "Test the pkg-release action"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: [ "gap-actions/ActionTestGAPDocPackage", "gap-actions/ActionTestOldDocPackage" ]
affix: [ 1, 2 ] # Run each package twice, to check reproducibility
include:
- package: "gap-actions/ActionTestGAPDocPackage"
force: true
- package: "gap-actions/ActionTestOldDocPackage"
force: false
steps:
# the order of the checkout actions is important because all contents of
# the target folder of the checkout action is removed
- name: "Clone the package"
uses: actions/checkout@v6
with:
repository: ${{ matrix.package }}
- name: "Fake the package's date so it does not get rejected later on"
shell: bash
if: ${{ !matrix.force }}
run: |
DATE=$(date +%d/%m/%Y)
sed -i -E "s|(Date[[:space:]]*:?=[[:space:]]*['\"]).*(['\"])|\1${DATE}\2|" "PackageInfo.g"
- name: "Check out this repository"
uses: actions/checkout@v6
with:
path: .this-action/
- name: "Setup GAP"
uses: gap-actions/setup-gap@v3
- name: "Build manual"
uses: gap-actions/build-pkg-docs@v2
with:
use-latex: true
- name: "Make a release"
uses: ./.this-action/
with:
dry-run: true
force: ${{ matrix.force }}
_affix: "-${{ matrix.affix }}"
check-reproducibility:
name: "Check if builds are reproducible"
runs-on: ubuntu-latest
needs: test-action
strategy:
fail-fast: false
matrix:
package: [ "ActionTestGAPDocPackage", "ActionTestOldDocPackage" ]
steps:
- name: "Download releases"
uses: actions/download-artifact@v8
with:
pattern: "Release_assets_for_${{ matrix.package }}*"
path: ${{ runner.temp }}
- name: "Compare releases"
shell: bash
working-directory: ${{ runner.temp }}
run: |
# Move downloaded assets
# The .zip is not an extension but part of the directory name
mv Release_assets_for_*-1.zip v1
mv Release_assets_for_*-2.zip v2
error_found=false
for EXT in .tar.gz .tar.bz2 .zip; do
for file1 in v1/*"$EXT"; do
file2="v2/$(basename "$file1")"
# Calculate sha256 checksums
chk1=$(sha256sum "$file1" | cut -d' ' -f1)
chk2=$(sha256sum "$file2" | cut -d' ' -f1)
if [[ "$chk1" != "$chk2" ]]; then
echo "::error::Checksum mismatch for ${EXT} archives"
echo "v1: $chk1"
echo "v2: $chk2"
error_found=true
else
echo "${EXT} archives are reproducible"
fi
done
done
if ${error_found}; then
exit 1
fi
test-scripts:
name: "Test the scripts used by this action"
runs-on: ubuntu-slim
steps:
- name: "Check out this repository"
uses: actions/checkout@v6
- 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/doc
cd filename-dir
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
diff $RUNNER_TEMP/filenames_run.txt - <<EOF
Checking for Windows-incompatible names
Illegal character in name: :q
Reserved Windows name: AUX
Reserved Windows name: COM².tar.gz
Illegal character in name: \Users\GillBates
Duplicate filename: DOC and doc
Name ends with space or period: period.
Name ends with space or period: space
EOF
- name: "Test check_absolute_paths.sh"
shell: bash
working-directory: scripts
run: |
mkdir -p paths-dir/doc
cd paths-dir
../check_absolute_paths.sh > $RUNNER_TEMP/absolute_paths_run.txt # empty folder, so should not give error
echo "<a href=\"/home/runner/gap/pkg/awesomepackage/doc/chap66_mj.html#ABC123\">Link</a>" > doc/chap1_mj.html
echo "<a href=\"file:///home/runner/gap/pkg/awesomepackage/doc/chap66_mj.html#ABC123\">Link</a>" > doc/chap2_mj.html
echo "<a href=\"../../../pkg/awesomepackage/doc/chap66_mj.html#ABC123\">Link</a>" > doc/chap3_mj.html
../check_absolute_paths.sh > $RUNNER_TEMP/absolute_paths_run.txt || true # suppress expected error here
diff <(sort $RUNNER_TEMP/absolute_paths_run.txt) - <<EOF
./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) - <<EOF
./sym.link
EOF
- name: "Test check_date.sh"
shell: bash
working-directory: scripts
run: |
if ! ./check_date.sh "$(date +%Y-%m-%d)" \
|| ! ./check_date.sh "$(date -d "1 day ago" +%Y-%m-%d)" \
|| ! ./check_date.sh "$(date -d "1 day" +%Y-%m-%d)" \
|| ./check_date.sh "$(date -d "2 days ago" +%Y-%m-%d)" \
|| ./check_date.sh "$(date -d "2 days" +%Y-%m-%d)"
then
exit 1
fi