Skip to content

Commit

Permalink
enable autogeneration of bindings on tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ralph-pichler committed Aug 16, 2019
1 parent f5a2f86 commit d79578e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 22 deletions.
49 changes: 38 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
language: generic

services:
- docker

- docker
branches:
only:
- master

- master
- "/v(\\d+\\.)(\\d+\\.)(\\d)/"
jobs:
include:
- stage: test
script:
- docker build -t sw3-travis .
- docker run -it --rm sw3-travis npm test
- docker run -it --rm sw3-travis npm run ethlint
- docker run -it --rm sw3-travis npm run solhint
- stage: test
script:
- docker build -t sw3-travis .
- docker run -it --rm sw3-travis npm test
- docker run -it --rm sw3-travis npm run ethlint
- docker run -it --rm sw3-travis npm run solhint
- stage: abigen
if: tag IS present
script:
- docker build -t sw3-travis .
- mkdir -p bindings
# turn vA.B.C to vA-B-C to avoid . in directory name
- export DIRECTORY=$(echo contracts-${TRAVIS_TAG} | tr '.' '-')
- docker run -v $(pwd)/bindings:/sw3/bindings sw3-travis npm run abigen
# bindings is owned by root at this point
- sudo chown -R $(id -u) bindings
- git clone "https://${GH_TOKEN}@${GH_REPO}"
- mv bindings ${REPO}/${DIRECTORY}
- cd ${REPO}
- git remote
- git config user.email ${EMAIL}
- git config user.name ${USER}
- git add .
- git commit -m "add bindings for ${TRAVIS_TAG}"
- git tag ${TRAVIS_TAG}
- git push origin master --tags
env:
global:
- USER="ralph-pichler"
- EMAIL="pichler.ralph@gmail.com"
- REPO_USER="ethersphere"
- REPO="go-sw3"
- GH_REPO="github.com/${REPO_USER}/${REPO}.git"
# GH_TOKEN
- secure: b8W9Me6I32mzRD7H+ac/J+irthmHjUMaEoz3mCFm/LfLw/2VwgtKZ5Xh06eGekaPeQTJqLcOjYfp/fckWw0LESkKj+Tf6CKrGdx2cImkx7AQtgQGT/ExFWqHnTV7lOUVV+uJo2OxTzhIbM9J1s4f++KWLY+v+XlxzdxEvr68w0ZToqCsac79jUGuYnlZED5AP9TCgUFjPjIp0rnKA4k9y6sMVLPf2MDtvQVz3Cdns2O66fAYz9uWlI89zjM4SNyBnktV0LtkHH/JvPYaeaS7KvfXsPnP6H0BVCQ/UbmUej3JQmTjQ5vgLevIm/MnyaqmQ1ox08VI5q78NUNHfktTsVmemYwsU8R6sbFnE6jR4X+HXoG/97i+U4VCAwOnb7Yuno6p9jabwsRZjVauVdej2gyPJ7z+fCSb6p9aSuUYgMhDEXJt79EtWCtxzvozUelNq75bHzmCtbsHb6ujEtSNd2fiZOdgwJFiXCX8ygeXylSiOrm4Ie4tSRyxKYWDMheuFjHfr7VojFx4OqIdIgGRMA9/WaeZeMAdinOLrMSaLDPOGhVw3JI8y7ndq9Chu7NRPy5kvozgl4ska46uxnTb/fBU8t54SGojbECPpiroOLPHnLNqA67zhTvsSLMEhOVuFcnBh6Z0B4ojzzq32dTsn7TNOqCpPwiFe6+NPBDPqic=
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ FROM node:10.16.0-stretch as builder
ARG GETH_VERSION="1.9.1-b7b2f60f"
ARG SOLIDITY_VERSION="0.5.10"

RUN wget "https://github.com/ethereum/solidity/releases/download/v$SOLIDITY_VERSION/solc-static-linux" \
RUN wget -q "https://github.com/ethereum/solidity/releases/download/v$SOLIDITY_VERSION/solc-static-linux" \
&& chmod +x solc-static-linux \
&& mv solc-static-linux /usr/local/bin/solc \
&& wget "https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-$GETH_VERSION.tar.gz" \
&& wget -q "https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-$GETH_VERSION.tar.gz" \
&& tar xvzf "geth-alltools-linux-amd64-$GETH_VERSION.tar.gz" \
&& mv "geth-alltools-linux-amd64-$GETH_VERSION/abigen" /usr/local/bin/abigen \
&& rm -rf "geth-alltools-linux-amd64-$GETH_VERSION" \
Expand Down
3 changes: 1 addition & 2 deletions abigen/code.go.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ function makeCodeFile(contract, path=`contracts/${contract}.sol`) {
const Contract = output.contracts[`${path}:${contract}`]
const binRuntime = Contract['bin-runtime']

return `
// Copyright 2019 The Swarm Authors
return ` // Copyright 2019 The Swarm Authors
// This file is part of the Swarm library.
//
// The Swarm library is free software: you can redistribute it and/or modify
Expand Down
12 changes: 6 additions & 6 deletions abigen/gen.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env sh
set -e

# contract name
CONTRACT=$1
# go package name
PACKAGE=contract
PACKAGE=$(echo $CONTRACT | tr '[:upper:]' '[:lower:]')
# temporary file for compiler output
COMPILED_JSON=compiled.json
# contract name
CONTRACT=SimpleSwap
# output directory
OUTPUT=bindings/$CONTRACT
OUTPUT=bindings/$PACKAGE

# check if all tools are available
for tool in node solc abigen
Expand All @@ -25,11 +25,11 @@ solc \
openzeppelin-solidity=$(pwd)/node_modules/openzeppelin-solidity\
--allow-paths node_modules/openzeppelin-solidity/contracts\
--combined-json=bin,abi,userdoc,devdoc,metadata,bin-runtime\
contracts/SimpleSwap.sol > "$COMPILED_JSON"
contracts/$CONTRACT.sol > "$COMPILED_JSON"

# generate the bindings
mkdir -p "$OUTPUT"
abigen -pkg $PACKAGE -out "$OUTPUT/simpleswap.go" --combined-json "$COMPILED_JSON"
abigen -pkg $PACKAGE -out "$OUTPUT/$PACKAGE.go" --combined-json "$COMPILED_JSON"
# this creates a separate file for the runtime binary which is not included by abigen
node abigen/code.go.js $PACKAGE "$COMPILED_JSON" $CONTRACT > "$OUTPUT/code.go"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"scripts": {
"test": "truffle test",
"abigen": "./abigen/gen.sh",
"abigen": "./abigen/gen.sh SimpleSwap",
"solhint": "solhint contracts/SimpleSwap.sol",
"ethlint": "solium -d contracts",
"coverage": "solidity-coverage"
Expand Down

0 comments on commit d79578e

Please # to comment.