Skip to content

Commit

Permalink
Merge pull request #2 from zgornel/cc-kheops-integration
Browse files Browse the repository at this point in the history
Kheops integration
  • Loading branch information
zgornel authored Jul 8, 2024
2 parents 71a5ff5 + e968997 commit 3d52475
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Kheops-compiled PULL REQUEST run
env:
REPOSITORY_DIR: "./${{ github.event.repository.name }}" # inside runner
WORKSPACE_DIR: "/workspace" # inside Kheops-compiled container
PROJECT_DIR: "/workspace/src" # inside Kheops-compiled container
CONFIG_PATH: "/workspace/.kheops/input-configuration.json"
INPUT_PARSER: julia
LOG_LEVEL: error
on:
pull_request:
branches:
- master
jobs:
build:
name: Kheops-compiled Docker ${{ github.event_name }}
#runs-on: [self-hosted]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
arch:
- x64
steps:
- name: Checkout current project repository
uses: actions/checkout@v3
with:
path: ${{ env.REPOSITORY_DIR }}
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: 'Testing architecture ...'
comment_tag: kheops_status_tag
- id: pull_docker_image
name: Pull Kheops-compiled container image
run: |
docker pull ghcr.io/oxoaresearch/kheops-compiled:latest
- id: run_docker_image
name: Run Kheops-compiled
run: |
echo 'DATA_DUMP<<EOF' >> $GITHUB_OUTPUT
echo '```' >> $GITHUB_OUTPUT
docker run --volume=${{ env.REPOSITORY_DIR }}:${{ env.WORKSPACE_DIR }} \
ghcr.io/oxoaresearch/kheops-compiled:latest kheopscli/bin/kheopscli \
--project-dir ${{ env.PROJECT_DIR }} \
--config-path ${{ env.CONFIG_PATH }} \
--input-parser ${{ env.INPUT_PARSER }} \
--output-type text \
--log-level ${{ env.LOG_LEVEL }}>> $GITHUB_OUTPUT
echo '```' >> $GITHUB_OUTPUT
echo '```mermaid' >> $GITHUB_OUTPUT
docker run --volume=${{ env.REPOSITORY_DIR }}:${{ env.WORKSPACE_DIR }} \
ghcr.io/oxoaresearch/kheops-compiled:latest kheopscli/bin/kheopscli \
--project-dir ${{ env.PROJECT_DIR }} \
--config-path ${{ env.CONFIG_PATH }} \
--input-parser ${{ env.INPUT_PARSER }} \
--output-type diagram \
--diagram-type file \
--diagram-backend mermaid \
--log-level ${{ env.LOG_LEVEL }} >> $GITHUB_OUTPUT
echo '```' >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Edit PR comment
uses: thollander/actions-comment-pull-request@v2
with:
message: ${{steps.run_docker_image.outputs.DATA_DUMP}}
comment_tag: kheops_status_tag
44 changes: 44 additions & 0 deletions .github/workflows/ci-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Kheops-compiled PUSH run
env:
REPOSITORY_DIR: "./${{ github.event.repository.name }}" # inside runner
WORKSPACE_DIR: "/workspace" # inside Kheops-compiled container
PROJECT_DIR: "/workspace/src" # inside Kheops-compiled container
CONFIG_PATH: "/workspace/.kheops/input-configuration.json"
INPUT_PARSER: julia
LOG_LEVEL: error
on:
push:
branches:
- master
tags: '*'
jobs:
build:
name: Kheops-compiled Docker ${{ github.event_name }}
#runs-on: [self-hosted]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
arch:
- x64
steps:
- name: Checkout current project repository
uses: actions/checkout@v3
with:
path: ${{ env.REPOSITORY_DIR }}
- id: pull_docker_image
name: Pull Kheops-compiled container image
run: |
docker pull ghcr.io/oxoaresearch/kheops-compiled:latest
- id: run_docker_image
name: Run Kheops-compiled
run: |
docker run --volume=${{ env.REPOSITORY_DIR }}:${{ env.WORKSPACE_DIR }} \
ghcr.io/oxoaresearch/kheops-compiled:latest kheopscli/bin/kheopscli \
--project-dir ${{ env.PROJECT_DIR }} \
--config-path ${{ env.CONFIG_PATH }} \
--input-parser ${{ env.INPUT_PARSER }} \
--output-type text \
--log-level ${{ env.LOG_LEVEL }}
52 changes: 52 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# For more documentation, on GitLab CI/CD YAML syntax check:
# https://docs.gitlab.com/ee/ci/yaml/
#

