Skip to content

Commit f2c9a09

Browse files
F-WRunTimejbertholdACassimirodkcummingrv-auditor
authored
Publish Docker image + Example CI WF + Upload to dockerhub (#516)
… bugs and challenge to fully isolate built dependencies into the src contained for packaging and installation deployiment. Current problem: - Post installation of whl .cache/kdist-<hash> file is not available and hardcoded to look in ~/.cache/kdist-<hash> - This needs a generalized location or be installed to site-package swith the rest of the library files for python packaging to work as intended. - Unresolved understanding of where stable-mir-json artifacts need to be stored / referenced for kmir prove - Published a single docker image from manual built image to produce an alias poetry-kmir usable image within CI, but is not ideal for scripting / simple usage and inspection by developer. # Objectives: ~- [ ] Create a simple to use whl installation for developers / consumers of kmir~ ~- [ ] Slim the docker image as an easy CI callable for kmir in CI~ - [x] Deploy Docker image - [x] Simple WF script demonstrate testing execution using kmir posted docker image ## MVP CI Run executing single test using published docker image to dockerhub --------- Co-authored-by: Jost Berthold <[email protected]> Co-authored-by: ACassimiro <[email protected]> Co-authored-by: Daniel Cumming <[email protected]> Co-authored-by: devops <[email protected]> Co-authored-by: rv-jenkins <[email protected]>
1 parent bf661d8 commit f2c9a09

File tree

7 files changed

+139
-10
lines changed

7 files changed

+139
-10
lines changed

.github/workflows/release.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "Release KMIR"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
runs-on: [self-hosted, linux, normal]
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
submodules: recursive
16+
- name: 'Setup Docker Buildx'
17+
uses: docker/[email protected]
18+
19+
- name: 'Login to Docker Hub'
20+
uses: docker/[email protected]
21+
with:
22+
username: ${{ vars.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
24+
25+
- name: Set Image Name
26+
id: set-image-name
27+
run: |
28+
echo "image-name=runtimeverificationinc/kmir" >> $GITHUB_OUTPUT
29+
echo "k-version=$(cat deps/k_release)" >> $GITHUB_OUTPUT
30+
echo "kmir-version=$(cat package/version)" >> $GITHUB_OUTPUT
31+
echo "short-sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
32+
33+
- name: Build Kmir Container
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
file: Dockerfile.kmir
38+
platforms: linux/amd64
39+
push: true
40+
build-args: |
41+
K_VERSION=${{ steps.set-image-name.outputs.k-version }}
42+
tags: ${{ steps.set-image-name.outputs.image-name }}:ubuntu-jammy-${{ steps.set-image-name.outputs.kmir-version }}
43+

.github/workflows/test.yml

+80
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,83 @@ jobs:
123123
- name: 'Tear down Docker'
124124
if: always()
125125
run: docker stop --time 0 mir-smir-ci-${GITHUB_SHA}
126+
127+
test-kmir-image:
128+
name: Test Kmir Image
129+
needs: [ unit-tests, version-bump ]
130+
runs-on: ubuntu-latest
131+
env:
132+
container_name: "kmir-${{ github.run_id }}"
133+
outputs:
134+
image-name: ${{ steps.set-image-name.outputs.image-name }}
135+
k-version: ${{ steps.set-image-name.outputs.k-version }}
136+
kmir-version: ${{ steps.set-image-name.outputs.kmir-version }}
137+
short-sha: ${{ steps.set-image-name.outputs.short-sha }}
138+
steps:
139+
- name: Checkout code
140+
uses: actions/checkout@v4
141+
with:
142+
submodules: recursive
143+
144+
- name: Setup Docker Buildx
145+
uses: docker/[email protected]
146+
147+
- name: Set Image Name Parameters
148+
id: set-image-name
149+
run: |
150+
echo "image-name=ghcr.io/runtimeverification/mir-semantics/kmir" >> $GITHUB_OUTPUT
151+
echo "k-version=$(cat deps/k_release)" >> $GITHUB_OUTPUT
152+
echo "kmir-version=$(cat package/version)" >> $GITHUB_OUTPUT
153+
echo "short-sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
154+
155+
- name: Build Kmir Container
156+
uses: docker/build-push-action@v6
157+
with:
158+
context: .
159+
file: Dockerfile.kmir
160+
platforms: linux/amd64
161+
push: false
162+
load: true
163+
build-args: |
164+
K_VERSION=${{ steps.set-image-name.outputs.k-version }}
165+
tags: ${{ steps.set-image-name.outputs.image-name }}:ubuntu-jammy-${{ steps.set-image-name.outputs.kmir-version }}-${{ steps.set-image-name.outputs.short-sha }}
166+
167+
- name: Container Sanity Check
168+
run: |
169+
# Create output directories for each test
170+
for k_file in kmir/src/tests/integration/data/*/*-spec.k; do
171+
proof_dir="$(dirname ${k_file})/proofs"
172+
mkdir -p "${proof_dir}"
173+
chmod 777 "${proof_dir}"
174+
done
175+
176+
# Start Container
177+
docker run --detach --rm -t \
178+
--name ${{ env.container_name }} \
179+
-v $PWD:/home/kmir/workspace \
180+
-w /home/kmir/workspace \
181+
${{ steps.set-image-name.outputs.image-name }}:ubuntu-jammy-${{ steps.set-image-name.outputs.kmir-version }}-${{ steps.set-image-name.outputs.short-sha }} \
182+
/bin/bash
183+
184+
# Run all tests in a single exec command to maintain fixuid context
185+
docker exec \
186+
-w /home/kmir/workspace \
187+
${{ env.container_name }} \
188+
/bin/bash -c '
189+
for k_file in kmir/src/tests/integration/data/*/*-spec.k; do
190+
echo "Running ${k_file}"
191+
proof_dir="$(dirname ${k_file})/proofs"
192+
if ! kmir prove run "${k_file}" --proof-dir "${proof_dir}" 2>&1; then
193+
echo "Proof failed for ${k_file}"
194+
fi
195+
done
196+
'
197+
198+
# Print test results
199+
echo "Test results:"
200+
find kmir/src/tests/integration/data -name "proofs" -type d -exec echo {} >> GITHUB_STEP_SUMMARY \;
201+
202+
- name: Tear Down Container
203+
if: always()
204+
run: docker stop ${{ env.container_name }}
205+

Dockerfile.kmir

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ARG K_VERSION
66

77
# create non-root user and adjust UID:GID on start-up
88
# see https://github.com/boxboat/fixuid
9-
RUN addgroup --gid 1000 kmir && \
10-
adduser -uid 1000 --ingroup kmir --home /home/kmir --shell /bin/bash --disabled-password --gecos "" kmir
9+
RUN addgroup --gid 1111 kmir && \
10+
adduser -uid 1111 --ingroup kmir --home /home/kmir --shell /bin/bash --disabled-password --gecos "" kmir
1111
RUN apt-get install -y curl graphviz python-is-python3 && \
1212
USER=kmir && \
1313
GROUP=kmir && \
@@ -23,9 +23,15 @@ RUN chown -R kmir:kmir deps/stable-mir-json/
2323

2424
USER kmir:kmir
2525
WORKDIR /home/kmir
26+
# Set Env variables for Building
2627
ENV K_VERSION=${K_VERSION} \
2728
PATH=/home/kmir/.local/bin:/home/kmir/.cargo/bin:$PATH \
2829
force_color_prompt=yes
30+
# Set Env Variables every time a new shell is opened (e.g. when using 'docker exec')
31+
RUN echo "export K_VERSION=${K_VERSION}" >> /home/kmir/.bash_profile && \
32+
echo "export PATH=/home/kmir/.local/bin:/home/kmir/.cargo/bin:\$PATH" >> /home/kmir/.bash_profile && \
33+
echo "export force_color_prompt=yes" >> /home/kmir/.bash_profile && \
34+
echo "source /home/kmir/.bash_profile" >> /home/kmir/.bashrc
2935

3036
# install rustup non-interactively and build
3137
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
@@ -42,7 +48,7 @@ RUN cd /deps/stable-mir-json && \
4248
cargo run --bin cargo_stable_mir_json -- $PWD && \
4349
ln -s /home/kmir/.stable-mir-json/release.sh /home/kmir/.local/bin/stable-mir-json && \
4450
cargo clean
45-
51+
# Fixuid is helpful for 1 time executions of docker containers but is not helpful when relying on `docker exec`
4652
ENTRYPOINT ["fixuid", "-q"]
4753

4854
CMD printf "%s\n" \

flake.nix

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
description = "mir-semantics - ";
2+
description = "kmir - ";
33
inputs = {
44
k-framework.url = "github:runtimeverification/k/v7.1.229";
55
nixpkgs.follows = "k-framework/nixpkgs";
@@ -15,7 +15,7 @@
1515
poetry2nix =
1616
inputs.poetry2nix.lib.mkPoetry2Nix { pkgs = prev; };
1717
in {
18-
mir-semantics = poetry2nix.mkPoetryApplication {
18+
kmir = poetry2nix.mkPoetryApplication {
1919
python = prev.python310;
2020
projectDir = ./kmir;
2121
overrides = poetry2nix.overrides.withDefaults
@@ -41,8 +41,8 @@
4141
};
4242
in {
4343
packages = rec {
44-
inherit (pkgs) mir-semantics;
45-
default = mir-semantics;
44+
inherit (pkgs) kmir;
45+
default = kmir;
4646
};
4747
}) // {
4848
overlay = nixpkgs.lib.composeManyExtensions allOverlays;

kmir/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "kmir"
7-
version = "0.3.113"
7+
version = "0.3.114"
88
description = ""
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

kmir/src/kmir/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from typing import Final
22

3-
VERSION: Final = '0.3.113'
3+
VERSION: Final = '0.3.114'

package/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.113
1+
0.3.114

0 commit comments

Comments
 (0)