tweak rust build scripts, add new C build scripts to run builds inside alpine containers of various architectures
All checks were successful
moparisthebest/self-ci/pipeline/head This commit looks good

This commit is contained in:
Travis Burtrum 2020-11-25 00:06:05 -05:00
parent 89756dce4a
commit 7f3caffe7a
4 changed files with 99 additions and 5 deletions

46
build-ci.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/bash
# first arg is $BUILD_LANG, currently supported:
# 1. rust, this runs $BUILD_SCRIPT with env variable TARGET and DISABLE_TESTS set appropriately once for each target supported by cross
# this'll have to do until cross can run in docker containers backed by the btrfs driver...
# 2. c, this runs $BUILD_SCRIPT inside an alpine linux container, once for each ARCH supported by build.sh here
# run like (for rust):
# curl --compressed -sL https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/build-ci.sh | bash -s -- rust
# curl --compressed -sL https://raw.githubusercontent.com/moparisthebest/self-ci/master/build-ci.sh | sed 's@https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master@https://raw.githubusercontent.com/moparisthebest/self-ci/master@g' | bash -s -- rust
export BUILD_LANG="${1-rust}"
shift
export BUILD_SCRIPT="${1-.jenkins/build.sh}"
shift
export RELEASE_SCRIPT="${1-.jenkins/release.sh}"
shift
set -euxo pipefail
mkdir -p bin
cd bin
curl --compressed -sL -O 'https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/ci-release-helper.sh' -O "https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/$BUILD_LANG/build.sh"
chmod +x ci-release-helper.sh build.sh
cd ..
export PATH="$(pwd)/bin:$PATH"
build.sh "$BUILD_SCRIPT" "$@"
if [ -e "$RELEASE_SCRIPT" ]
then
"$RELEASE_SCRIPT" "$@"
elif [ -d 'release' ]
then
# default release script
ci-release-helper.sh standard_pre_release
cd release
find -type f ! -path ./sha256sum.txt -print0 | xargs -0 sha256sum > sha256sum.txt
gpg --clearsign sha256sum.txt
ci-release-helper.sh standard_multi_release 'sha256sum.txt' 'text/plain'
ci-release-helper.sh standard_multi_release 'sha256sum.txt.asc' 'text/plain'
rm -f sha256sum.txt sha256sum.txt.asc
find -type f -print0 | xargs -0n1 -I {} ci-release-helper.sh standard_multi_release '{}' 'application/octet-stream'
fi
exit 0

23
c/build.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
set -euxo pipefail
export BUILD_SCRIPT="${1-.jenkins/build.sh}"
docker_build() {
export ARCH="$1"
shift
DOCKER_IMAGE="$1"
# run it, but after, chown anything left in /tmp to *this* uid/gid, otherwise we can't delete them later...
docker run --rm -e ARCH -v "$(pwd)":/tmp "$DOCKER_IMAGE" sh -c "'/tmp/$BUILD_SCRIPT'; exit=\$?; chown -R '$UID:$(id -g)' /tmp; exit \$exit"
}
docker_build 'amd64' 'alpine'
# before first multiarch image, must register binfmt handlers
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker_build 'i386' 'multiarch/alpine:i386-latest-stable'
docker_build 'aarch64' 'multiarch/alpine:aarch64-latest-stable'
docker_build 'armv7' 'multiarch/alpine:armv7-latest-stable'
docker_build 'ppc64le' 'multiarch/alpine:ppc64le-latest-stable'

View File

@ -1,14 +1,37 @@
#!/bin/bash
set -euxo pipefail
# this'll have to do until cross can run in docker containers backed by the btrfs driver
# run like: curl https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/rust/build-jenkins.sh | bash
# this runs first arg or .jenkins/build.sh with env variable TARGET and DISABLE_TESTS set appropriately once for each target supported by cross
# this'll have to do until cross can run in docker containers backed by the btrfs driver...
# run like:
# curl --compressed -sL https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/rust/build-jenkins.sh | bash
# curl --compressed -sL https://raw.githubusercontent.com/moparisthebest/self-ci/master/rust/build-jenkins.sh | sed 's@https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master@https://raw.githubusercontent.com/moparisthebest/self-ci/master@g' | bash
# or with custom script:
# curl --compressed -sL https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/rust/build-jenkins.sh | bash -s -- ./path/to/build.sh
# curl --compressed -sL https://raw.githubusercontent.com/moparisthebest/self-ci/master/rust/build-jenkins.sh | sed 's@https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master@https://raw.githubusercontent.com/moparisthebest/self-ci/master@g' | bash -s -- ./path/to/build.sh
export BUILD_SCRIPT="${1-.jenkins/build.sh}"
shift
export RELEASE_SCRIPT="${1-.jenkins/release.sh}"
mkdir bin
cd bin
curl -O https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/ci-release-helper.sh -O https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/rust/build.sh
curl --compressed -sL -O https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/ci-release-helper.sh -O https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/rust/build.sh
chmod +x ci-release-helper.sh build.sh
cd ..
export PATH="$(pwd)/bin:$PATH"
build.sh "$BUILD_SCRIPT"
if [ -e "$RELEASE_SCRIPT" ]
then
"$RELEASE_SCRIPT"
elif [ -d 'release' ]
then
# default release script
ci-release-helper.sh standard_pre_release
exec build.sh .jenkins/build.sh
find release/ -type f -print0 | xargs -0n1 -I {} ci-release-helper.sh standard_multi_release '{}' 'application/octet-stream'
fi
exit 0

View File

@ -1,6 +1,8 @@
#!/bin/bash
set -euo pipefail
export CROSS_VERSION=0.2.1
for TARGET in ${BUILD_TARGETS:-x86_64-unknown-linux-musl x86_64-unknown-linux-gnu i686-unknown-linux-musl i686-unknown-linux-gnu i586-unknown-linux-musl i586-unknown-linux-gnu aarch64-unknown-linux-musl aarch64-unknown-linux-gnu armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf arm-unknown-linux-gnueabi arm-unknown-linux-gnueabihf arm-unknown-linux-musleabi arm-unknown-linux-musleabihf armv5te-unknown-linux-gnueabi armv5te-unknown-linux-musleabi x86_64-pc-windows-gnu x86_64-linux-android i686-linux-android aarch64-linux-android armv7-linux-androideabi arm-linux-androideabi mips64el-unknown-linux-gnuabi64 mips64-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl mips-unknown-linux-gnu mips-unknown-linux-musl powerpc64le-unknown-linux-gnu powerpc-unknown-linux-gnu riscv64gc-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-sun-solaris sparcv9-sun-solaris x86_64-unknown-netbsd}
do
if echo "$TARGET" | grep -E '(^s390x|^thumb|solaris$|^x86_64-unknown-dragonfly$|^x86_64-unknown-netbsd$)' >/dev/null