-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
246 lines (216 loc) · 9.15 KB
/
action.yml
File metadata and controls
246 lines (216 loc) · 9.15 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: 'Compile GAP package'
description: 'Compile the given GAP package being tested'
inputs:
coverage:
description: 'Boolean that determines whether code coverage is turned on by adding `--coverage` to `CFLAGS`, `CXXFLAGS` and `LDFLAGS`.'
required: false
default: 'true'
configflags:
description: 'Additional arguments to be passed to configure.'
required: false
default: ''
build-needed-pkgs:
description: 'Build GAP packages needed by this package, as defined by `Dependencies.NeededPackages` in `PackageInfo.g`. Options are: true, false, recursive.'
required: false
default: 'recursive'
build-suggested-pkgs:
description: 'Build GAP packages suggested by this package, as defined by `Dependencies.SuggestedOtherPackages` in `PackageInfo.g`. Options are: true, false, recursive.'
required: false
default: 'true'
build-extensions:
description: 'Build GAP packages needed for extensions by this package, as defined by `Extensions` in `PackageInfo.g`. Options are: true, false, recursive.'
required: false
default: 'true'
build-system-pkgs:
description: 'Build system packages needed by this package, as defined by `Dependencies.NeededSystemPackages` in `PackageInfo.g`. Options are: true, false, recursive.'
required: false
default: 'recursive'
build-test-pkgs:
description: 'Build GAP packages needed for CI testing, as defined by `Dependencies.TestPackages` in `PackageInfo.g`. Options are: true, false, recursive.'
required: false
default: 'true'
extra-pkgs:
description: 'Additional packages to build that do not appear in `PackageInfo.g`. Should be a space- or newline-separated list.'
required: false
default: ''
runs:
using: "composite"
steps:
- name: "Validate input"
shell: bash
run: |
validate_boolean() {
local input=$1
local option_name=$2
if ! [[ "$input" =~ ^(true|false)$ ]]; then
echo "::error::Invalid value for option $option_name. Expected 'true' or 'false', but found '$input'"
exit 1;
fi
}
validate_opts() {
local input=$1
local option_name=$2
if ! [[ "$input" =~ ^(true|false|recursive)$ ]]; then
echo "::error::Invalid value for option $option_name. Expected 'true', 'false' or 'recursive' but found '$input'"
exit 1;
fi
}
validate_boolean "${{ inputs.coverage }}" coverage
validate_opts "${{ inputs.build-needed-pkgs }}" build-needed-pkgs
validate_opts "${{ inputs.build-suggested-pkgs }}" build-suggested-pkgs
validate_opts "${{ inputs.build-extensions }}" build-extensions
validate_opts "${{ inputs.build-system-pkgs }}" build-system-pkgs
validate_opts "${{ inputs.build-test-pkgs }}" build-test-pkgs
- name: "Determine the package's dependencies"
shell: bash
run: |
$GAP -A -q <<GAPInput
# Get the name of this package
Read("PackageInfo.g");;
orig := LowercaseString( GAPInfo.PackageInfoCurrent.PackageName );;
todo := [ orig ];;
curr := orig;;
done := [];;
pkgs := [];;
build_pkg_check := function( info, field, mode )
return IsBound( info.(field) ) and (
mode = "recursive" or ( mode = "true" and curr = orig )
);
end;;
build_pkg_add_todo := function( pkg, desc, aset, aset2 )
local name;
name := LowercaseString( pkg[1] );
Print( " - ", desc, " '", name, "'\n" );
if not name in aset2 then
AddSet( aset, name );
fi;
end;;
build_pkg_gather_deps := function( info, field, mode, desc )
local pkg;
if build_pkg_check( info.Dependencies, field, mode ) then
for pkg in info.Dependencies.(field) do
build_pkg_add_todo( pkg, desc, todo, done );
od;
fi;
end;;
while not IsEmpty( todo ) do
curr := Remove( todo );
Print( "Now handling package '", curr, "'\n");
if not IsBound( GAPInfo.PackagesInfo.(curr) ) then
Exec( Concatenation(
"echo \"::warning::Package '", curr, "' could not be found.\""
));
continue;
fi;
AddSet( done, curr );
info := GAPInfo.PackagesInfo.(curr)[1];
# Needed packages
build_pkg_gather_deps(
info,
"NeededOtherPackages",
"${{ inputs.build-needed-pkgs }}",
"needs package"
);
# Suggested packages
build_pkg_gather_deps(
info,
"SuggestedOtherPackages",
"${{ inputs.build-suggested-pkgs }}",
"suggests package"
);
# Test packages
build_pkg_gather_deps(
info,
"TestPackages",
"${{ inputs.build-test-pkgs }}",
"is tested using package"
);
# System packages
if build_pkg_check( info.Dependencies, "NeededSystemPackages", "${{ inputs.build-system-pkgs }}" ) then
field := "DOES_NOT_EXIST";
if "${{ runner.os }}" = "Linux" then
field := "Ubuntu";
elif "${{ runner.os }}" = "macOS" then
field := "Homebrew";
fi;
if IsBound( info.Dependencies.NeededSystemPackages.(field) ) then
for pkg in info.Dependencies.NeededSystemPackages.(field) do
build_pkg_add_todo( pkg, "needs system package", pkgs, [] );
od;
fi;
fi;
# Package extensions
if build_pkg_check( info, "Extensions", "${{ inputs.build-extensions }}" ) then
for ext in info.Extensions do
for pkg in ext.needed do
build_pkg_add_todo( pkg,"has an extension that needs package", todo, done );
od;
od;
fi;
od;
# We already built the package being tested!
RemoveSet( done, orig );;
# Cannot use RUNNER_TEMP on Cygwin...
PrintTo( "__GAP_PKGS_TO_BUILD__.txt", JoinStringsWithSeparator( done, " " ) );
PrintTo( "__SYS_PKGS_TO_BUILD__.txt", JoinStringsWithSeparator( pkgs, " " ) );
QUIT;
GAPInput
# ... so put the contents in an environement variable (after removing linebreaks)...
echo "GAP_PKGS_TO_BUILD=$(tr -d '\\\n' < __GAP_PKGS_TO_BUILD__.txt)" | tee -a $GITHUB_ENV
echo "SYS_PKGS_TO_BUILD=$(tr -d '\\\n' < __SYS_PKGS_TO_BUILD__.txt)" | tee -a $GITHUB_ENV
# ... and we ensure no file is left behind.
rm __GAP_PKGS_TO_BUILD__.txt
rm __SYS_PKGS_TO_BUILD__.txt
- name: "Build the package's external dependencies"
shell: bash
run: |
if [[ "${{ runner.os }}" == "Linux" ]] && [[ -n "${SYS_PKGS_TO_BUILD}" ]]; then
sudo apt-get install --no-install-recommends ${SYS_PKGS_TO_BUILD}
elif [[ "${{ runner.os }}" = "macOS" ]] && [[ -n "${SYS_PKGS_TO_BUILD}" ]]; then
brew install ${SYS_PKGS_TO_BUILD}
fi
- name: "Build the package itself"
shell: bash
run: |
GAPROOT=${GAPROOT-$HOME/gap}
# ensure coverage is turned on
if [[ "${{ inputs.coverage }}" = "true" ]]; then
export CFLAGS="$CFLAGS --coverage"
export CXXFLAGS="$CXXFLAGS --coverage"
export LDFLAGS="$LDFLAGS --coverage"
fi
# build this package, if necessary
if [[ -x prerequisites.sh ]]; then
./prerequisites.sh $GAPROOT
fi
if [[ -x autogen.sh && ! -x configure ]]; then
./autogen.sh
fi
if [[ -x configure ]]; then
./configure --with-gaproot=$GAPROOT ${{ inputs.configflags }}
make -j4 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS"
fi
- name: "Build the package's dependencies"
shell: bash
run: |
# Cannot use 'working-directory' on Cygwin, so we use cd instead
cd $GAPROOT/pkg
EXTRA_PKGS_TO_BUILD=$(echo "${{ inputs.extra-pkgs }}" | tr '\n' ' ')
PKGS_TO_BUILD=$(printf '%s\n' $GAP_PKGS_TO_BUILD $EXTRA_PKGS_TO_BUILD | sort -u | xargs)
# Fix for older GAP versions
# E.g. "gapdoc" might actually be located in "GAPDoc-1.2.3"
pkgdirs=()
for pkgdir in ${PKGS_TO_BUILD}; do
# Find directory up to capitalisation
while IFS= read -r d; do
pkgdirs+=("${d#./}")
done < <(find . -maxdepth 1 -type d -iname "${pkgdir}")
# Find directory with version number up to capitalisation
while IFS= read -r d; do
pkgdirs+=("${d#./}")
done < <(find . -maxdepth 1 -type d -iname "${pkgdir}-*")
done
# Only run if array is nonempty, otherwise this tries to build all packages
if [[ -n ${pkgdirs[@]} ]]; then
../bin/BuildPackages.sh --strict ${pkgdirs[@]}
fi