-
Notifications
You must be signed in to change notification settings - Fork 8
255 lines (238 loc) · 10.6 KB
/
github-CI-Windows.yml
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
247
248
249
250
251
252
253
254
255
name: wget-for-windows CI
on: [push, pull_request]
jobs:
# Customize the env and configure args
# windows-2022 installs only pure MSYS2: https://github.com/actions/virtual-environments/issues/1572#issuecomment-908941444
# https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Install-Msys2.ps1
# https://github.com/actions/virtual-environments/tree/main/images/win/toolsets
build:
# https://docs.github.com/en/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
strategy:
matrix:
#os: [ubuntu-latest, windows-latest] # run native test
bits: [32, 64]
ftype: [vista-wintls-winhashes-shared-full, vista-wintls-winhashes-static-lite, xp-openssl-lite]
fail-fast: false
# https://github.com/actions/virtual-environments
name: mingw${{matrix.bits}}-${{matrix.ftype}}
runs-on: windows-latest
env:
mingw: mingw${{matrix.bits}}
build_type: ${{matrix.ftype}}
defaults:
run:
shell: msys2 {0}
steps:
- name: Set up ENVs for MSYS2 to inherit
shell: bash
run: |
# Explicitly enable year2038:
# gnulib requires `-D__MINGW_USE_VC2005_COMPAT` for `time_t` from `year2038.m4` and `largefile.m4`.
# gnulib/doc/posix-headers/sys_time.texi
case "${mingw}" in
mingw32) arch="i686"; echo CFLAGS="-D__MINGW_USE_VC2005_COMPAT=1" >> $GITHUB_ENV ;;
mingw64) arch="x86_64" ;;
*) exit 1 ;;
esac
BRoot="${PWD}"
BDir="build/${build_type}/${mingw}"
CDir="${BDir}-config"
echo arch="$arch" >> $GITHUB_ENV
echo BRoot="$BRoot" >> $GITHUB_ENV
echo BDir="$BDir" >> $GITHUB_ENV
echo CDir="$CDir" >> $GITHUB_ENV
# https://github.com/msys2/setup-msys2
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{env.mingw}}
release: false
#path-type: inherit
# `AX_CODE_COVERAGE` requires autoconf-archive: https://github.com/google/oss-fuzz/pull/5379/files
# gpgme for metalink, but depends on many others, that's not preferred on windows
# gettext for NLS, expat for metalink, libidn2 and libunistring for libpsl
# mingw-w64-${{env.arch}}-libmetalink is removed from MSYS2 repo, compile and install it ourself.
# pacman group: https://packages.msys2.org/group/
install: >-
base-devel
gperf
autoconf
automake
autoconf-archive
git
python
libcares-devel
mingw-w64-${{env.arch}}-gcc
mingw-w64-${{env.arch}}-expat
mingw-w64-${{env.arch}}-gpgme
mingw-w64-${{env.arch}}-libpsl
mingw-w64-${{env.arch}}-libidn2
mingw-w64-${{env.arch}}-libunistring
mingw-w64-${{env.arch}}-gettext
# MinGW-w64 pre-installed
- name: Show setup result
run: |
echo "ls /"
ls /
echo "bash --version"
bash --version
echo "gcc -v"
gcc -v
git --version
python -V
python -c "import sys; print(sys.executable)"
python3 -V
python3 -c "import sys; print(sys.executable)"
perl -e 'print $^O . "\n"'
pwd
echo "PATH"
echo "$PATH"
echo "$BRoot"
echo "$BDir"
echo "$CDir"
- uses: actions/checkout@v4
# Shallow fetch makes version unknown: git describe --abbrev=4 --match="$prefix*" HEAD
with:
fetch-depth: 0
# gettext-0.20 issue: https://github.com/coreutils/gnulib/blob/master/build-aux/po/Makefile.in.in#L11
# gettext and gettext-devel v0.20 is not available on MSYS2
# wget => gnulib_po => gnulib/build-aux/po/Makefile.in.in, po/Makefile.in.in from MSYS2 gettext
- name: Generate configure
run: |
loc_ver=$(gettext -V | sed -n "s/gettext[^0-9]\+\([0-9.]\+\).*/\1/p")
req_ver=$(sed -n "s/^\gettext\s\+\([0-9.]\+\)$/\1/mp" bootstrap.conf)
if [ -n "${req_ver}" ] && [ ${loc_ver} \< ${req_ver} ]; then
echo "Reset gettext version: bootstrap.conf requires "${req_ver}", local is "${loc_ver}
sed -i "s/^\(gettext\s\+\)[0-9.]\+$/\1${loc_ver}/gm" bootstrap.conf
fi
req_ver=$(sed -n "s/^AM_GNU_GETTEXT_VERSION(\[\([0-9.]\+\)\])$/\1/mp" configure.ac)
if [ -n "${req_ver}" ] && [ ${loc_ver} \< ${req_ver} ]; then
echo "Reset gettext version: configure.ac requires "${req_ver}", local is "${loc_ver}
sed -i "s/^\(AM_GNU_GETTEXT_VERSION(\[\)[0-9.]\+\(\])\)$/\1${loc_ver}\2/gm" configure.ac
fi
./bootstrap --skip-po
sed -i "s/-dirty\b//p" configure
# -->
- name: Install extra dependencies
run: |
if [ "${{matrix.ftype}}" = "vista-wintls-winhashes-shared-full" ]; then
wget https://github.com/metalink-dev/libmetalink/releases/download/release-0.1.3/libmetalink-0.1.3.tar.gz
tar -xvzf libmetalink-0.1.3.tar.gz
cd libmetalink-0.1.3
./configure --disable-xmltest
make install
else
wget https://github.com/win-iconv/win-iconv/archive/refs/tags/v0.0.8.tar.gz
tar -xvzf v0.0.8.tar.gz
cd win-iconv-0.0.8
make -E CFLAGS=-Os -E prefix=/$mingw install
if [ "${{matrix.ftype}}" = "xp-openssl-lite" ]; then
cd ..
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
tar -xvzf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
CFLAGS='-Wall -Os -fomit-frame-pointer' LDFLAGS=-s ./config --api=1.1.0 --prefix=/$mingw -static \
-no-shared --release \
enable-aria enable-asm enable-async enable-camellia enable-chacha enable-ct enable-deprecated \
enable-des enable-dh enable-ec enable-ecdh enable-ecdsa enable-gost enable-md4 enable-multiblock \
enable-pinshared enable-poly1305 enable-psk enable-rfc3779 enable-sock enable-srp enable-sse2 \
enable-stdio enable-tls enable-ts enable-ui-console \
no-afalgeng no-asan no-autoalginit no-autoerrinit no-autoload-config no-bf no-blake2 no-buildtest-c++ \
no-capieng no-cast no-cmac no-cms no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng \
no-dgram no-dsa no-dtls no-dynamic-engine no-ec2m no-ec_nistp_64_gcc_128 no-egd no-engine no-err \
no-external-tests no-filenames no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-hw no-idea no-makedepend \
no-md2 no-mdc2 no-msan no-nextprotoneg no-ocb no-ocsp no-pic no-posix-io no-rc2 no-rc4 no-rc5 no-rdrand \
no-rmd160 no-scrypt no-sctp no-seed no-shared no-siphash no-sm2 no-sm3 no-sm4 no-srtp no-ssl \
no-ssl-trace no-static-engine no-tests no-threads no-ubsan no-unit-test no-weak-ssl-ciphers no-whirlpool \
no-zlib no-zlib-dynamic
make install_dev
fi
fi
- name: configure
run: |
mkdir -p $BDir
mkdir -p $CDir
cd $CDir
pwd
export CFLAGS+=" -Wall -DGNULIB_defined_ESOCK -DSite=https://github.com/lifenjoiner/wget-for-windows"
if [ "${{matrix.ftype}}" = "vista-wintls-winhashes-shared-full" ]; then
CFLAGS+=" -D_WIN32_WINNT=0x0600 -O2" $BRoot/configure --prefix=$BRoot/$BDir --disable-rpath --with-cares \
--with-winidn --enable-threads=windows
elif [ "${{matrix.ftype}}" = "vista-wintls-winhashes-static-lite" ]; then
CFLAGS+=" -D_WIN32_WINNT=0x0600 -Os" LDFLAGS="-static -s" $BRoot/configure --prefix=$BRoot/$BDir \
--disable-debug --disable-rpath --disable-nls --without-libpsl --without-metalink --disable-pcre \
--disable-pcre2 --with-winidn --enable-threads=windows
elif [ "${{matrix.ftype}}" = "xp-openssl-lite" ]; then
# -DNTDDI_VERSION=NTDDI_WINXPSP3 for winhashes
CFLAGS+=" -D_WIN32_WINNT=0x0501 -Os" LDFLAGS="-static -s" $BRoot/configure --prefix=$BRoot/$BDir \
--with-ssl=openssl --without-winhashes \
--disable-debug --disable-rpath --disable-nls --without-libpsl --without-metalink --disable-pcre \
--disable-pcre2 --with-winidn --enable-threads=windows
fi
# <--
# gnulib_po gettext requires gettext version 0.20 higher env can have!
- name: Build
run: |
cd $CDir
echo -e "all:\n\n" > gnulib_po/Makefile
make
- name: Show compiled wget info
run: |
ls -l $CDir/src/wget.exe
SHA=$(sha1sum $CDir/src/wget.exe | cut -b 1-40)
echo SHA="$SHA" >> $GITHUB_ENV
$CDir/src/wget -V
- name: fuzz
run: |
cd $CDir/fuzz
make check
- name: testenv
if: ${{success()}} || ${{failure()}}
run: |
cd $CDir/testenv
make check
timeout-minutes: 5 # in case of stuck
- name: tests
if: ${{success()}} || ${{failure()}}
run: |
cd $CDir/tests
make check
timeout-minutes: 5 # in case of stuck
- name: Upload wget
uses: actions/upload-artifact@v4
if: ${{success()}} || ${{failure()}}
with:
name: wget-${{env.mingw}}-${{env.build_type}}_${{github.head_ref || github.ref_name}}_${{env.SHA}}
path: |
${{env.CDir}}/src/wget.exe
- name: Upload logs
uses: actions/upload-artifact@v4
if: ${{failure()}}
with:
name: wget-${{env.mingw}}-${{env.build_type}}-logs
# Previous steps can be stuck and then timeout, so all `.log` files and sub-folders.
path: |
${{env.CDir}}/config.log
${{env.CDir}}/lib/libgnu.a
${{env.CDir}}/src/libunittest.a
${{env.CDir}}/fuzz/*.log
${{env.CDir}}/fuzz/Makefile
${{env.CDir}}/testenv/
${{env.CDir}}/tests/*.log
${{env.CDir}}/tests/Makefile
${{env.CDir}}/tests/**/
!${{env.CDir}}/tests/.deps/
!${{env.CDir}}/tests/*.exe
!${{env.CDir}}/tests/*.o
- name: Package release assets
if: ${{ startsWith(github.ref, 'refs/tags/') && endsWith(matrix.ftype, '-lite') }}
run: |
cd ${{env.CDir}}/src
"/C/Program Files/7-Zip/7z" a wget-${{env.mingw}}-${{env.build_type}}_${{github.head_ref || github.ref_name}}_${{env.SHA}}.7z wget.exe
- name: Upload release assets
uses: softprops/action-gh-release@v2
if: ${{ startsWith(github.ref, 'refs/tags/') && endsWith(matrix.ftype, '-lite') }}
with:
draft: true
files: |
${{env.CDir}}/src/wget-${{env.mingw}}-${{env.build_type}}_${{github.head_ref || github.ref_name}}_${{env.SHA}}.7z