#image: ghcr.io/oxoaresearch/kheops-compiled:latest

variables:
REPOSITORY_DIR: "./$CI_PROJECT_DIR" # inside runner
WORKSPACE_DIR: "/tmp" # inside Kheops-compiled container
PROJECT_DIR: "/tmp/src" # inside Kheops-compiled container
CONFIG_PATH: "/tmp/.kheops/input-configuration.json" # inside Kheops-compiled container
OUTPUT_TYPE: "text"
LOG_LEVEL: "debug"

stages:
- run_kheops_push
- run_kheops_mr
- post_output_mr

push_job:
stage: run_kheops_push
script: # sample test run
- docker run --volume=./:/tmp ghcr.io/oxoaresearch/kheops-compiled:latest /kheopscli/bin/kheopscli --project-dir /tmp/src --config-path /tmp/.kheops/input-configuration.json --input-parser Julia --output-type text --log-level debug
rules:
- if: $CI_PIPELINE_SOURCE == "push"

merge_request_job:
stage: run_kheops_mr
artifacts:
paths:
- kheops_output.txt
- kheops_output.plantuml
script:
- docker run --volume=./:/tmp ghcr.io/oxoaresearch/kheops-compiled:latest /kheopscli/bin/kheopscli --project-dir /tmp/src --config-path /tmp/.kheops/input-configuration.json --input-parser Julia --output-type text --log-level error > ./kheops_output.txt
- docker run --volume=./:/tmp ghcr.io/oxoaresearch/kheops-compiled:latest /kheopscli/bin/kheopscli --project-dir /tmp/src --config-path /tmp/.kheops/input-configuration.json --input-parser Julia --output-type diagram --diagram-backend plantuml --log-level error > ./kheops_output.plantuml
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

post_message_to_merge_request:
stage: post_output_mr
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: on_success
dependencies:
- merge_request_job
script:
- tree -L 1 ./
- export GITLAB_TOKEN=glpat-3YKjQp-kcHsHxJW4t_SJ
#TODO: Fix to actually post the contents of kheops_output.txt and kheops_output.plantuml
- 'curl --request POST "https://gitlab.ai.vub.ac.be/api/v4/projects/$CI_MERGE_REQUEST_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes" --header "PRIVATE-TOKEN: $GITLAB_TOKEN" --header "Content-Type: application/json" --data-raw "{ \"body\": \"$(cat kheops_output.txt)\" }"'
39 changes: 39 additions & 0 deletions .kheops/input-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"Rules": [
{ "from": "KNOWLEDGE_BASE", "to": "CONTROL_FLOW"},
{ "from": "KNOWLEDGE_BASE", "to": "KNOWLEDGE_BASE"},
{ "from": "KNOWLEDGE_BASE", "to": "PROGRAM_EXECUTION"},
{ "from": "PROGRAM_EXECUTION", "to": "CONTROL_FLOW"},
{ "from": "PROGRAM_EXECUTION", "to": "PROGRAM_EXECUTION"},
{ "from": "CONTROL_FLOW", "to": "CONTROL_FLOW"}
],
"Components": [
{
"name": "PROGRAM_EXECUTION",
"sources": [
{
"type": "File",
"value": "src/program.jl"
}
]
},
{
"name": "CONTROL_FLOW",
"sources": [
{
"type": "FileList",
"value": ["src/automaton.jl", "src/transition.jl"]
}
]
},
{
"name": "KNOWLEDGE_BASE",
"sources": [
{
"type": "FileList",
"value": ["src/kb.jl", "src/sat.jl", "src/utils.jl"]
}
]
}
]
}

0 comments on commit 3d52475

Please sign in to comment.