Skip to content

Commit

Permalink
Cirrus CI: Extract packaging steps as reusable YAML node
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Feb 10, 2023
1 parent ac4aa4d commit 703dfba
Showing 1 changed file with 94 additions and 87 deletions.
181 changes: 94 additions & 87 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installs lit, clones the git submodules, builds LDC and the test
# runners and runs the tests.
# Requires env variables EXTRA_CMAKE_FLAGS and PARALLELISM.
# Requires env variables CI_OS, EXTRA_CMAKE_FLAGS and PARALLELISM.
common_steps_template: &COMMON_STEPS_TEMPLATE
install_lit_script: |
# Install lit
Expand Down Expand Up @@ -49,8 +49,99 @@ common_steps_template: &COMMON_STEPS_TEMPLATE
fi
ctest -j$PARALLELISM --output-on-failure -E "$excludes"
# Performs the extra packaging steps for jobs producing a prebuilt package.
# Requires env variables CI_OS and GITHUB_TOKEN (and CC for FreeBSD).
packaging_steps_template: &PACKAGING_STEPS_TEMPLATE
# Install LDC & make portable
install_script: |
cd $CIRRUS_WORKING_DIR/..
cd build
ninja install > /dev/null
cd ..
perl -pi -e s?$PWD/install/?%%ldcbinarypath%%/../?g install/etc/ldc2.conf
if [[ "$CI_OS" == "freebsd" ]]; then
perl -pi -e "s?,druntime-ldc\",?,druntime-ldc\", \"-gcc=$CC\",?" install/etc/ldc2.conf
fi
cp $CIRRUS_WORKING_DIR/{LICENSE,packaging/README} install
cat install/etc/ldc2.conf
# Now rename the installation dir to test portability
mv install installed
# Run hello-world integration test with shared libs
run_shared_libs_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
echo 'void main() { import std.stdio; writefln("Hello world, %d bits", size_t.sizeof * 8); }' > hello.d
installed/bin/ldc2 hello.d -m64 -of=hello64 -link-defaultlib-shared
./hello64
# Run hello-world integration test with LTO
run_lto_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
installed/bin/ldc2 hello.d -of=hello_thin -flto=thin -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
./hello_thin
installed/bin/ldc2 hello.d -of=hello_full -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
./hello_full
# Run dynamic-compile integration test
run_dynamic_compile_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
installed/bin/ldc2 -enable-dynamic-compile -run $CIRRUS_WORKING_DIR/tests/dynamiccompile/array.d
# Run ImportC integration test
run_importC_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
installed/bin/ldc2 -run $CIRRUS_WORKING_DIR/tests/dmd/runnable/test22597.c
# Build & copy dub
build_dub_script: |
cd $CIRRUS_WORKING_DIR/..
export DMD=$PWD/installed/bin/ldmd2
git clone --recursive https://github.com/dlang/dub.git
cd dub
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/dub_version)"
$DMD -run build.d -O -w -linkonce-templates
cp bin/dub ../installed/bin
../installed/bin/dub --version
# Build & copy dlang tools
build_dlang_tools_script: |
cd $CIRRUS_WORKING_DIR/..
DMD=$PWD/installed/bin/ldmd2
git clone --recursive https://github.com/dlang/tools.git dlang-tools
cd dlang-tools
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/dlang-tools_version)"
mkdir bin
$DMD -w -de -dip1000 rdmd.d -of=bin/rdmd
$DMD -w -de -dip1000 ddemangle.d -of=bin/ddemangle
$DMD -w -de -dip1000 DustMite/dustmite.d DustMite/splitter.d DustMite/polyhash.d -of=bin/dustmite
cp bin/{rdmd,ddemangle,dustmite} ../installed/bin
# Build & copy reggae
build_reggae_script: |
cd $CIRRUS_WORKING_DIR/..
git clone --recursive https://github.com/atilaneves/reggae.git
cd reggae
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/reggae_version)"
DFLAGS="-O -linkonce-templates" ../dub/bin/dub build -v --combined --compiler="$PWD/../installed/bin/ldc2"
cp bin/reggae ../installed/bin
../installed/bin/reggae --version -b ninja
# Pack artifact
pack_artifact_script: |
cd $CIRRUS_WORKING_DIR/..
mkdir artifacts
if [[ "${CIRRUS_TAG:-}" == v* ]]; then
artifactID=${CIRRUS_TAG:1}
else
artifactID=${CIRRUS_CHANGE_IN_REPO:0:8}
fi
artifactName=ldc2-$artifactID-$CI_OS-x86_64
mv installed $artifactName
chmod -R go=rX $artifactName
gtar -cf - --owner=0 --group=0 $artifactName | 7z a artifacts/$artifactName.tar.xz -si -txz -mx9
# Upload to GitHub release (only for commits on the master branch and tags)
upload_to_github_script: |
cd $CIRRUS_WORKING_DIR
if [[ "${CIRRUS_TAG:-}" == v* ]]; then
tools/upload-to-github.sh $CIRRUS_TAG ../artifacts/ldc2-*.tar.xz
elif [[ "${CIRRUS_TAG:-}" = "" && "$CIRRUS_PR" = "" && "$CIRRUS_BRANCH" = "master" ]]; then
tools/upload-to-github.sh CI ../artifacts/ldc2-*.tar.xz
fi
# Installs Ubuntu 18.04+ prerequisites.
# Requires env variables HOST_LDC_VERSION and EXTRA_APT_PACKAGES.
# Requires env variables HOST_LDC_VERSION, EXTRA_APT_PACKAGES and EXTRA_CMAKE_FLAGS.
install_ubuntu_prerequisites_template: &INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
install_prerequisites_script: |
cd $CIRRUS_WORKING_DIR/..
Expand Down Expand Up @@ -239,88 +330,4 @@ task:
ninja -j$PARALLELISM
bin/ldc2 -version
<< : *COMMON_STEPS_TEMPLATE
# Install LDC & make portable
install_script: |
cd $CIRRUS_WORKING_DIR/..
cd build
ninja install > /dev/null
cd ..
perl -pi -e s?$PWD/install/?%%ldcbinarypath%%/../?g install/etc/ldc2.conf
perl -pi -e "s?,druntime-ldc\",?,druntime-ldc\", \"-gcc=$CC\",?" install/etc/ldc2.conf
cp $CIRRUS_WORKING_DIR/{LICENSE,packaging/README} install
cat install/etc/ldc2.conf
# Now rename the installation dir to test portability
mv install installed
# Run hello-world integration test with shared libs
run_shared_libs_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
echo 'void main() { import std.stdio; writefln("Hello world, %d bits", size_t.sizeof * 8); }' > hello.d
installed/bin/ldc2 hello.d -m64 -of=hello64 -link-defaultlib-shared
./hello64
# Run hello-world integration test with LTO
run_lto_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
installed/bin/ldc2 hello.d -of=hello_thin -flto=thin -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
./hello_thin
installed/bin/ldc2 hello.d -of=hello_full -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
./hello_full
# Run dynamic-compile integration test
run_dynamic_compile_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
installed/bin/ldc2 -enable-dynamic-compile -run $CIRRUS_WORKING_DIR/tests/dynamiccompile/array.d
# Run ImportC integration test
run_importC_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
installed/bin/ldc2 -run $CIRRUS_WORKING_DIR/tests/dmd/runnable/test22597.c
# Build & copy dub
build_dub_script: |
cd $CIRRUS_WORKING_DIR/..
export DMD=$PWD/installed/bin/ldmd2
git clone --recursive https://github.com/dlang/dub.git
cd dub
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/dub_version)"
$DMD -run build.d -O -w -linkonce-templates
cp bin/dub ../installed/bin
../installed/bin/dub --version
# Build & copy dlang tools
build_dlang_tools_script: |
cd $CIRRUS_WORKING_DIR/..
DMD=$PWD/installed/bin/ldmd2
git clone --recursive https://github.com/dlang/tools.git dlang-tools
cd dlang-tools
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/dlang-tools_version)"
mkdir bin
$DMD -w -de -dip1000 rdmd.d -of=bin/rdmd
$DMD -w -de -dip1000 ddemangle.d -of=bin/ddemangle
$DMD -w -de -dip1000 DustMite/dustmite.d DustMite/splitter.d DustMite/polyhash.d -of=bin/dustmite
cp bin/{rdmd,ddemangle,dustmite} ../installed/bin
# Build & copy reggae
build_reggae_script: |
cd $CIRRUS_WORKING_DIR/..
git clone --recursive https://github.com/atilaneves/reggae.git
cd reggae
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/reggae_version)"
DFLAGS="-O -linkonce-templates" ../dub/bin/dub build -v --combined --compiler="$PWD/../installed/bin/ldc2"
cp bin/reggae ../installed/bin
../installed/bin/reggae --version -b ninja
# Pack artifact
pack_artifact_script: |
cd $CIRRUS_WORKING_DIR/..
mkdir artifacts
if [[ "${CIRRUS_TAG:-}" == v* ]]; then
artifactID=${CIRRUS_TAG:1}
else
artifactID=${CIRRUS_CHANGE_IN_REPO:0:8}
fi
artifactName=ldc2-$artifactID-$CI_OS-x86_64
mv installed $artifactName
chmod -R go=rX $artifactName
gtar -cf - --owner=0 --group=0 $artifactName | 7z a artifacts/$artifactName.tar.xz -si -txz -mx9
# Upload to GitHub release (only for commits on the master branch and tags)
upload_to_github_script: |
cd $CIRRUS_WORKING_DIR
if [[ "${CIRRUS_TAG:-}" == v* ]]; then
tools/upload-to-github.sh $CIRRUS_TAG ../artifacts/ldc2-*.tar.xz
elif [[ "${CIRRUS_TAG:-}" = "" && "$CIRRUS_PR" = "" && "$CIRRUS_BRANCH" = "master" ]]; then
tools/upload-to-github.sh CI ../artifacts/ldc2-*.tar.xz
fi
<< : *PACKAGING_STEPS_TEMPLATE

0 comments on commit 703dfba

Please sign in to comment.