Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate release CI back to github #9437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# release CI for FreeBSD
compute_engine_instance:
image_project: freebsd-org-cloud-dev
image: family/freebsd-13-2
platform: freebsd
disk: 100 # Gb

build_task:
timeout_in: 120m
only_if: $CIRRUS_TAG != ''
env:
ADD_CABAL_ARGS: "--enable-split-sections"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be implemented in cabal.project.release under a conditional if os(FreeBSD)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this be conditional on platform? AFAIK it's only Windows that doesn't support it, and it's a win everywhere else. (Macs ignore the option since they always do dead code stripping, although GHC needed a lot of hackery to make use of it safely, but that's not our problem.)

ARCH: 64
ARTIFACT: "x86_64-portbld-freebsd"
CIRRUS_CLONE_SUBMODULES: true
DISTRO: na
GHC_VERSION: 9.2.4
GITHUB_WORKSPACE: ${CIRRUS_WORKING_DIR}
RUNNER_OS: FreeBSD
TARBALL_EXT: tar.xz
TZ: Asia/Singapore
install_script:
- sed -i.bak -e 's/quarterly/latest/' /etc/pkg/FreeBSD.conf
- pkg install -y ghc hs-cabal-install git bash misc/compat10x misc/compat11x misc/compat12x gmake llvm14 patchelf tree gmp libiconv
script:
- tzsetup Etc/GMT
- adjkerntz -a
- bash .github/scripts/build.sh
binaries_artifacts:
path: "out/*"

27 changes: 27 additions & 0 deletions .github/scripts/brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

set -eux

# shellcheck disable=SC1091
. .github/scripts/env.sh

if [ -e "$HOME/.brew" ] ; then
(
cd "$HOME/.brew"
git fetch --depth 1
git reset --hard origin/master
)
else
git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.brew"
fi
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"

mkdir -p "$CI_PROJECT_DIR/.brew_cache"
export HOMEBREW_CACHE="$CI_PROJECT_DIR/.brew_cache"
mkdir -p "$CI_PROJECT_DIR/.brew_logs"
export HOMEBREW_LOGS="$CI_PROJECT_DIR/.brew_logs"
mkdir -p /private/tmp/.brew_tmp
export HOMEBREW_TEMP=/private/tmp/.brew_tmp

#brew update
brew install ${1+"$@"}
66 changes: 66 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

set -eux
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer explicit tracing instead of increasing default verbosity everywhere because it adds a permanent tax on reading and storing logs. I feel like a lot of my career has been spent figuring out how to filter useless log messages. But maybe that's just me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just you; Splunk exists for a reason. (But it costs way too much.)


# shellcheck disable=SC1091
. .github/scripts/env.sh
# shellcheck disable=SC1091
. .github/scripts/common.sh

uname -a
uname -p
uname
pwd
env

# ensure ghcup
install_ghcup

# build
ghcup install ghc "${GHC_VERSION}"
ghcup set ghc "${GHC_VERSION}"
sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project
ecabal update
ecabal user-config diff
ecabal user-config init -f
"ghc-${GHC_VERSION}" --info
"ghc" --info

# https://github.com/haskell/cabal/issues/7313#issuecomment-811851884
if [ "$(getconf LONG_BIT)" == "32" ] || [ "${DISTRO}" == "CentOS" ] ; then
echo 'constraints: lukko -ofd-locking' >> cabal.project.release.local
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should just be included in cabal.project.release under a if arch(I386) conditional. I am not sure if there is something specific to CentOS, it does not seem to be mentioned in the thread above

fi

# shellcheck disable=SC2206
args=(
-w "ghc-$GHC_VERSION"
--disable-profiling
--enable-executable-stripping
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other things that should be in cabal.project.release

--project-file=cabal.project.release
${ADD_CABAL_ARGS}
)

run cabal v2-build "${args[@]}" cabal-install

mkdir -p "$CI_PROJECT_DIR/out"
# shellcheck disable=SC2154
cp "$(cabal list-bin "${args[@]}" cabal-install:exe:cabal)" "$CI_PROJECT_DIR/out/cabal$ext"
cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json"
cd "$CI_PROJECT_DIR/out/"

