Skip to content

Commit f2e6cd4

Browse files
committed
Migrate release CI back to github
1 parent 269fd80 commit f2e6cd4

13 files changed

+900
-159
lines changed

.cirrus.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# release CI for FreeBSD
2+
compute_engine_instance:
3+
image_project: freebsd-org-cloud-dev
4+
image: family/freebsd-13-2
5+
platform: freebsd
6+
disk: 100 # Gb
7+
8+
build_task:
9+
timeout_in: 120m
10+
only_if: $CIRRUS_TAG != ''
11+
env:
12+
ADD_CABAL_ARGS: "--enable-split-sections"
13+
ARCH: 64
14+
ARTIFACT: "x86_64-portbld-freebsd"
15+
CIRRUS_CLONE_SUBMODULES: true
16+
DISTRO: na
17+
GHC_VERSION: 9.2.8
18+
GITHUB_WORKSPACE: ${CIRRUS_WORKING_DIR}
19+
RUNNER_OS: FreeBSD
20+
TARBALL_EXT: tar.xz
21+
TZ: Asia/Singapore
22+
install_script:
23+
- sed -i.bak -e 's/quarterly/latest/' /etc/pkg/FreeBSD.conf
24+
- pkg install -y ghc hs-cabal-install git bash misc/compat10x misc/compat11x misc/compat12x gmake llvm14 patchelf tree gmp libiconv
25+
script:
26+
- tzsetup Etc/GMT
27+
- adjkerntz -a
28+
- bash .github/scripts/build.sh
29+
binaries_artifacts:
30+
path: "out/*"
31+

.github/scripts/brew.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
set -eux
4+
5+
# shellcheck disable=SC1091
6+
. .github/scripts/env.sh
7+
8+
if [ -e "$HOME/.brew" ] ; then
9+
(
10+
cd "$HOME/.brew"
11+
git fetch --depth 1
12+
git reset --hard origin/master
13+
)
14+
else
15+
git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.brew"
16+
fi
17+
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"
18+
19+
mkdir -p "$CI_PROJECT_DIR/.brew_cache"
20+
export HOMEBREW_CACHE="$CI_PROJECT_DIR/.brew_cache"
21+
mkdir -p "$CI_PROJECT_DIR/.brew_logs"
22+
export HOMEBREW_LOGS="$CI_PROJECT_DIR/.brew_logs"
23+
mkdir -p /private/tmp/.brew_tmp
24+
export HOMEBREW_TEMP=/private/tmp/.brew_tmp
25+
26+
#brew update
27+
brew install ${1+"$@"}
28+

.github/scripts/build.sh

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
# shellcheck disable=SC1091
6+
. .github/scripts/env.sh
7+
# shellcheck disable=SC1091
8+
. .github/scripts/common.sh
9+
10+
uname -a
11+
uname -p
12+
uname
13+
pwd
14+
env
15+
16+
# ensure ghcup
17+
install_ghcup
18+
19+
# build
20+
ghcup install ghc "${GHC_VERSION}"
21+
ghcup set ghc "${GHC_VERSION}"
22+
sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project
23+
ecabal update
24+
ecabal user-config diff
25+
ecabal user-config init -f
26+
"ghc-${GHC_VERSION}" --info
27+
"ghc" --info
28+
29+
# https://github.com/haskell/cabal/issues/7313#issuecomment-811851884
30+
if [ "$(getconf LONG_BIT)" == "32" ] || [ "${DISTRO}" == "CentOS" ] ; then
31+
echo 'constraints: lukko -ofd-locking' >> cabal.release.project.local
32+
fi
33+
34+
# shellcheck disable=SC2206
35+
args=(
36+
-w "ghc-$GHC_VERSION"
37+
--disable-profiling
38+
--enable-executable-stripping
39+
--project-file=cabal.release.project
40+
${ADD_CABAL_ARGS}
41+
)
42+
43+
run cabal v2-build "${args[@]}" cabal-install
44+
45+
mkdir -p "$CI_PROJECT_DIR/out"
46+
# shellcheck disable=SC2154
47+
cp "$(cabal list-bin "${args[@]}" cabal-install:exe:cabal)" "$CI_PROJECT_DIR/out/cabal$ext"
48+
cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json"
49+
cd "$CI_PROJECT_DIR/out/"
50+
51+
# create tarball/zip
52+
TARBALL_PREFIX="cabal-install-$("$CI_PROJECT_DIR/out/cabal" --numeric-version)"
53+
case "${TARBALL_EXT}" in
54+
zip)
55+
zip "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
56+
;;
57+
tar.xz)
58+
tar caf "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
59+
;;
60+
*)
61+
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
62+
;;
63+
esac
64+
65+
rm cabal plan.json
66+

