-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automated ghc-lib build This PR aims at automating the build of ghc-lib. The current process still has a few manual steps; it needs to be updated because Bintray is going away, so this seemed like a good opportunity to fully automate it. This works like the "patch bazel on Windows" jobs: the filename will contain a hash of the `ci/da-ghc-lib` folder, and the job will run only if the corresponding filename does not yet exist on the GCS bucket. PRs aiming at changing the ghc-lib version will need to run twice: once to create the artifacts, and once to change the `stack-snapshot.yaml` file to match. CHANGELOG_BEGIN CHANGELOG_END
- Loading branch information
1 parent
003549e
commit 2fe320f
Showing
3 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright (c) 2020 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: | ||
vmImage: 'Ubuntu 16.04' | ||
variables: | ||
ghc-lib-sha: 'd2eadb7ef4a6d4f33a6a04056d2e57f11a59ef0f' | ||
base-sha: '9c787d4d24f2b515934c8503ee2bbd7cfac4da20' | ||
patches: '4650347db9a7e8c65831ab83b80da43b28c3deba 833ca63be2ab14871874ccb6974921e8952802e9' | ||
flavor: '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 | ||
echo "Both artifacts exist; no need to run." | ||
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) | ||
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) \ | ||
| tee log | ||
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 stack-snapshot.yaml:" | ||
echo " - archive: $URL_BASE/$LIB" | ||
echo " sha256: \"$(sha256sum ghc-lib-${VERSION}.tar.gz | awk '{print $1}')\"" | ||
echo " - archive: $URL_BASE/$PARSER" | ||
echo " sha256: \"$(sha256sum ghc-lib-parser-${VERSION}.tar.gz | awk '{print $1}')\"" | ||
env: | ||
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters