Skip to content

Commit

Permalink
Merge pull request #1 from vulcanize/ci
Browse files Browse the repository at this point in the history
docker and CI
  • Loading branch information
ramilexe authored Sep 4, 2020
2 parents cdd6aed + a34fd7b commit ef1a4d7
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 46 deletions.
44 changes: 16 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
name: "Build"
on:
pull_request:
push:
branches:
- statediff
jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
# we need this to map platform names as used by github to
# the attribute names defined in release.nix
include:
- os: ubuntu-latest
os_attr: linux
- os: macos-latest
os_attr: darwin
fail-fast: false
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# v10
- uses: cachix/install-nix-action@63cf434de4e4292c6960639d56c5dd550e789d77
with:
# we use the nixpkgs defined in default.nix
skip_adding_nixpkgs_channel: false
# v6
- uses: cachix/cachix-action@490a246fbc7f92208d309eeb54383a4d828cedc1
with:
name: dapp
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: run dapp tests
run: nix-env -iA nixpkgs.bashInteractive && nix-shell --pure src/dapp-tests/shell.nix --command 'make --directory src/dapp-tests'
- name: run hevm symbolic tests
run: nix-build -j 1 -A hevm-tests
- run: nix-build release.nix -A dapphub.${{ matrix.os_attr }}.stable
# - name: run dapp tests
# run: nix-env -iA nixpkgs.bashInteractive && nix-shell --pure src/dapp-tests/shell.nix --command 'make --directory src/dapp-tests'
- name: Get the version
id: vars
run: echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
- name: Run docker build
run: make docker-build
- name: Tag docker image
run: docker tag vulcanize/dapptools docker.pkg.github.com/vulcanize/dapptools/dapptools:${{steps.vars.outputs.sha}}
- name: Docker Login
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin
- name: Docker Push
run: docker push docker.pkg.github.com/vulcanize/dapptools/dapptools:${{steps.vars.outputs.sha}}
16 changes: 16 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Build"
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# - uses: cachix/install-nix-action@63cf434de4e4292c6960639d56c5dd550e789d77
# with:
# # we use the nixpkgs defined in default.nix
# skip_adding_nixpkgs_channel: false
# - name: run dapp tests
# run: nix-env -iA nixpkgs.bashInteractive && nix-shell --pure src/dapp-tests/shell.nix --command 'make --directory src/dapp-tests'
- name: Run docker build
run: make docker-build
25 changes: 25 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Docker image
on:
release:
types: [published]
jobs:
push_to_registries:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Get the version
id: vars
run: |
echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})
- name: Docker Login to Github Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin
- name: Docker Pull
run: docker pull docker.pkg.github.com/vulcanize/dapptools/dapptools:${{steps.vars.outputs.sha}}
- name: Docker Login to Docker Registry
run: echo ${{ secrets.VULCANIZEJENKINS_PAT }} | docker login -u vulcanizejenkins --password-stdin
- name: Tag docker image
run: docker tag docker.pkg.github.com/vulcanize/dapptools/dapptools:${{steps.vars.outputs.sha}} vulcanize/dapptools:${{steps.vars.outputs.tag}}
- name: Docker Push to Docker Hub
run: docker push vulcanize/dapptools:${{steps.vars.outputs.tag}}

17 changes: 0 additions & 17 deletions .github/workflows/release.yml

This file was deleted.

4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

.PHONY: docker-build
docker-build:
docker build -t vulcanize/dapptools -f docker/Dockerfile .
17 changes: 17 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM nixos/nix:2.3.6

# https://github.com/sgerrand/alpine-pkg-glibc
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-2.32-r0.apk && \
apk add glibc-2.32-r0.apk

#USER guest
WORKDIR /root

# copy all files
ADD . .
RUN nix-shell --pure -p cacert cachix curl git jq nix --run "bash docker/install.sh"

EXPOSE 8545
EXPOSE 8546
ENTRYPOINT ["./docker/startup_script_wrapper.sh"]
20 changes: 20 additions & 0 deletions docker/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'

oops() {
>&2 echo -e "${RED}error:${NC} $1"
exit 1
}

#[[ "$(id -u)" -eq 0 ]] && oops "Please run this script as a regular user"

#API_OUTPUT=$(curl -sS https://api.github.com/repos/vulcanize/dapptools/releases/latest)
#RELEASE=$(echo "$API_OUTPUT" | jq -r .tarball_url)
#
#[[ $RELEASE == null ]] && oops "No release found in ${API_OUTPUT}"

cachix use dapp
nix-env -iA dapp hevm seth solc -f .

echo -e "${GREEN}All set!${NC}"
34 changes: 34 additions & 0 deletions docker/startup_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

set -ex

# clean up
trap 'killall geth && rm -rf "$TMPDIR"' EXIT
trap "exit 1" SIGINT SIGTERM

TMPDIR=$(mktemp -d)
dapp testnet --rpc-addr 0.0.0.0 --chain-id 4 --dir "$TMPDIR" &
echo "sleeping 90 sec"
# give it a few secs to start up
sleep 90

read -r ACC BAL <<< "$(seth ls --keystore "$TMPDIR/8545/keystore")"
echo $ACC
echo $BAL


# Deploy a contract:
solc --bin --bin-runtime docker/stateful.sol -o "$TMPDIR"
A_ADDR=$(seth send --create "$(<"$TMPDIR"/A.bin)" "constructor(uint y)" 1 --from "$ACC" --keystore "$TMPDIR"/8545/keystore --password /dev/null --gas 0xffffffff)

echo $A_ADDR

# Call transaction

TX=$(seth send "$A_ADDR" "off()" --gas 0xffff --password /dev/null --from "$ACC" --keystore "$TMPDIR"/8545/keystore --async)
echo $TX
#RESULT=$(seth run-tx "$TX")
#echo $RESULT

# Run forever
tail -f /dev/null
3 changes: 3 additions & 0 deletions docker/startup_script_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

nix-shell -p cacert cachix curl jq nix --run "sh docker/startup_script.sh"
17 changes: 17 additions & 0 deletions docker/stateful.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
contract A {
uint x;

constructor(uint y) public {
x = y;
}

function off() public {
require(x == 1);
x = 0;
}

function on() public {
require(x == 0);
x = 1;
}
}
1 change: 0 additions & 1 deletion src/dapp/libexec/dapp/dapp---testnet-launch
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ else
-n 0 -i eip150Block \
-n 0 -i eip155Block \
-n 0 -i eip158Block \
-n 0 -i eip160Block \
-n 0 -i byzantiumBlock \
-n 0 -i constantinopleBlock \
-n 0 -i petersburgBlock \
Expand Down

0 comments on commit ef1a4d7

Please sign in to comment.