Skip to content

Commit

Permalink
Run tests on PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Aug 7, 2024
1 parent 2d0f87a commit aeff8a8
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/actions/with-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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 }}
run: |
set -euxo pipefail
TAG=runtimeverificationinc/${CONTAINER_NAME}
K_COMMIT=$(cat ./deps/k_release)
docker build . --tag ${TAG} --build-arg K_COMMIT=${K_COMMIT}
docker run \
--name ${CONTAINER_NAME} \
--rm \
--interactive \
--tty \
--detach \
--user root \
--workdir /home/user \
${TAG}
docker cp . ${CONTAINER_NAME}:/home/user
docker exec ${CONTAINER_NAME} chown -R user:user /home/user
30 changes: 30 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: 'Build And Test'
on:
pull_request:
# Stop in progress workflows on the same branch and same workflow to use latest committed code
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-test:
name: 'Build And Test'
runs-on: [self-hosted, linux, normal]
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
with:
container-name: k-rust-demo-${{ github.sha }}
- name: 'Build the semantics'
run: docker exec -t k-rust-demo-${{ github.sha }} /bin/bash -c 'make build -j4'
- name: 'Run Tests'
run: docker exec -t k-rust-demo-${{ github.sha }} /bin/bash -c 'make -j4 test'
- name: 'Tear down Docker'
if: always()
run: |
docker stop k-rust-demo-${{ github.sha }}
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ARG Z3_VERSION
ARG K_COMMIT

ARG Z3_VERSION=4.12.1
FROM runtimeverificationinc/z3:ubuntu-jammy-${Z3_VERSION} as Z3

ARG K_COMMIT
FROM runtimeverificationinc/kframework-k:ubuntu-jammy-${K_COMMIT}

COPY --from=Z3 /usr/bin/z3 /usr/bin/z3

# RUN apt-get update \
# && apt-get upgrade --yes \
# && apt-get install --yes \
# cmake \
# curl \
# pandoc \
# python3 \
# python3-pip \
# wabt

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

# RUN curl -sSL https://install.python-poetry.org | python3 - \
# && poetry --version

# RUN pip3 install --user \
# cytoolz \
# numpy

# ENV PATH=/home/user/wabt/build:/home/user/.local/bin:$PATH
1 change: 1 addition & 0 deletions deps/k_release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.1.92

0 comments on commit aeff8a8

Please sign in to comment.