Skip to content

Commit

Permalink
Github tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
traiansf committed Dec 20, 2024
1 parent 4397e7f commit 3e0d4c7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 14 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 -f .github/workflows/Dockerfile.k . --tag ${TAG} --build-arg K_COMMIT=${K_COMMIT}
docker build . --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/wasm-semantics \
--workdir /home/user \
${TAG}
docker cp . ${CONTAINER_NAME}:/home/user/wasm-semantics
docker exec ${CONTAINER_NAME} chown -R user:user /home/user/wasm-semantics
docker cp . ${CONTAINER_NAME}:/home/user
docker exec ${CONTAINER_NAME} chown -R user:user /home/user
34 changes: 34 additions & 0 deletions .github/actions/with-k/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'With Docker'
description: 'Run a given stage with Docker Image'
inputs:
container-name:
description: 'Docker container name to use'
required: true
runs:
using: 'composite'
steps:
- name: 'Set up Docker'
shell: bash {0}
env:
CONTAINER_NAME: ${{ inputs.container-name }}
GITHUB_TOKEN: ${{ github.token }}
run: |
set -euxo pipefail
TAG=runtimeverificationinc/${CONTAINER_NAME}
K_COMMIT=$(cat ./deps/k_release)
docker build -f .github/workflows/Dockerfile.k . --tag ${TAG} --build-arg K_COMMIT=${K_COMMIT} --build-arg GITHUB_TOKEN=${GITHUB_TOKEN}
docker run \
--name ${CONTAINER_NAME} \
--rm \
--interactive \
--tty \
--detach \
--user root \
--workdir /home/user/wasm-semantics \
${TAG}
docker cp . ${CONTAINER_NAME}:/home/user/wasm-semantics
docker exec ${CONTAINER_NAME} chown -R user:user /home/user/wasm-semantics
4 changes: 2 additions & 2 deletions .github/workflows/Dockerfile.k
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ RUN pip3 install --user \
numpy

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

RUN mkdir /home/user/wasm-semantics
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ jobs:
with:
submodules: recursive
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
uses: ./.github/actions/with-k
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
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} bash -c "CXX=clang++-16 make ulm-wasm ulm-contract-compiler ulm-build erc20-bin"
- name: 'Start server'
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} -d ./scripts/run-dev-ulm
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} -d bash -c "./scripts/run-dev-ulm"
- name: 'Load kwasm library'
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} ./scripts/ulm-load-lang
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} bash -c "./scripts/ulm-load-lang"
- name: 'Run ERC20 tests'
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} tests/ulm/erc20/erc20_test.sh
run: docker exec -u user kwasm-ci-erc20-${GITHUB_SHA} bash -c "tests/ulm/erc20/erc20_test.sh"
- name: 'Tear down Docker'
if: always()
run: |
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ ULM_SRC_HOOKS=$(shell find "$(ULM_CLONE_DIR)/kllvm" -type f -a '(' -name '*.cpp'

ULM_GETH_TARGET=$(ULM_BUILD_DIR)/geth

GITHUB_TOKEN ?= $(shell cat ~/.github-auth-token)
GITHUB_PREFIX = $(if $(GITHUB_TOKEN),https://$(GITHUB_TOKEN)@github.com,https://github.com)

### ULM Crypto Plugin

$(ULM_KRYPTO_DIR)/.git:
@mkdir -p $(ULM_DEP_DIR)
cd $(ULM_DEP_DIR); \
git clone --depth 1 https://github.com/runtimeverification/blockchain-k-plugin plugin; \
git clone --depth 1 $(GITHUB_PREFIX)/runtimeverification/blockchain-k-plugin plugin; \
cd plugin; \
git submodule update --init --recursive

Expand All @@ -102,7 +105,7 @@ ulm-krypto-build: $(ULM_KRYPTO_TARGET)
$(ULM_CLONE_DIR)/.git:
@mkdir -p $(ULM_DEP_DIR)
cd $(ULM_DEP_DIR); \
git clone --depth 1 --branch contract-size-limits https://github.com/pi-squared-inc/ulm
git clone --depth 1 --branch contract-size-limits $(GITHUB_PREFIX)/pi-squared-inc/ulm

$(ULM_HOOKS_TARGET): $(ULM_SRC_HOOKS) | $(ULM_CLONE_DIR)/.git
@mkdir -p $(ULM_LIB_DIR)
Expand All @@ -119,7 +122,7 @@ ulm-hooks-build: $(ULM_HOOKS_TARGET)
$(ULM_KEVM_DIR)/.git:
@mkdir -p $(ULM_DEP_DIR)
cd $(ULM_DEP_DIR); \
git clone --depth 1 https://github.com/pi-squared-inc/evm-semantics -b $(ULM_KEVM_BRANCH) evm-semantics
git clone --depth 1 $(GITHUB_PREFIX)/pi-squared-inc/evm-semantics -b $(ULM_KEVM_BRANCH) evm-semantics

$(ULM_KEVM_TARGET): $(ULM_KRYPTO_TARGET) $(ULM_HOOKS_TARGET) | $(ULM_KEVM_DIR)/.git
@mkdir -p $(ULM_LIB_DIR)
Expand Down

0 comments on commit 3e0d4c7

Please sign in to comment.