GitHub action (#687)

* Draft GitHub action

* Update action.yml

* Allow solc version selection

* Updation action.yml
pull/683/head
Samuel Moelius 3 years ago committed by GitHub
parent b425931b9f
commit ed064f14c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      .github/workflows/action.yml
  2. 5
      action/Dockerfile
  3. 63
      action/action.yml
  4. 47
      action/entrypoint.sh

@ -0,0 +1,35 @@
name: Action
on:
push:
branches:
- master
- nix
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Assert test
uses: ./action
with:
files: "examples/solidity/basic/assert.sol"
contract: "TestAssert"
config: "examples/solidity/basic/assert.yaml"
solc-version: 0.6.12
negate-exit-status: 1
- name: Multi-abi test
uses: ./action
with:
files: "examples/solidity/basic/multi-abi.sol"
contract: "B"
multi-abi: true
solc-version: 0.7.6
negate-exit-status: 1

@ -0,0 +1,5 @@
FROM trailofbits/echidna
RUN pip3 install solc-select
COPY entrypoint.sh /entrypoint.sh
RUN chmod ugo+x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

@ -0,0 +1,63 @@
name: "Echidna"
description: "Run echidna-test"
inputs:
files:
description: "Solidity files to analyze"
required: true
contract:
description: "Contract to analyze"
required: false
config:
description: "Config file (CLI arguments override config options)"
required: false
format:
description: "Output format: json, text, none. Disables interactive UI"
required: false
corpus-dir:
description: "Directory to store corpus and coverage data"
required: false
check-asserts:
description: "Check asserts in the code"
required: false
multi-abi:
description: "Use multi-abi mode of testing"
required: false
test-limit:
description: "Number of sequences of transactions to generate during testing"
required: false
shrink-limit:
description: "Number of tries to attempt to shrink a failing sequence of transactions"
required: false
seq-len:
description: "Number of transactions to generate during testing"
required: false
contract-addr:
description: "Address to deploy the contract to test"
required: false
deployer:
description: "Address of the deployer of the contract to test"
required: false
sender:
description: "Addresses to use for the transactions sent during testing"
required: false
seed:
description: "Run with a specific seed"
required: false
crytic-args:
description: "Additional arguments to use in crytic-compile for the compilation of the contract to test"
required: false
solc-args:
description: "Additional arguments to use in solc for the compilation of the contract to test"
required: false
solc-version:
description: "Version of the Solidity compiler to use"
required: false
negate-exit-status:
description: "Apply logical NOT to echidna-test's exit status (for testing the action)"
required: false
runs:
using: "docker"
image: "Dockerfile"

@ -0,0 +1,47 @@
#! /bin/bash
set -eu
export PYTHONPATH=/root/.local/lib/python3.6/site-packages
OPTIONS="contract config format corpus-dir test-limit shrink-limit seq-len \
contract-addr deployer sender seed crytic-args solc-args"
SWITCHES="check-asserts multi-abi"
# smoelius: `get` works for non-standard variable names like `INPUT_CORPUS-DIR`.
get() {
env | sed -n "s/^$1=\(.*\)/\1/;T;p"
}
CMD=(echidna-test "$INPUT_FILES")
for OPTION in $OPTIONS; do
NAME=INPUT_"${OPTION^^}"
VALUE="$(get "$NAME")"
if [[ -n "$VALUE" ]]; then
CMD+=(--"$OPTION" "$VALUE")
fi
done
for SWITCH in $SWITCHES; do
NAME=INPUT_"${SWITCH^^}"
VALUE="$(get "$NAME")"
if [[ -n "$VALUE" ]]; then
CMD+=(--"$SWITCH")
fi
done
SOLC_VERSION="$(get 'INPUT_SOLC-VERSION')"
if [[ -n "$SOLC_VERSION" ]]; then
solc-select install "$SOLC_VERSION"
solc-select use "$SOLC_VERSION"
fi
echo "${CMD[@]}" >&2
if [[ -n "$(get 'INPUT_NEGATE-EXIT-STATUS')" ]]; then
! "${CMD[@]}"
else
"${CMD[@]}"
fi
Loading…
Cancel
Save