Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

Commit

Permalink
Use AWS and cache in image
Browse files Browse the repository at this point in the history
  • Loading branch information
aureleoules committed Sep 2, 2023
1 parent 4e267dd commit 815abfd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 60 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --tag aureleoules/mutation-worker:latest
- name: Push the Docker image
run: docker push aureleoules/mutation-worker:latest
run: docker build . --tag bitcoin-coverage-mutation-worker:latest
- name: Push to ECR
uses: jwalton/gh-ecr-push@v1
with:
access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
region: us-east-1
image: bitcoin-coverage-mutation-worker:latest
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ HEALTHCHECK --interval=5s --timeout=3s CMD curl -X POST ${HEALTHCHECK_WEBHOOK} -

ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y git python3-zmq libevent-dev libboost-dev libdb5.3++-dev libsqlite3-dev libminiupnpc-dev libzmq3-dev libtool autotools-dev automake pkg-config bsdmainutils bsdextrautils curl wget lsb-release software-properties-common build-essential jq
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
RUN apt update && apt install google-cloud-cli -y

RUN git config --global user.email "[email protected]"
RUN git config --global user.name "bitcoin-coverage"

RUN git clone https:/bitcoin/bitcoin.git /tmp/bitcoin
WORKDIR /tmp/bitcoin
RUN make -C depends NO_BOOST=1 NO_LIBEVENT=1 NO_QT=1 NO_SQLITE=1 NO_NATPMP=1 NO_UPNP=1 NO_ZMQ=1 NO_USDT=1
ENV BDB_PREFIX=/tmp/bitcoin/depends/x86_64-pc-linux-gnu
RUN mkdir -p /tmp/bitcoin/releases && ./test/get_previous_releases.py -b

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
50 changes: 1 addition & 49 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,10 @@
#!/bin/bash
set -e

err() {
echo "Error occurred:"
awk 'NR>L-4 && NR<L+4 { printf "%-5d%3s%s\n",NR,(NR==L?">>>":""),$0 }' L=$1 $0
curl -X POST "$ERROR_WEBHOOK" -H 'Content-Type: application/json' -d '{"text":"Error occurred in bitcoin-coverage: '$1'"}'
}
trap 'err $LINENO' ERR

# if /key.json exists
if [ -f /key.json ]; then
echo "Found key.json"
gcloud auth activate-service-account --key-file /key.json
else
gcloud config set account $GCP_ACCOUNT
fi

git clone https:/bitcoin/bitcoin.git /tmp/bitcoin
cd /tmp/bitcoin
cd /tmp/bitcoin && git pull origin master
git fetch origin pull/$PR_NUM/head && git checkout FETCH_HEAD

# check depends folder exists in gcloud bucket 'bitcoin-coverage-cache'
if gsutil ls gs://bitcoin-coverage-cache/depends/x86_64-pc-linux-gnu/; then
echo "Found cached depends folder"
gsutil -m cp -r gs://bitcoin-coverage-cache/depends/x86_64-pc-linux-gnu /tmp/bitcoin/depends
else
echo "No cached depends folder found"
make -C depends NO_BOOST=1 NO_LIBEVENT=1 NO_QT=1 NO_SQLITE=1 NO_NATPMP=1 NO_UPNP=1 NO_ZMQ=1 NO_USDT=1
gsutil -m cp -r /tmp/bitcoin/depends/x86_64-pc-linux-gnu gs://bitcoin-coverage-cache/depends/x86_64-pc-linux-gnu
fi

BDB_PREFIX="/tmp/bitcoin/depends/x86_64-pc-linux-gnu"

mkdir -p /tmp/bitcoin/releases
gsutil -m cp -r gs://bitcoin-coverage-cache/releases /tmp/bitcoin || echo "No cached previous releases found"
./test/get_previous_releases.py -b
for f in /tmp/bitcoin/releases/*; do
if ! gsutil -m ls gs://bitcoin-coverage-cache/releases/$(basename $f)/; then
echo "Uploading $(basename $f) to gcloud bucket"
gsutil -m cp -r $f gs://bitcoin-coverage-cache/releases
else
echo "Found cached $(basename $f)"
fi
done
# set chmod +x to releases/**/bin/*
find /tmp/bitcoin/releases -type f -exec chmod +x {} \;

./autogen.sh && ./configure --disable-fuzz --enable-fuzz-binary=no --with-gui=no --disable-zmq --disable-bench BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include"

echo $PAYLOAD | base64 -d | jq -r .patch | base64 -d > patch
Expand All @@ -54,10 +13,3 @@ patch -p0 < patch
make -j$(nproc)
make check -j$(nproc)
python3 test/functional/test_runner.py -j$(nproc)

if [ -n "$SUCCESS_WEBHOOK" ]; then
echo "Sending success webhook"
curl -X POST "$SUCCESS_WEBHOOK"
else
echo "No success webhook set"
fi

0 comments on commit 815abfd

Please sign in to comment.