Skip to content

Commit e09f540

Browse files
committed
Migrate to github CI
1 parent b0457a5 commit e09f540

File tree

20 files changed

+1259
-907
lines changed

20 files changed

+1259
-907
lines changed

.cirrus.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# release CI for FreeBSD
2+
compute_engine_instance:
3+
image_project: freebsd-org-cloud-dev
4+
image: family/freebsd-13-1
5+
platform: freebsd
6+
disk: 100 # Gb
7+
8+
build_task:
9+
name: build
10+
timeout_in: 120m
11+
only_if: $CIRRUS_TAG != ''
12+
env:
13+
AWS_ACCESS_KEY_ID: ENCRYPTED[dc5896620ebc12e98e6bbe96f72c5a2fe3785f439b7b2346797355f8d329a4bfd8ef6e58086bfc014be0d914424101cd]
14+
AWS_SECRET_ACCESS_KEY: ENCRYPTED[6501cd594aca08c6c67cc679dd6f6d30db0cd44a81cceddebf32bb3d0a37f9af19cd71ddb7169d3f7b284a7829969f9e]
15+
S3_HOST: ENCRYPTED[d3fef1b5850e85d80dd1684370b53183df2218f2d36509108a2703371afd9ebd3f9596ad4de52487c15ea29baed606b7]
16+
TARBALL_EXT: "tar.xz"
17+
ARCH: 64
18+
ARTIFACT: "x86_64-freebsd"
19+
DISTRO: "na"
20+
RUNNER_OS: "FreeBSD"
21+
ADD_CABAL_ARGS: "--enable-split-sections"
22+
GITHUB_WORKSPACE: ${CIRRUS_WORKING_DIR}
23+
install_script: pkg install -y hs-cabal-install git bash misc/compat10x misc/compat11x misc/compat12x gmake patchelf tree
24+
script:
25+
- tzsetup Etc/GMT
26+
- adjkerntz -a
27+
- bash .github/scripts/build.sh
28+
- bash .github/scripts/test.sh
29+
# binaries_cache: &binaries_cache
30+
# folder: out
31+
# fingerprint_script:
32+
# - ghc --numeric-version
33+
# - cat cabal.project
34+
# - cat haskell-language-server.cabal
35+
# - cat dist-newstyle/cache/plan.json
36+
binaries_artifacts:
37+
path: "out/*"
38+
39+
# release_task:
40+
# name: "Release"
41+
# only_if: $CIRRUS_TAG != ''
42+
# depends_on: build
43+
# env:
44+
# GITHUB_TOKEN: ENCRYPTED[9d9b54424cb18abc9067436c729a77e0486805eff1903bc5b2c591696850f8db7cebac3f29cfa3b119ebb6fd2e98a839]
45+
# install_script: pkg install -y curl bash jq
46+
# binaries_cache: *binaries_cache
47+
# upload_script: |
48+
# #!/bin/bash
49+
#
50+
# if [[ "$CIRRUS_RELEASE" == "" ]]; then
51+
# NUM_TRIES=0
52+
# until [ $NUM_TRIES -eq 20 ]
53+
# do
54+
# echo "Retrying to find a release associated with this tag"
55+
# CIRRUS_RELEASE=$(curl -sL https://api.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/tags/$CIRRUS_TAG | jq -r '.id')
56+
# [[ "$CIRRUS_RELEASE" != "null" ]] && break
57+
# NUM_TRIES=$((NUM_TRIES+1))
58+
# sleep 30
59+
# done
60+
# fi
61+
#
62+
# if [[ "$GITHUB_TOKEN" == "" ]]; then
63+
# echo "Please provide GitHub access token via GITHUB_TOKEN environment variable!"
64+
# exit 1
65+
# fi
66+
#
67+
# for fpath in out/*
68+
# do
69+
# echo "Uploading $fpath..."
70+
# name=$(basename "$fpath")
71+
# url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets?name=$name"
72+
# echo "Uploading to $url_to_upload"
73+
# curl -X POST \
74+
# --data-binary @$fpath \
75+
# --header "Authorization: token $GITHUB_TOKEN" \
76+
# --header "Content-Type: application/x-xz-compressed-tar" \
77+
# $url_to_upload
78+
# done

.github/scripts/brew.sh

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

.github/scripts/build.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
. .github/scripts/env.sh
6+
. .github/scripts/common.sh
7+
8+
uname -a
9+
uname -p
10+
uname
11+
pwd
12+
env
13+
14+
# ensure ghcup
15+
if ! command -v ghcup ; then
16+
install_ghcup
17+
fi
18+
19+
# ensure cabal-cache
20+
download_cabal_cache "$HOME/.local/bin/cabal-cache"
21+
22+
23+
# build
24+
ecabal update
25+
26+
mkdir -p "$CI_PROJECT_DIR/plan.json"
27+
mkdir -p "$CI_PROJECT_DIR/out"
28+
29+
case "$(uname)" in
30+
MSYS_*|MINGW*)
31+
for ghc in $(cat bindist/ghcs-Msys) ; do
32+
GHC_VERSION="$(echo "${ghc}" | tr -d '\r')"
33+
args=( -O2 -w "ghc-$GHC_VERSION" --project-file cabal.project --disable-profiling --disable-tests --enable-executable-stripping ${ADD_CABAL_ARGS})
34+
ghcup install ghc "${GHC_VERSION}"
35+
ghcup set ghc "${GHC_VERSION}"
36+
"ghc-${GHC_VERSION}" --info
37+
"ghc" --info
38+
# Shorten binary names
39+
# due to MAX_PATH issues on windows
40+
sed -i.bak -e 's/haskell-language-server/hls/g' \
41+
-e 's/haskell_language_server/hls/g' \
42+
haskell-language-server.cabal cabal.project
43+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
44+
src/**/*.hs exe/*.hs
45+
46+
47+
# shellcheck disable=SC2068
48+
build_with_cache ${args[@]} exe:hls exe:hls-wrapper
49+
cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/plan.json/${ARTIFACT}-ghc-${GHC_VERSION}-plan.json"
50+
51+
# shellcheck disable=SC2068
52+
cp "$(cabal list-bin -v0 ${args[@]} exe:hls)" "$CI_PROJECT_DIR/out/haskell-language-server-${GHC_VERSION}"${ext}
53+
# shellcheck disable=SC2068
54+
cp "$(cabal list-bin -v0 ${args[@]} exe:hls-wrapper)" "$CI_PROJECT_DIR/out/haskell-language-server-wrapper"${ext}
55+
ghcup rm ghc "${GHC_VERSION}"
56+
done
57+
;;
58+
*)
59+
sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project
60+
emake --version
61+
emake GHCUP=ghcup CABAL_CACHE_BIN=cabal-cache.sh S3_HOST="${S3_HOST}" S3_KEY="${ARTIFACT}" hls
62+
emake GHCUP=ghcup bindist
63+
(
64+
cd out/
65+
for pj in *plan.json ; do
66+
mv "${pj}" "$CI_PROJECT_DIR/plan.json/${ARTIFACT}-${pj}"
67+
done
68+
)
69+
rm -rf out/*.*.*
70+
;;
71+
esac
72+
73+
# create tarball/zip
74+
TARBALL_PREFIX="haskell-language-server"
75+
case "${TARBALL_EXT}" in
76+
zip)
77+
HLS_VERSION="$("$CI_PROJECT_DIR/out/haskell-language-server-wrapper" --numeric-version)"
78+
(
79+
cd "$CI_PROJECT_DIR/out/"
80+
zip "${TARBALL_PREFIX}-${HLS_VERSION}-${ARTIFACT}.zip" haskell-language-server-*
81+
find . -mindepth 1 -maxdepth 1 \! -name '*.zip' -exec rm -rf '{}' \;
82+
)
83+
;;
84+
tar.xz)
85+
emake --version
86+
HLS_VERSION="$(emake -s -C out/bindist/haskell-language-server-* version)"
87+
emake TARBALL="${TARBALL_PREFIX}-${HLS_VERSION}-${ARTIFACT}.tar.xz" bindist-tar
88+
emake GHCUP=ghcup clean-ghcs
89+
find out -mindepth 1 -maxdepth 1 \! -name '*.tar.xz' -exec rm -rf '{}' \;
90+
;;
91+
*)
92+
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
93+
;;
94+
esac
95+
96+
mv "$CI_PROJECT_DIR"/plan.json/* out/

.github/scripts/cabal-cache.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
case "$(uname -s)" in
4+
MSYS_*|MINGW*)
5+
ext=".exe"
6+
;;
7+
*)
8+
ext=""
9+
;;
10+
esac
11+
12+
if [ -n "${CABAL_CACHE_DISABLE}" ] ; then
13+
echo "cabal-cache disabled (CABAL_CACHE_DISABLE set)"
14+
elif [ -n "${CABAL_CACHE_NONFATAL}" ] ; then
15+
"cabal-cache${ext}" "$@" || echo "cabal-cache failed (CABAL_CACHE_NONFATAL set)"
16+
else
17+
exec "cabal-cache${ext}" "$@"
18+
fi
19+

0 commit comments

Comments
 (0)