@@ -6,10 +6,10 @@ set -eu
6
6
target=$1
7
7
dir=.github/actions/$target
8
8
9
- mkdir -p $dir
9
+ mkdir -p " $dir "
10
10
11
11
# ## Generate the action
12
- cat > $dir /action.yml << EOF
12
+ cat > " $dir /action.yml" << EOF
13
13
name: 'depexts-$target '
14
14
description: 'Test external dependencies handling for $target '
15
15
runs:
@@ -25,23 +25,23 @@ OCAML_CONSTRAINT=''
25
25
26
26
case " $target " in
27
27
alpine)
28
- cat > $dir /Dockerfile << EOF
28
+ cat > " $dir /Dockerfile" << EOF
29
29
FROM alpine
30
30
RUN apk add $mainlibs $ocaml
31
31
RUN apk add g++
32
32
EOF
33
33
;;
34
34
archlinux)
35
35
# no automake
36
- cat > $dir /Dockerfile << EOF
36
+ cat > " $dir /Dockerfile" << EOF
37
37
FROM archlinux
38
38
RUN pacman -Syu --noconfirm $mainlibs $ocaml gcc diffutils
39
39
EOF
40
40
;;
41
41
centos)
42
42
# CentOS 7 doesn't support OCaml 5 (GCC is too old)
43
43
OCAML_CONSTRAINT=' & < "5.0"'
44
- cat > $dir /Dockerfile << EOF
44
+ cat > " $dir /Dockerfile" << EOF
45
45
FROM almalinux:9.4
46
46
RUN dnf install 'dnf-command(config-manager)' -y
47
47
RUN dnf config-manager --set-enabled crb
@@ -51,15 +51,15 @@ RUN sed -i 's/ID="almalinux"/ID="centos"/' /etc/os-release
51
51
EOF
52
52
;;
53
53
debian)
54
- cat > $dir /Dockerfile << EOF
54
+ cat > " $dir /Dockerfile" << EOF
55
55
FROM debian
56
56
RUN apt update
57
57
RUN apt install -y $mainlibs $ocaml
58
58
RUN apt install -y g++
59
59
EOF
60
60
;;
61
61
fedora)
62
- cat > $dir /Dockerfile << EOF
62
+ cat > " $dir /Dockerfile" << EOF
63
63
FROM fedora
64
64
RUN dnf install -y $mainlibs $ocaml diffutils
65
65
RUN dnf install -y gcc-c++
69
69
mainlibs=${mainlibs/ git/ dev-vcs\/ git}
70
70
mainlibs=${mainlibs/ tar/ app-arch\/ tar}
71
71
mainlibs=${mainlibs/ bzip2/ app-arch\/ bzip2}
72
- cat > $dir /Dockerfile << EOF
72
+ cat > " $dir /Dockerfile" << EOF
73
73
# name the portage image
74
74
FROM gentoo/portage as portage
75
75
# image is based on stage3
83
83
;;
84
84
opensuse)
85
85
# glpk-dev is installed manually because os-family doesn't handle tumbleweed
86
- cat > $dir /Dockerfile << EOF
86
+ cat > " $dir /Dockerfile" << EOF
87
87
FROM opensuse/leap:15.3
88
88
RUN zypper --non-interactive install $mainlibs $ocaml diffutils gzip glpk-devel
89
89
RUN zypper --non-interactive install gcc-c++
90
90
EOF
91
91
;;
92
92
oraclelinux)
93
- cat > $dir /Dockerfile << EOF
93
+ cat > " $dir /Dockerfile" << EOF
94
94
FROM oraclelinux:8
95
95
RUN yum install -y $mainlibs
96
96
RUN yum install -y gcc-c++
97
97
EOF
98
98
;;
99
99
ubuntu)
100
- cat > $dir /Dockerfile << EOF
100
+ cat > " $dir /Dockerfile" << EOF
101
101
FROM ubuntu:20.04
102
102
RUN apt update
103
103
RUN apt install -y $mainlibs $ocaml
@@ -108,10 +108,13 @@ esac
108
108
109
109
OCAML_INVARIANT=" \" ocaml\" {>= \" 4.09.0\" $OCAML_CONSTRAINT }"
110
110
111
- # Copy 2.1 opam binary from cache
112
- cp binary/opam $dir /opam
111
+ # Copy released opam binary from cache
112
+ cp binary/opam " $dir /opam"
113
113
114
- cat >> $dir /Dockerfile << EOF
114
+ LOCAL_REPO=/opam/repo
115
+ CONF_BRANCH=confs
116
+
117
+ cat >> " $dir /Dockerfile" << EOF
115
118
RUN test -d /opam || mkdir /opam
116
119
ENV OPAMROOTISOK=1
117
120
ENV OPAMROOT=/opam/root
@@ -120,7 +123,19 @@ ENV OPAMCONFIRMLEVEL=unsafe-yes
120
123
ENV OPAMPRECISETRACKING=1
121
124
COPY opam /usr/bin/opam
122
125
RUN echo 'default-invariant: [ $OCAML_INVARIANT ]' > /opam/opamrc
123
- RUN /usr/bin/opam init --no-setup --disable-sandboxing --bare --config /opam/opamrc git+$OPAM_REPO #$OPAM_REPO_SHA
126
+ # Retrieve opam repo
127
+ RUN git clone $OPAM_REPO --single-branch --branch master $LOCAL_REPO
128
+ RUN git config --global user.email "[email protected] "
129
+ RUN git config --global user.name "OPAM GHA"
130
+ RUN git -C $LOCAL_REPO reset --hard $OPAM_REPO_SHA
131
+ RUN git -C $LOCAL_REPO reset --soft \$ (git -C $LOCAL_REPO rev-list --all | tail -1)
132
+ RUN git -C $LOCAL_REPO commit -qm "all packages"
133
+ # Build a branch that contains only confs packages
134
+ RUN git -C $LOCAL_REPO checkout -b $CONF_BRANCH
135
+ RUN git -C $LOCAL_REPO rm -q \$ (git -C $LOCAL_REPO ls-files packages | grep -v "^packages/conf-")
136
+ RUN git -C $LOCAL_REPO commit -qm "keep only confs"
137
+ # Setup opam
138
+ RUN /usr/bin/opam init --no-setup --disable-sandboxing --bare --config /opam/opamrc git+file://$LOCAL_REPO #master
124
139
RUN echo 'archive-mirrors: "https://opam.ocaml.org/cache"' >> \$ OPAMROOT/config
125
140
RUN /usr/bin/opam switch create this-opam --formula='$OCAML_INVARIANT '
126
141
RUN /usr/bin/opam install opam-core opam-state opam-solver opam-repository opam-format opam-client --deps
@@ -131,67 +146,72 @@ EOF
131
146
132
147
133
148
# ## Generate the entrypoint
134
- cat > $dir /entrypoint.sh << EOF
149
+ cat > " $dir /entrypoint.sh" << EOF
135
150
#!/bin/sh
136
151
set -eux
137
152
138
153
git config --global --add safe.directory /github/workspace
139
154
155
+ ## CI WORKING DIR
140
156
# Workdir is /github/workpaces
141
157
cd /github/workspace
142
158
143
- ### LOCAL TESTING
144
- #git clone https://github.com/ocaml/opam --single-branch --branch 2.2 --depth 1 local-opam
159
+ ## LOCAL TESTING WORKING DIR
160
+ # with docker run -v local/path/opam:/opam/local-git:ro
161
+ #git clone /opam/local-git --single-branch --branch branch-name --depth 1 local-opam
162
+ # with a distant branch
163
+ #git clone https://github.com/ocaml/opam --single-branch --branch branch-name --depth 1 local-opam
145
164
#cd local-opam
146
165
147
- opam install . --deps
148
- eval \$ (opam env)
166
+ /usr/bin/ opam install . --deps
167
+ eval \$ (/usr/bin/ opam env)
149
168
./configure
150
169
make
170
+
151
171
./opam config report
152
- ./opam switch create confs --empty
172
+ ./opam switch create confs --empty --repo rconf=git+file:// $LOCAL_REPO # $CONF_BRANCH
153
173
EOF
154
174
155
175
# Test depexts
156
176
157
177
DEPEXTS2TEST=" "
158
178
test_depext () {
159
- DEPEXTS2TEST=" $DEPEXTS2TEST $@ "
179
+ DEPEXTS2TEST=" $DEPEXTS2TEST $* "
160
180
}
161
181
162
182
test_depext conf-gmp.4 conf-which.1
163
183
164
- if [ $target != " gentoo" ]; then
184
+ if [ " $target " != gentoo ]; then
165
185
test_depext conf-autoconf.0.1
166
186
fi
167
187
168
188
# disable automake for centos, as os-family returns rhel
169
- if [ $target != " centos" ] && [ $target != " gentoo" ] && [ $target != " opensuse" ]; then
189
+ if [ " $target " != centos ] && [ " $target " != gentoo ] && [ " $target " != opensuse ]; then
170
190
test_depext conf-automake.1
171
191
fi
172
192
173
- # additionna
174
- if [ $target != " oraclelinux " ] && [ $target != " xxx " ]; then
193
+ # additional
194
+ if [ " $target " != oraclelinux ]; then
175
195
test_depext conf-dpkg.1 # gentoo
176
196
fi
177
197
178
198
# package with os-version check
179
199
180
- if [ $target = " debian" ] || [ $target = " ubuntu" ]; then
200
+ if [ " $target " = debian ] || [ " $target " = ubuntu ]; then
181
201
test_depext conf-sundials.2
182
202
# conf-libgccjit.1 conf-rdkit.1
183
203
fi
184
204
185
- if [ $target = " alpine" ]; then
205
+ if [ " $target " = alpine ]; then
186
206
test_depext conf-clang-format.1
187
207
# conf-pandoc.0.1
188
208
fi
189
209
190
- if [ $target = " fedora" ]; then
210
+ if [ " $target " = fedora ]; then
191
211
test_depext conf-emacs.1
192
212
fi
193
213
194
- if [ $target = " oraclelinux" ] || [ $target = " centos" ]; then
214
+ if [ " $target " = oraclelinux ] || [ " $target " = centos ]; then
195
215
test_depext conf-pkg-config.3
196
216
fi
197
217
@@ -203,7 +223,7 @@ if [ -z "$DEPEXTS2TEST" ]; then
203
223
exit 3
204
224
fi
205
225
206
- cat >> $dir /entrypoint.sh << EOF
226
+ cat >> " $dir /entrypoint.sh" << EOF
207
227
ERRORS=""
208
228
test_depexts () {
209
229
for pkg in \$ @ ; do
222
242
EOF
223
243
224
244
# Test depexts update
225
- cat >> $dir /entrypoint.sh << EOF
245
+ cat >> " $dir /entrypoint.sh" << EOF
226
246
./opam update --depexts || ERRORS="\$ ERRORS opam-update-depexts"
227
247
EOF
228
248
229
- chmod +x $dir /entrypoint.sh
249
+ chmod +x " $dir /entrypoint.sh"
230
250
231
251
# done
0 commit comments