Lexer: Alternate Layout Rule injects actual not virtual braces
[ghc.git] / .circleci / push-test-metrics.sh
1 #!/usr/bin/env bash
2 # vim: sw=2 et
3 set -euo pipefail
4
5 fail() {
6 echo "ERROR: $*" >&2
7 exit 1
8 }
9
10 if [ "$CIRCLE_REPOSITORY_URL" != "git@github.com:ghc/ghc.git" ]; then
11 exit 0
12 fi
13
14 GHC_ORIGIN=git@git.haskell.org:ghc
15
16 # Add git.haskell.org as a known host.
17 echo "|1|F3mPVCE55+KfApNIMYQ3Dv39sGE=|1bRkvJEJhAN2R0LE/lAjFCEJGl0= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBUZS9jGBkE5UzpSo6irnIgcQcfzvbuIOsFc8+N61FwtZncRntbaKPuUimOFPgeaUZLl6Iajz6IIs7aduU0/v+I=" >> ~/.ssh/known_hosts
18 echo "|1|2VUMjYSRVpT2qJPA0rA9ap9xILY=|5OThkI4ED9V0J+Es7D5FOD55Klk= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+3TLluLAO4lkW60W+N2DFkS+WoRFGqLwHzgd1ifxG9TIm31wChPY3E/hgMnJmgGqWCF4UDUemmyCycEaL7FtKfzjTAclg9EfpQnozyE3T5hIo2WL7SN5O8ttG/bYGuDnn14jLnWwJyN4oz/znWFiDG9e2Oc9YFNlQ+PK8ae5xR4gqBB7EOoj9J1EiPqG2OXRr5Mei3TLsRDU6fnz/e4oFJpKWWeN6M63oePv0qoaGjxcrATZUWsuWrxVMmYo9kP1xRuFJbAUw2m4uVP+793SW1zxySi1HBMtJG+gCDdZZSwYbkV1hassLWBHv1qPttncfX8Zek3Z3VolaTmfWJTo9" >> ~/.ssh/known_hosts
19
20 # Check that a git notes dont already exist.
21 # This is a percausion as we reset refs/notes/perf and we want to avoid data loss.
22 if [ $(git notes --ref=perf list | wc -l) -ne 0 ]
23 then
24 fail "Found an existing git note on HEAD. Expected no git note."
25 fi
26
27 # Assert that the METRICS_FILE exists and can be read.
28 if [ "$METRICS_FILE" = "" ] || ! [ -r $METRICS_FILE ]
29 then
30 fail "Metrics file not found: $METRICS_FILE"
31 fi
32
33 # Reset the git notes and append the metrics file to the notes, then push and return the result.
34 # This is favoured over a git notes merge as it avoids potential data loss/duplication from the merge strategy.
35 function reset_append_note_push {
36 git fetch -f $GHC_ORIGIN refs/notes/perf:refs/notes/perf || true
37 echo "git notes --ref=perf append -F $METRICS_FILE HEAD"
38 git notes --ref=perf append -F $METRICS_FILE HEAD
39 git push $GHC_ORIGIN refs/notes/perf
40 }
41
42 # Push the metrics file as a git note. This may fail if another task pushes a note first. In that case
43 # the latest note is fetched and appended.
44 MAX_RETRY=20
45 until reset_append_note_push || [ $MAX_RETRY -le 0 ]
46 do
47 ((MAX_RETRY--))
48 echo ""
49 echo "Failed to push git notes. Fetching, appending, and retrying... $MAX_RETRY retries left."
50 done