daml/ci/da-ghc-lib/compile.yml
Gary Verhaegen d2e2c21684
update copyright headers (#12240)
New year, new copyright, new expected unknown issues with various files
that won't be covered by the script and/or will be but shouldn't change.

I'll do the details on Jan 1, but would appreciate this being
preapproved so I can actually get it merged by then.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-03 16:36:51 +00:00

95 lines
4.1 KiB
YAML

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
parameters:
- name: final_job_name
jobs:
- job: ${{ parameters.final_job_name }}
pool:
name: ubuntu_20_04
demands: assignment -equals default
variables:
ghc-lib-sha: '362d4f38a7ac10521393de9b7ad942a77a2605be'
base-sha: '9c787d4d24f2b515934c8503ee2bbd7cfac4da20'
patches: '0f5fbd5cdaf57041214c64c61e9309042f394bc5 833ca63be2ab14871874ccb6974921e8952802e9'
flavor: 'da-ghc-8.8.1'
steps:
- checkout: self
- bash: |
set -euo pipefail
CACHE_KEY="$(find ci/da-ghc-lib -type f -print0 | sort -z | xargs -r0 md5sum | md5sum | awk '{print $1}')"
LIB="da-ghc-lib/ghc-lib-$CACHE_KEY.tar.gz"
PARSER="da-ghc-lib/ghc-lib-parser-$CACHE_KEY.tar.gz"
URL_BASE="https://daml-binaries.da-ext.net"
LIB_STATUS="$(curl -Is "$URL_BASE/$LIB" | head -1 | awk '{print $2}')"
PARSER_STATUS="$(curl -Is "$URL_BASE/$PARSER" | head -1 | awk '{print $2}')"
if [ "200" = "$LIB_STATUS" ] && [ "200" = "$PARSER_STATUS" ]; then
curl -s "$URL_BASE/$LIB" --output lib.tar.gz
curl -s "$URL_BASE/$PARSER" --output parser.tar.gz
echo "Both artifacts exist; no need to run."
echo "Check the following lines of bazel-haskell-deps.bzl:"
echo "GHC_LIB_REV = \"$CACHE_KEY\""
echo "GHC_LIB_SHA256 = \"$(sha256sum lib.tar.gz | awk '{print $1}')\""
echo "GHC_LIB_VERSION = \"8.8.1\""
echo "GHC_LIB_PARSER_REV = \"$CACHE_KEY\""
echo "GHC_LIB_PARSER_SHA256 = \"$(sha256sum parser.tar.gz | awk '{print $1}')\""
echo "GHC_LIB_PARSER_VERSION = \"8.8.1\""
rm -f lib.tar.gz parser.tar.gz
exit 0
fi
DIR="$(pwd)"
WORKDIR="$(mktemp -d -p "$(pwd)")"
cleanup() {
rm -rf "$WORKDIR"
}
trap cleanup EXIT
cd $WORKDIR
git clone https://github.com/digital-asset/ghc-lib.git
cd ghc-lib
git checkout $(ghc-lib-sha)
mkdir -p ~/.stack
echo -e "system-ghc: true\ninstall-ghc: false" > ~/.stack/config.yaml
cat ~/.stack/config.yaml
STACK_CMD="stack runhaskell --package extra \
--package optparse-applicative \
CI.hs \
-- \
--da \
--merge-base-sha=$(base-sha) \
$(for p in $(patches); do echo -n "--patch $p "; done) \
--gen-flavor=$(flavor) \
--version-suffix= \
| tee log"
export NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/cc855b133100a956d4587079e27c5704cbc8342b.tar.gz
# We need GHC 8.10.4 for running ghc-lib-gen and GHC 8.6.5 to build GHC.
nix-shell -p stack -p gmp -p autoconf269 -p automake -p coreutils -p perl -p m4 -p 'haskell.packages.ghc8104.ghcWithPackages(_: [])' 'haskell.packages.ghc865Binary.ghcWithPackages(_: [])' --command "$STACK_CMD"
VERSION=$(cat log | tail -1)
GCS_KEY=$(mktemp)
cleanup() {
rm -rf $GCS_KEY
rm -rf "$WORKDIR"
}
trap cleanup EXIT
# This will break on external PRs.
echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > $GCS_KEY
gcloud auth activate-service-account --key-file=$GCS_KEY
BOTO_CONFIG=/dev/null gsutil cp -n "ghc-lib-${VERSION}.tar.gz" "gs://daml-binaries/$LIB"
BOTO_CONFIG=/dev/null gsutil cp -n "ghc-lib-parser-${VERSION}.tar.gz" "gs://daml-binaries/$PARSER"
echo "Please add(/replace) the following lines to bazel-haskell-deps.bzl:"
echo "GHC_LIB_REV = \"$CACHE_KEY\""
echo "GHC_LIB_SHA256 = \"$(sha256sum ghc-lib-${VERSION}.tar.gz | awk '{print $1}')\""
echo "GHC_LIB_VERSION = \"8.8.1\""
echo "GHC_LIB_PARSER_REV = \"$CACHE_KEY\""
echo "GHC_LIB_PARSER_SHA256 = \"$(sha256sum ghc-lib-parser-${VERSION}.tar.gz | awk '{print $1}')\""
echo "GHC_LIB_PARSER_VERSION = \"8.8.1\""
env:
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)