.github/scripts/common.sh

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. .github/scripts/env.sh
5+
6+
# Colors
7+
RED="0;31"
8+
LT_BROWN="1;33"
9+
LT_BLUE="1;34"
10+
11+
ecabal() {
12+
cabal "$@"
13+
}
14+
15+
nonfatal() {
16+
"$@" || "$* failed"
17+
}
18+
19+
sha_sum() {
20+
if [ "${RUNNER_OS}" = "FreeBSD" ] ; then
21+
sha256 "$@"
22+
else
23+
sha256sum "$@"
24+
fi
25+
}
26+
27+
git_describe() {
28+
git config --global --get-all safe.directory | grep '^\*$' || git config --global --add safe.directory "*"
29+
git describe --always
30+
}
31+
32+
install_ghcup() {
33+
# find "$GHCUP_INSTALL_BASE_PREFIX"
34+
mkdir -p "$GHCUP_BIN"
35+
mkdir -p "$GHCUP_BIN"/../cache
36+
37+
if [ "${RUNNER_OS}" = "FreeBSD" ] ; then
38+
curl -o ghcup https://downloads.haskell.org/~ghcup/x86_64-portbld-freebsd-ghcup
39+
chmod +x ghcup
40+
mv ghcup "$HOME/.local/bin/ghcup"
41+
else
42+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_MINIMAL=1 sh
43+
source "$(dirname "${GHCUP_BIN}")/env"
44+
ghcup install cabal --set "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
45+
fi
46+
}
47+
48+
strip_binary() {
49+
(
50+
set -e
51+
local binary=$1
52+
case "$(uname -s)" in
53+
"Darwin"|"darwin")
54+
;;
55+
MSYS_*|MINGW*)
56+
;;
57+
*)
58+
strip -s "${binary}"
59+
;;
60+
esac
61+
)
62+
}
63+
64+
# GitLab Pipelines log section delimiters
65+
# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664
66+
start_section() {
67+
name="$1"
68+
echo -e "section_start:$(date +%s):$name\015\033[0K"
69+
}
70+
71+
end_section() {
72+
name="$1"
73+
echo -e "section_end:$(date +%s):$name\015\033[0K"
74+
}
75+
76+
echo_color() {
77+
local color="$1"
78+
local msg="$2"
79+
echo -e "\033[${color}m${msg}\033[0m"
80+
}
81+
82+
error() { echo_color "${RED}" "$1"; }
83+
warn() { echo_color "${LT_BROWN}" "$1"; }
84+
info() { echo_color "${LT_BLUE}" "$1"; }
85+
86+
fail() { error "error: $1"; exit 1; }
87+
88+
run() {
89+
info "Running $*..."
90+
"$@" || ( error "$* failed"; return 1; )
91+
}
92+
93+
emake() {
94+
if command -v gmake >/dev/null 2>&1 ; then
95+
gmake "$@"
96+
else
97+
make "$@"
98+
fi
99+
}
100+
101+
mktempdir() {
102+
case "$(uname -s)" in
103+
"Darwin"|"darwin")
104+
mktemp -d -t cabal_ci.XXXXXXX
105+
;;
106+
*)
107+
mktemp -d
108+
;;
109+
esac
110+
}

.github/scripts/env.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
mkdir -p "$HOME"/.local/bin
4+
5+
if [ "${RUNNER_OS}" = "Windows" ] ; then
6+
ext=".exe"
7+
else
8+
# shellcheck disable=SC2034
9+
ext=''
10+
fi
11+
12+
export PATH="$HOME/.local/bin:$PATH"
13+
14+
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
15+
export BOOTSTRAP_HASKELL_CABAL_VERSION="${CABAL_VER:-3.12.1.0}"
16+
export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=no
17+
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK=yes
18+
export BOOTSTRAP_HASKELL_ADJUST_BASHRC=1
19+
20+
if [ "${RUNNER_OS}" = "freebsd" ] ; then
21+
export RUNNER_OS=FreeBSD
22+
fi
23+
24+
if [ "${RUNNER_OS}" = "Windows" ] ; then
25+
# on windows use pwd to get unix style path
26+
CI_PROJECT_DIR="$(pwd)"
27+
export CI_PROJECT_DIR
28+
export GHCUP_INSTALL_BASE_PREFIX="/c"
29+
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/ghcup/bin"
30+
export PATH="$GHCUP_BIN:$PATH"
31+
export CABAL_DIR="C:\\Users\\runneradmin\\AppData\\Roaming\\cabal"
32+
else
33+
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}"
34+
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
35+
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin"
36+
export PATH="$GHCUP_BIN:$PATH"
37+
export CABAL_DIR="$CI_PROJECT_DIR/cabal"
38+
export CABAL_CACHE="$CI_PROJECT_DIR/cabal-cache"
39+
fi
40+
41+
export DEBIAN_FRONTEND=noninteractive
42+
export TZ=Asia/Singapore

0 commit comments

Comments
 (0)