Skip to content

Commit

Permalink
Merge pull request #291 from cashapp/adrw.2023-02-01.hermit
Browse files Browse the repository at this point in the history
Use Hermit for JDK and Gradle setup
  • Loading branch information
adrw authored Feb 1, 2023
2 parents df59b21 + 5bce9fb commit 1f79e14
Show file tree
Hide file tree
Showing 47 changed files with 130 additions and 17 deletions.
22 changes: 6 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ jobs:
steps:
- checkout
- run:
name: "Download and extract OpenJDK 11"
command: |
mkdir -p ~/openjdk-11 && cd ~/openjdk-11 && curl -sSL https://download.oracle.com/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz | tar -xz --strip-components 1
echo '
export PATH="$JAVA_HOME/bin:$PATH"
export JAVA_HOME="$HOME/openjdk-11"
' >> $BASH_ENV
name: Hermit
command: ./bin/hermit env -r >> $BASH_ENV
- run:
name: "Compile"
command: |
./gradlew testClasses --parallel --build-cache
gradle testClasses --parallel --build-cache
- save_cache:
paths:
- ~/.gradle/caches
Expand All @@ -46,13 +41,8 @@ jobs:
- v1-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}
- v1-master-compile
- run:
name: "Download and extract OpenJDK 11"
command: |
mkdir -p ~/openjdk-11 && cd ~/openjdk-11 && curl -sSL https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz | tar -xz --strip-components 1
echo '
export PATH="$JAVA_HOME/bin:$PATH"
export JAVA_HOME="$HOME/openjdk-11"
' >> $BASH_ENV
name: Hermit
command: ./bin/hermit env -r >> $BASH_ENV
- run:
name: "Dump environment variables"
command: env
Expand All @@ -64,7 +54,7 @@ jobs:
command: docker run -d -p 3306:3306 --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=1 mysql:5.7 --sql-mode=""
- run:
name: "Build and test"
command: ./gradlew build check -i --parallel --build-cache
command: gradle build check -i --parallel --build-cache
- run:
name: Collect test results
command: |
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ Backfila is a service that manages backfill state, calling into other services t

Note: some instructions here are out of date

## Hermit

[Hermit](https://cashapp.github.io/hermit/) is used to manage build dependencies like local Java and Gradle versions.

Install [Hermit shell hooks](https://cashapp.github.io/hermit/usage/shell/?h=shell) or run the following manually.

```
cd backfila
. ./bin/activate-hermit
```

## Building
Build backfila:

```
$ ./gradlew clean shadowJar
$ gradle clean shadowJar
```

## Run the Service
Expand Down
1 change: 1 addition & 0 deletions bin/.gradle-7.6.pkg
1 change: 1 addition & 0 deletions bin/[email protected]
1 change: 1 addition & 0 deletions bin/[email protected]
7 changes: 7 additions & 0 deletions bin/README.hermit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hermit environment

This is a [Hermit](https://github.com/cashapp/hermit) bin directory.

The symlinks in this directory are managed by Hermit and will automatically
download and install Hermit itself as well as packages. These packages are
local to this environment.
21 changes: 21 additions & 0 deletions bin/activate-hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# This file must be used with "source bin/activate-hermit" from bash or zsh.
# You cannot run it directly
#
# THIS FILE IS GENERATED; DO NOT MODIFY

if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi

BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")"
if "${BIN_DIR}/hermit" noop > /dev/null; then
eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")"

if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then
hash -r 2>/dev/null
fi

echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated"
fi
1 change: 1 addition & 0 deletions bin/corepack
1 change: 1 addition & 0 deletions bin/gradle
43 changes: 43 additions & 0 deletions bin/hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#
# THIS FILE IS GENERATED; DO NOT MODIFY

set -eo pipefail

export HERMIT_USER_HOME=~

if [ -z "${HERMIT_STATE_DIR}" ]; then
case "$(uname -s)" in
Darwin)
export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit"
;;
Linux)
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit"
;;
esac
fi

export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://github.com/cashapp/hermit/releases/download/stable}"
HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")"
export HERMIT_CHANNEL
export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit}

if [ ! -x "${HERMIT_EXE}" ]; then
echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2
INSTALL_SCRIPT="$(mktemp)"
# This value must match that of the install script
INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38"
if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then
curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}"
else
# Install script is versioned by its sha256sum value
curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}"
# Verify install script's sha256sum
openssl dgst -sha256 "${INSTALL_SCRIPT}" | \
awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \
'$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}'
fi
/bin/bash "${INSTALL_SCRIPT}" 1>&2
fi

exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@"
Empty file added bin/hermit.hcl
Empty file.
1 change: 1 addition & 0 deletions bin/jaotc
1 change: 1 addition & 0 deletions bin/jar
1 change: 1 addition & 0 deletions bin/jarsigner
1 change: 1 addition & 0 deletions bin/java
1 change: 1 addition & 0 deletions bin/javac
1 change: 1 addition & 0 deletions bin/javadoc
1 change: 1 addition & 0 deletions bin/javap
1 change: 1 addition & 0 deletions bin/jcmd
1 change: 1 addition & 0 deletions bin/jconsole
1 change: 1 addition & 0 deletions bin/jdb
1 change: 1 addition & 0 deletions bin/jdeprscan
1 change: 1 addition & 0 deletions bin/jdeps
1 change: 1 addition & 0 deletions bin/jfr
1 change: 1 addition & 0 deletions bin/jhsdb
1 change: 1 addition & 0 deletions bin/jimage
1 change: 1 addition & 0 deletions bin/jinfo
1 change: 1 addition & 0 deletions bin/jjs
1 change: 1 addition & 0 deletions bin/jlink
1 change: 1 addition & 0 deletions bin/jmap
1 change: 1 addition & 0 deletions bin/jmod
1 change: 1 addition & 0 deletions bin/jps
1 change: 1 addition & 0 deletions bin/jrunscript
1 change: 1 addition & 0 deletions bin/jshell
1 change: 1 addition & 0 deletions bin/jstack
1 change: 1 addition & 0 deletions bin/jstat
1 change: 1 addition & 0 deletions bin/jstatd
1 change: 1 addition & 0 deletions bin/keytool
1 change: 1 addition & 0 deletions bin/node
1 change: 1 addition & 0 deletions bin/npm
1 change: 1 addition & 0 deletions bin/npx
1 change: 1 addition & 0 deletions bin/pack200
1 change: 1 addition & 0 deletions bin/rmic
1 change: 1 addition & 0 deletions bin/rmid
1 change: 1 addition & 0 deletions bin/rmiregistry
1 change: 1 addition & 0 deletions bin/serialver
1 change: 1 addition & 0 deletions bin/unpack200

0 comments on commit 1f79e14

Please sign in to comment.