Skip to content

Commit 5f7f773

Browse files
committed
cd: windows initial
1 parent c3a1144 commit 5f7f773

11 files changed

+351
-0
lines changed

.github/workflows/cd.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release-win:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
script-id: [win32, win64]
15+
env:
16+
FILE_ENV: ./cd/00_setup_env_${{ matrix.script-id }}.sh
17+
OS_NAME: linux
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
steps:
20+
- name: checkout
21+
uses: actions/checkout@v2
22+
- name: cache
23+
uses: actions/cache@v2
24+
with:
25+
path: |
26+
./depends/built
27+
./ci/scratch/.ccache
28+
key: ${{ runner.os }}-${{ matrix.script-id }}
29+
- name: build
30+
run: |
31+
./cd/run_all.sh
32+
- name: release
33+
uses: softprops/action-gh-release@v1
34+
with:
35+
files: '/tmp/release/*'

cd/00_setup_env.sh

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2019-2020 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
# The root dir.
10+
# The ci system copies this folder.
11+
# This is where the depends build is done.
12+
BASE_ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../ >/dev/null 2>&1 && pwd )
13+
export BASE_ROOT_DIR
14+
15+
echo "Setting specific values in env"
16+
if [ -n "${FILE_ENV}" ]; then
17+
set -o errexit;
18+
# shellcheck disable=SC1090
19+
source "${FILE_ENV}"
20+
fi
21+
22+
echo "Fallback to default values in env (if not yet set)"
23+
# The number of parallel jobs to pass down to make and test_runner.py
24+
export MAKEJOBS=${MAKEJOBS:--j4}
25+
# A folder for the ci system to put temporary files (ccache, datadirs for tests, ...)
26+
# This folder only exists on the ci host.
27+
export BASE_SCRATCH_DIR=${BASE_SCRATCH_DIR:-$BASE_ROOT_DIR/ci/scratch}
28+
# What host to compile for. See also ./depends/README.md
29+
# Tests that need cross-compilation export the appropriate HOST.
30+
# Tests that run natively guess the host
31+
export HOST=${HOST:-$("$BASE_ROOT_DIR/depends/config.guess")}
32+
# Whether to prefer BusyBox over GNU utilities
33+
export USE_BUSY_BOX=${USE_BUSY_BOX:-false}
34+
export CONTAINER_NAME=${CONTAINER_NAME:-ci_unnamed}
35+
export DOCKER_NAME_TAG=${DOCKER_NAME_TAG:-ubuntu:18.04}
36+
# See man 7 debconf
37+
export DEBIAN_FRONTEND=noninteractive
38+
export CCACHE_SIZE=${CCACHE_SIZE:-100M}
39+
export CCACHE_TEMPDIR=${CCACHE_TEMPDIR:-/tmp/.ccache-temp}
40+
export CCACHE_COMPRESS=${CCACHE_COMPRESS:-1}
41+
# The cache dir.
42+
# This folder exists on the ci host and ci guest. Changes are propagated back and forth.
43+
export CCACHE_DIR=${CCACHE_DIR:-$BASE_SCRATCH_DIR/.ccache}
44+
# The depends dir.
45+
# This folder exists on the ci host and ci guest. Changes are propagated back and forth.
46+
export DEPENDS_DIR=${DEPENDS_DIR:-$BASE_ROOT_DIR/depends}
47+
# Folder where the build result is put (bin and lib).
48+
export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out/$HOST}
49+
# Folder where the build is done (dist and out-of-tree build).
50+
export BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build}
51+
export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
52+
export DOCKER_PACKAGES=${DOCKER_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git procps bison}
53+
export PATH=${BASE_ROOT_DIR}/ci/retry:$PATH
54+
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}

cd/00_setup_env_win32.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2019-2020 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
export CONTAINER_NAME=ci_win32
10+
export DOCKER_NAME_TAG=ubuntu:20.04
11+
export HOST=i686-w64-mingw32
12+
export PACKAGES="python3 nsis g++-mingw-w64-i686 wine-binfmt wine32"
13+
export RUN_UNIT_TESTS=false
14+
export RUN_FUNCTIONAL_TESTS=false
15+
# export RUN_SECURITY_TESTS="true"
16+
export GOAL="deploy"
17+
export GRIDCOIN_CONFIG="--enable-reduce-exports --with-gui=qt5"
18+
export DPKG_ADD_ARCH="i386"
19+
export NEED_XVFB="false"

cd/00_setup_env_win64.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2019-2020 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
export CONTAINER_NAME=ci_win64
10+
export DOCKER_NAME_TAG=ubuntu:20.04
11+
export HOST=x86_64-w64-mingw32
12+
export PACKAGES="python3 nsis g++-mingw-w64-x86-64 wine-binfmt wine64"
13+
export GOAL="deploy"
14+
export GRIDCOIN_CONFIG="--enable-reduce-exports --with-gui=qt5"
15+
export RUN_UNIT_TESTS=false
16+
export NEED_XVFB="false"

cd/03_before_install.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2018-2019 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
BEGIN_FOLD () {
10+
echo ""
11+
CURRENT_FOLD_NAME=$1
12+
echo "::group::${CURRENT_FOLD_NAME}"
13+
}
14+
15+
END_FOLD () {
16+
RET=$?
17+
echo "::endgroup::"
18+
if [ $RET != 0 ]; then
19+
echo "${CURRENT_FOLD_NAME} failed with status code ${RET}"
20+
fi
21+
}
22+

cd/04_install.sh

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2018-2020 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
if [[ $DOCKER_NAME_TAG == centos* ]]; then
10+
export LC_ALL=en_US.utf8
11+
fi
12+
if [[ $QEMU_USER_CMD == qemu-s390* ]]; then
13+
export LC_ALL=C
14+
fi
15+
16+
# Create folders that are mounted into the docker
17+
mkdir -p "${CCACHE_DIR}"
18+
mkdir -p "/tmp/release"
19+
20+
env | grep -E '^(GRIDCOIN_CONFIG|BASE_|QEMU_|CCACHE_|LC_ALL|BOOST_TEST_RANDOM|DEBIAN_FRONTEND|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS|PREVIOUS_RELEASES_DIR)' | tee /tmp/env
21+
22+
export P_CI_DIR="$PWD"
23+
24+
mkdir -p /tmp/release
25+
26+
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
27+
echo "Creating $DOCKER_NAME_TAG container to run in"
28+
${CI_RETRY_EXE} docker pull "$DOCKER_NAME_TAG"
29+
30+
DOCKER_ID=$(docker run $DOCKER_ADMIN -idt \
31+
--mount type=bind,src=$BASE_ROOT_DIR,dst=/ro_base,readonly \
32+
--mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR \
33+
--mount type=bind,src=$DEPENDS_DIR,dst=$DEPENDS_DIR \
34+
--mount type=bind,src=$PREVIOUS_RELEASES_DIR,dst=$PREVIOUS_RELEASES_DIR \
35+
--mount type=bind,src=/tmp/release,dst=/release \
36+
-w $BASE_ROOT_DIR \
37+
--env-file /tmp/env \
38+
--name $CONTAINER_NAME \
39+
$DOCKER_NAME_TAG)
40+
export DOCKER_CI_CMD_PREFIX="docker exec $DOCKER_ID"
41+
else
42+
echo "Running on host system without docker wrapper"
43+
fi
44+
45+
DOCKER_EXEC () {
46+
$DOCKER_CI_CMD_PREFIX bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $P_CI_DIR && $*"
47+
}
48+
export -f DOCKER_EXEC
49+
50+
if [ -n "$DPKG_ADD_ARCH" ]; then
51+
DOCKER_EXEC dpkg --add-architecture "$DPKG_ADD_ARCH"
52+
fi
53+
54+
if [[ $DOCKER_NAME_TAG == centos* ]]; then
55+
BEGIN_FOLD yum
56+
${CI_RETRY_EXE} DOCKER_EXEC yum -y install epel-release
57+
${CI_RETRY_EXE} DOCKER_EXEC yum -y install $DOCKER_PACKAGES $PACKAGES
58+
END_FOLD
59+
elif [ "$CI_USE_APT_INSTALL" != "no" ]; then
60+
BEGIN_FOLD apt
61+
${CI_RETRY_EXE} DOCKER_EXEC apt-get update
62+
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $DOCKER_PACKAGES
63+
if [ "$NEED_XVFB" == "true" ]; then
64+
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y xvfb
65+
fi
66+
END_FOLD
67+
fi
68+
69+
if [ "$OS_NAME" == "macos" ]; then
70+
top -l 1 -s 0 | awk ' /PhysMem/ {print}'
71+
echo "Number of CPUs: $(sysctl -n hw.logicalcpu)"
72+
else
73+
DOCKER_EXEC free -m -h
74+
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$\(nproc\)
75+
DOCKER_EXEC echo $(lscpu | grep Endian)
76+
DOCKER_EXEC echo "Free disk space:"
77+
DOCKER_EXEC df -h
78+
fi
79+
80+
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
81+
echo "Create $BASE_ROOT_DIR"
82+
DOCKER_EXEC rsync -a /ro_base/ $BASE_ROOT_DIR
83+
fi
84+
85+
if [ "$USE_BUSY_BOX" = "true" ]; then
86+
echo "Setup to use BusyBox utils"
87+
DOCKER_EXEC mkdir -p $BASE_SCRATCH_DIR/bins/
88+
# tar excluded for now because it requires passing in the exact archive type in ./depends (fixed in later BusyBox version)
89+
# find excluded for now because it does not recognize the -delete option in ./depends (fixed in later BusyBox version)
90+
# ar excluded for now because it does not recognize the -q option in ./depends (unknown if fixed)
91+
# shellcheck disable=SC1010
92+
DOCKER_EXEC for util in \$\(busybox --list \| grep -v "^ar$" \| grep -v "^tar$" \| grep -v "^find$"\)\; do ln -s \$\(command -v busybox\) $BASE_SCRATCH_DIR/bins/\$util\; done
93+
# Print BusyBox version
94+
DOCKER_EXEC patch --help
95+
fi