# create tarball/zip
TARBALL_PREFIX="cabal-install-$("$CI_PROJECT_DIR/out/cabal" --numeric-version)"
case "${TARBALL_EXT}" in
zip)
zip "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
;;
tar.xz)
tar caf "${TARBALL_PREFIX}-${ARTIFACT}.${TARBALL_EXT}" "cabal${ext}" plan.json
;;
*)
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
;;
esac

rm cabal plan.json

110 changes: 110 additions & 0 deletions .github/scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

# shellcheck disable=SC1091
. .github/scripts/env.sh

# Colors
RED="0;31"
LT_BROWN="1;33"
LT_BLUE="1;34"

ecabal() {
cabal "$@"
}

nonfatal() {
"$@" || "$* failed"
}

sha_sum() {
if [ "${RUNNER_OS}" = "FreeBSD" ] ; then
sha256 "$@"
else
sha256sum "$@"
fi
}

git_describe() {
git config --global --get-all safe.directory | grep '^\*$' || git config --global --add safe.directory "*"
git describe --always
}

install_ghcup() {
# find "$GHCUP_INSTALL_BASE_PREFIX"
mkdir -p "$GHCUP_BIN"
mkdir -p "$GHCUP_BIN"/../cache

if [ "${RUNNER_OS}" = "FreeBSD" ] ; then
curl -o ghcup https://downloads.haskell.org/ghcup/tmp/x86_64-portbld-freebsd-ghcup-0.1.18.1
chmod +x ghcup
mv ghcup "$HOME/.local/bin/ghcup"
else
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_MINIMAL=1 sh
source "$(dirname "${GHCUP_BIN}")/env"
ghcup install cabal --set "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
fi
}

strip_binary() {
(
set -e
local binary=$1
case "$(uname -s)" in
"Darwin"|"darwin")
;;
MSYS_*|MINGW*)
;;
*)
strip -s "${binary}"
;;
esac
)
}

# GitLab Pipelines log section delimiters
# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664
start_section() {
name="$1"
echo -e "section_start:$(date +%s):$name\015\033[0K"
}

end_section() {
name="$1"
echo -e "section_end:$(date +%s):$name\015\033[0K"
}

echo_color() {
local color="$1"
local msg="$2"
echo -e "\033[${color}m${msg}\033[0m"
}

error() { echo_color "${RED}" "$1"; }
warn() { echo_color "${LT_BROWN}" "$1"; }
info() { echo_color "${LT_BLUE}" "$1"; }

fail() { error "error: $1"; exit 1; }

run() {
info "Running $*..."
"$@" || ( error "$* failed"; return 1; )
}

emake() {
if command -v gmake >/dev/null 2>&1 ; then
gmake "$@"
else
make "$@"
fi
}

mktempdir() {
case "$(uname -s)" in
"Darwin"|"darwin")
mktemp -d -t cabal_ci.XXXXXXX
;;
*)
mktemp -d
;;
esac
}
38 changes: 38 additions & 0 deletions .github/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

mkdir -p "$HOME"/.local/bin

if [ "${RUNNER_OS}" = "Windows" ] ; then
ext=".exe"
else
# shellcheck disable=SC2034
ext=''
fi

export PATH="$HOME/.local/bin:$PATH"

export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
export BOOTSTRAP_HASKELL_CABAL_VERSION="${CABAL_VER:-3.8.1.0}"
export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=no
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK=yes
export BOOTSTRAP_HASKELL_ADJUST_BASHRC=1

if [ "${RUNNER_OS}" = "Windows" ] ; then
# on windows use pwd to get unix style path
CI_PROJECT_DIR="$(pwd)"
export CI_PROJECT_DIR
export GHCUP_INSTALL_BASE_PREFIX="/c"
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/ghcup/bin"
export PATH="$GHCUP_BIN:$PATH"
export CABAL_DIR="C:\\Users\\runneradmin\\AppData\\Roaming\\cabal"
else
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}"
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin"
export PATH="$GHCUP_BIN:$PATH"
export CABAL_DIR="$CI_PROJECT_DIR/cabal"
export CABAL_CACHE="$CI_PROJECT_DIR/cabal-cache"
fi

export DEBIAN_FRONTEND=noninteractive
export TZ=Asia/Singapore
Loading
Loading