Skip to content

Commit

Permalink
Added ERC20 tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
traiansf committed Dec 20, 2024
1 parent 1bb4927 commit 1dfc846
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/actions/with-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
TAG=runtimeverificationinc/${CONTAINER_NAME}
K_COMMIT=$(cat ./deps/k_release)
docker build . --tag ${TAG} --build-arg K_COMMIT=${K_COMMIT}
docker build -f .github/workflows/Dockerfile.k . --tag ${TAG} --build-arg K_COMMIT=${K_COMMIT}
docker run \
--name ${CONTAINER_NAME} \
Expand All @@ -26,8 +26,8 @@ runs:
--tty \
--detach \
--user root \
--workdir /home/user \
--workdir /home/user/wasm-semantics \
${TAG}
docker cp . ${CONTAINER_NAME}:/home/user
docker exec ${CONTAINER_NAME} chown -R user:user /home/user
docker cp . ${CONTAINER_NAME}:/home/user/wasm-semantics
docker exec ${CONTAINER_NAME} chown -R user:user /home/user/wasm-semantics
108 changes: 108 additions & 0 deletions .github/workflows/Dockerfile.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Use a compatible base image like Ubuntu or Debian
FROM --platform=linux/amd64 ubuntu:22.04
# Add necessary repositories for missing packages. Add the packages needed by K, and required at installation time.
RUN apt-get update && \
apt-get install -y \
software-properties-common \
wget \
gnupg \
bash \
python3 \
python3-pip \
build-essential \
libusb-1.0-0-dev \
libssl-dev \
curl \
nano \
iputils-ping \
gcc \
git \
jq \
make \
lsb-release \
openjdk-17-jdk \
libboost-dev \
libboost-test-dev \
libffi-dev \
libfmt-dev \
libgmp-dev \
libjemalloc-dev \
libmpfr-dev \
libsecp256k1-0 \
libtinfo-dev \
libunwind-dev \
libyaml-dev \
libz3-4 \
bison \
flex \
pkg-config \
libcrypto++-dev \
libsecp256k1-dev \
cmake \
maven \
z3 \
xxd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG HOME

# Pre-requisites

## Define build argument for GitHub Token

ARG GITHUB_TOKEN
ENV GITHUB_TOKEN=${GITHUB_TOKEN}

ARG KFRAMEWORK_REPO=github.com/runtimeverification/k.git
ARG K_COMMIT
ARG LLVM_VERSION=16
ARG GO_VERSION=1.23.1
ARG POETRY_VERSION=1.8.3

## Install LLVM 16: Install version 16 as later versions have a known bug affecting the code generator.

RUN wget https://apt.llvm.org/llvm.sh -O llvm.sh && chmod +x llvm.sh
RUN ./llvm.sh ${LLVM_VERSION} all && \
apt-get install -y --no-install-recommends clang-${LLVM_VERSION} lldb-${LLVM_VERSION} lld-${LLVM_VERSION} && \
rm -f llvm.sh

# Install Go

RUN wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz -O go${GO_VERSION}.linux-amd64.tar.gz
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
rm go${GO_VERSION}.linux-amd64.tar.gz


ARG USER_ID=1000
ARG GROUP_ID=1000
RUN groupadd -g $GROUP_ID user && useradd -m -u $USER_ID -s /bin/sh -g user user

USER user:user
WORKDIR /home/user

## Setup the base directory
ENV WORKDIR=/home/user

# Add Go to the PATH
ENV PATH=$PATH:/usr/local/go/bin

## Install Poetry

RUN curl -sSL https://install.python-poetry.org -o install-poetry.py
RUN python3 install-poetry.py --version ${POETRY_VERSION} && rm install-poetry.py
ENV PATH=$HOME/.local/bin:$PATH

RUN pip3 install --user \
cytoolz \
numpy

# Install K
RUN git clone --depth=1 --branch v${K_COMMIT} https://${GITHUB_TOKEN}@${KFRAMEWORK_REPO} k
RUN cd k && git submodule update --init --recursive
ENV CXXFLAGS=-fvisibility=hidden
RUN cd k && mvn package -Dhaskell.backend.skip -DskipTests
ENV PATH=$WORKDIR/k/k-distribution/target/release/k/bin:$PATH

RUN mkdir /home/user/wasm-semantics
WORKDIR /home/user/wasm-semantics
27 changes: 27 additions & 0 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,30 @@ jobs:
if: always()
run: |
docker stop --time=0 kwasm-ci-conformance-${GITHUB_SHA}
erc20-tests:
name: 'ERC20 Tests'
needs: pykwasm-code-quality-checks
runs-on: [self-hosted, aws, us-east-2, m6a.4xlarge]
timeout-minutes: 30
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
with:
container-name: kwasm-ci-erc20-${{ github.sha }}
- name: 'Build everything'
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} make ulm-wasm ulm-contract-compiler ulm-build erc20-bin -j13
- name: 'Start server'
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} -d ./scripts/run-dev-ulm
- name: 'Load kwasm library'
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} ./scripts/ulm-load-lang
- name: 'Run ERC20 tests'
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} tests/ulm/erc20/erc20_test.sh
- name: 'Tear down Docker'
if: always()
run: |
docker stop --time=0 kwasm-ci-erc20-${GITHUB_SHA}

0 comments on commit 1dfc846

Please sign in to comment.