cd/05_before_script.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2018-2020 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
DOCKER_EXEC mkdir -p ${DEPENDS_DIR}/SDKs ${DEPENDS_DIR}/sdk-sources
10+
11+
OSX_SDK_BASENAME="Xcode-${XCODE_VERSION}-${XCODE_BUILD_ID}-extracted-SDK-with-libcxx-headers.tar.gz"
12+
OSX_SDK_PATH="${DEPENDS_DIR}/sdk-sources/${OSX_SDK_BASENAME}"
13+
14+
if [ -n "$XCODE_VERSION" ] && [ ! -f "$OSX_SDK_PATH" ]; then
15+
sudo curl --location --fail "${SDK_URL}/${OSX_SDK_BASENAME}" -o "$OSX_SDK_PATH"
16+
fi
17+
18+
if [ -n "$XCODE_VERSION" ] && [ -f "$OSX_SDK_PATH" ]; then
19+
DOCKER_EXEC tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH"
20+
fi
21+
if [[ $HOST = *-mingw32 ]]; then
22+
DOCKER_EXEC update-alternatives --set $HOST-g++ \$\(which $HOST-g++-posix\)
23+
fi
24+
if [ -z "$NO_DEPENDS" ]; then
25+
if [[ $DOCKER_NAME_TAG == centos* ]]; then
26+
# CentOS has problems building the depends if the config shell is not explicitly set
27+
# (i.e. for libevent a Makefile with an empty SHELL variable is generated, leading to
28+
# an error as the first command is executed)
29+
SHELL_OPTS="CONFIG_SHELL=/bin/bash"
30+
else
31+
SHELL_OPTS="CONFIG_SHELL="
32+
fi
33+
DOCKER_EXEC $SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS
34+
fi
35+
if [[ $HOST = x86_64-apple-darwin* ]]; then
36+
DOCKER_EXEC "cd src/ && ../contrib/nomacro.pl"
37+
fi

cd/06_script_a.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2018-2020 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
GRIDCOIN_CONFIG_ALL="--disable-dependency-tracking --prefix=$DEPENDS_DIR/$HOST --bindir=$BASE_OUTDIR/bin --libdir=$BASE_OUTDIR/lib"
10+
DOCKER_EXEC "ccache --zero-stats --max-size=$CCACHE_SIZE"
11+
12+
BEGIN_FOLD autogen
13+
if [ -n "$CONFIG_SHELL" ]; then
14+
DOCKER_EXEC "$CONFIG_SHELL" -c "./autogen.sh"
15+
else
16+
DOCKER_EXEC ./autogen.sh
17+
fi
18+
END_FOLD
19+
20+
DOCKER_EXEC mkdir -p "${BASE_BUILD_DIR}"
21+
export P_CI_DIR="${BASE_BUILD_DIR}"
22+
23+
BEGIN_FOLD configure
24+
DOCKER_EXEC "${BASE_ROOT_DIR}/configure" --cache-file=config.cache $GRIDCOIN_CONFIG_ALL $GRIDCOIN_CONFIG || ( (DOCKER_EXEC cat config.log) && false)
25+
END_FOLD
26+
27+
BEGIN_FOLD distdir
28+
DOCKER_EXEC make distdir VERSION=$HOST
29+
END_FOLD
30+
31+
export P_CI_DIR="${BASE_BUILD_DIR}/gridcoin-$HOST"
32+
33+
BEGIN_FOLD configure
34+
DOCKER_EXEC ./configure --cache-file=../config.cache $GRIDCOIN_CONFIG_ALL $GRIDCOIN_CONFIG || ( (DOCKER_EXEC cat config.log) && false)
35+
END_FOLD
36+
37+
BEGIN_FOLD build
38+
DOCKER_EXEC make $MAKEJOBS deploy || ( echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 ; false )
39+
END_FOLD
40+
41+
BEGIN_FOLD cache_stats
42+
DOCKER_EXEC "ccache --version | head -n 1 && ccache --show-stats"
43+
DOCKER_EXEC du -sh "${DEPENDS_DIR}"/*/
44+
DOCKER_EXEC du -sh "${PREVIOUS_RELEASES_DIR}"
45+
END_FOLD

cd/06_script_b.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2021 The Gridcoin developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
DOCKER_EXEC mv release/* /release
10+
11+
for f in /tmp/release/*; do
12+
sha256sum $f > $f.SHA256
13+
done

cd/run_all.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2019 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
set -o errexit; source ./cd/00_setup_env.sh
10+
set -o errexit; source ./cd/03_before_install.sh
11+
set -o errexit; source ./cd/04_install.sh
12+
set -o errexit; source ./cd/05_before_script.sh
13+
set -o errexit; source ./cd/06_script_a.sh
14+
set -o errexit; source ./cd/06_script_b.sh

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,7 @@ AC_SUBST(QR_LIBS)
11931193
AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist])
11941194
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
11951195
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
1196+
AC_CONFIG_LINKS([CHANGELOG.md:CHANGELOG.md COPYING:COPYING])
11961197

11971198
dnl boost's m4 checks do something really nasty: they export these vars. As a
11981199
dnl result, they leak into secp256k1's configure and crazy things happen.

0 commit comments

Comments
 (0)