Skip to content

Commit

Permalink
Add GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tothtamas28 committed Nov 11, 2024
1 parent 960dd84 commit 07cebb5
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/actions/with-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG K_VERSION
FROM runtimeverificationinc/kframework-k:ubuntu-jammy-${K_VERSION}

RUN apt-get update \
&& apt-get upgrade --yes \
&& apt-get install --yes \
curl \
&& apt-get clean

ARG USER=user
ARG GROUP=$USER
ARG USER_ID=1000
ARG GROUP_ID=$USER_ID

RUN groupadd -g $GROUP_ID $GROUP && useradd -m -u $USER_ID -s /bin/sh -g $GROUP $USER

USER $USER:$GROUP

ENV PATH=/home/$USER/.local/bin:$PATH
RUN curl -sSL https://install.python-poetry.org | python3 -
46 changes: 46 additions & 0 deletions .github/actions/with-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'With Docker'
description: 'Start a Docker container with the K development environment set up'
inputs:
container-name:
description: 'Docker container name to use'
required: true
type: string
runs:
using: 'composite'
steps:
- name: 'Set up Docker'
shell: bash {0}
run: |
set -euxo pipefail
CONTAINER_NAME=${{ inputs.container-name }}
TAG=runtimeverificationinc/${CONTAINER_NAME}
DOCKERFILE=${{ github.action_path }}/Dockerfile
K_VERSION=$(cat deps/k_release)
docker build . \
--file ${DOCKERFILE} \
--build-arg K_VERSION=${K_VERSION} \
--tag ${TAG}
- name: 'Run Docker container'
shell: bash {0}
run: |
set -euxo pipefail
CONTAINER_NAME=${{ inputs.container-name }}
TAG=runtimeverificationinc/${CONTAINER_NAME}
WORKDIR=/home/user
docker run \
--name ${CONTAINER_NAME} \
--rm \
--interactive \
--tty \
--detach \
--user root \
--workdir ${WORKDIR} \
${TAG}
docker cp . ${CONTAINER_NAME}:${WORKDIR}
docker exec ${CONTAINER_NAME} chown -R user:user ${WORKDIR}
65 changes: 65 additions & 0 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Test PR'
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
code-quality-checks:
name: 'Code Quality Checks & Unit Tests'
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
working-directory: kimp
steps:
- name: 'Check out code'
uses: actions/checkout@v4
- name: 'Install Python'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: 'Install Poetry'
uses: Gr1N/setup-poetry@v9
- name: 'Run code quality checks'
run: make check
- name: 'Run pyupgrade'
run: make pyupgrade
- name: 'Run unit tests'
run: make cov-unit

integration-tests:
name: 'Integration Tests'
runs-on: [self-hosted, linux, normal]
timeout-minutes: 5
env:
CONTAINER: imp-integration-${{ github.sha }}
steps:
- name: 'Check out code'
uses: actions/checkout@v4
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
with:
container-name: ${CONTAINER}
- name: 'Build and run integration tests'
run: docker exec -u user ${CONTAINER} make -C kimp cov-integration
- name: 'Tear down Docker container'
if: always()
run: |
docker stop --time=0 ${CONTAINER}
docker-tests:
name: 'Docker Tests'
runs-on: [self-hosted, linux, normal]
timeout-minutes: 5
env:
TAG: ${{ github.sha }}
CONTAINER: imp-docker-${{ github.sha }}
steps:
- name: 'Check out code'
uses: actions/checkout@v4
- name: 'Build Docker image'
run: make docker TAG=${TAG}
- name: 'Run smoke tests'
run: docker run --rm --name ${CONTAINER} ${TAG} ./smoke-test.sh

0 comments on commit 07cebb5

Please sign in to comment.