Skip to content

Commit cc0c6cd

Browse files
Set up project (#2)
* Instantiate project template * Add versioning * Add dependencies * Add `poetry.lock` * Add `kdist` setup * Add CI tests * Set Version: 0.1.1 * Add update workflow * Sync Poetry files 0.1.48 * deps/k_release: sync release file version 7.0.52 * Restore workflow trigger --------- Co-authored-by: devops <[email protected]>
1 parent 7fa2c93 commit cc0c6cd

28 files changed

+1773
-2
lines changed

.cruft.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"template": "https://github.com/runtimeverification/python-project-template",
3+
"commit": "601d5e2a0e8a98c87dcb1ae694d22d76d0114e01",
4+
"checkout": null,
5+
"context": {
6+
"cookiecutter": {
7+
"project_name": "ksoroban",
8+
"project_slug": "ksoroban",
9+
"package_name": "ksoroban",
10+
"version": "0.1.0",
11+
"description": "K tooling for the Soroban platform",
12+
"author_name": "Runtime Verification, Inc.",
13+
"author_email": "[email protected]",
14+
"_template": "https://github.com/runtimeverification/python-project-template"
15+
}
16+
},
17+
"directory": null
18+
}

.flake8

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[flake8]
2+
max-line-length = 120
3+
extend-select = B9, TC1
4+
extend-ignore = B950,E,W1,W2,W3,W4,W5
5+
per-file-ignores =
6+
*/__init__.py: F401
7+
type-checking-strict = true
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ARG K_VERSION
2+
FROM runtimeverificationinc/kframework-k:ubuntu-jammy-${K_VERSION}
3+
4+
ARG PYTHON_VERSION=3.10
5+
6+
RUN apt-get -y update \
7+
&& apt-get -y install \
8+
graphviz \
9+
python${PYTHON_VERSION} \
10+
python${PYTHON_VERSION}-dev \
11+
&& apt-get -y clean
12+
13+
ARG USER_ID=9876
14+
ARG GROUP_ID=9876
15+
RUN groupadd -g ${GROUP_ID} user \
16+
&& useradd -m -u ${USER_ID} -s /bin/bash -g user user
17+
18+
USER user
19+
WORKDIR /home/user
20+
21+
ENV PATH=/home/user/.local/bin:${PATH}
22+
RUN curl -sSL https://install.python-poetry.org | python3 -
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 'With Docker'
2+
description: 'Run a given stage with Docker Image'
3+
inputs:
4+
container-name:
5+
description: 'Docker container name to use'
6+
type: string
7+
required: true
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: 'Set up Docker'
12+
shell: bash {0}
13+
run: |
14+
set -euxo pipefail
15+
16+
CONTAINER_NAME=${{ inputs.container-name }}
17+
TAG=runtimeverificationinc/${CONTAINER_NAME}
18+
K_VERSION=$(cat deps/k_release)
19+
20+
docker build . \
21+
--file .github/actions/with-docker/Dockerfile \
22+
--tag ${TAG} \
23+
--build-arg K_VERSION=${K_VERSION}
24+
25+
docker run \
26+
--name ${CONTAINER_NAME} \
27+
--rm \
28+
--interactive \
29+
--tty \
30+
--detach \
31+
--user root \
32+
--workdir /home/user \
33+
${TAG}
34+
35+
docker cp . ${CONTAINER_NAME}:/home/user
36+
docker exec ${CONTAINER_NAME} chown -R user:user /home/user

.github/workflows/master.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'Master Push'
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
9+
release:
10+
name: 'Publish Release'
11+
runs-on: [self-hosted, linux, flyweight]
12+
steps:
13+
- name: 'Check out code'
14+
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.push.head.sha }}
17+
fetch-depth: 0
18+
- name: 'Make release'
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
run: |
22+
set -x
23+
VERSION=v$(cat package/version)
24+
gh release create ${VERSION} --target ${{ github.sha }}

.github/workflows/test.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: 'Test'
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
11+
version-bump:
12+
name: 'Version Bump'
13+
runs-on: [self-hosted, linux, flyweight]
14+
steps:
15+
- name: 'Check out code'
16+
uses: actions/checkout@v4
17+
with:
18+
token: ${{ secrets.JENKINS_GITHUB_PAT }}
19+
fetch-depth: 0
20+
ref: ${{ github.event.pull_request.head.sha }}
21+
- name: 'Configure GitHub user'
22+
run: |
23+
git config user.name devops
24+
git config user.email [email protected]
25+
- name: 'Update version'
26+
run: |
27+
og_version=$(git show origin/${GITHUB_BASE_REF}:package/version)
28+
./package/version.sh bump ${og_version}
29+
./package/version.sh sub
30+
new_version=$(cat package/version)
31+
git add --update && git commit --message "Set Version: ${new_version}" || true
32+
- name: 'Push updates'
33+
run: git push origin HEAD:${GITHUB_HEAD_REF}
34+
35+
code-quality-checks:
36+
needs: version-bump
37+
name: 'Code Quality Checks'
38+
runs-on: [self-hosted, linux, flyweight]
39+
steps:
40+
- name: 'Check out code'
41+
uses: actions/checkout@v3
42+
- name: 'Run code quality checks'
43+
run: make check
44+
- name: 'Run pyupgrade'
45+
run: make pyupgrade
46+
- name: 'Run unit tests'
47+
run: make test-unit
48+
49+
integration-tests:
50+
needs: code-quality-checks
51+
name: 'Integration Tests'
52+
runs-on: [self-hosted, linux, normal]
53+
env:
54+
CONTAINER: ksoroban-integration-${{ github.sha }}
55+
steps:
56+
- name: 'Check out code'
57+
uses: actions/checkout@v3
58+
with:
59+
fetch-depth: 0
60+
- name: 'Set up Docker'
61+
uses: ./.github/actions/with-docker
62+
with:
63+
container-name: ${CONTAINER}
64+
- name: 'Build ksoroban'
65+
run: docker exec --user user ${CONTAINER} poetry install
66+
- name: 'Build semantics'
67+
run: docker exec --user user ${CONTAINER} make kdist-build
68+
- name: 'Run integration tests'
69+
run: docker exec --user user ${CONTAINER} make test-integration
70+
- name: 'Tear down Docker'
71+
if: always()
72+
run: docker stop --time=0 ${CONTAINER}

.github/workflows/update.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'Update Version'
2+
on:
3+
push:
4+
branches:
5+
- '_update-deps/runtimeverification/wasm-semantics'
6+
workflow_dispatch:
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
update-deps:
13+
name: 'Update Dependecies'
14+
runs-on: [self-hosted, linux, flyweight]
15+
steps:
16+
- name: 'Check out code'
17+
uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
20+
token: ${{ secrets.JENKINS_GITHUB_PAT }}
21+
- name: 'Configure GitHub user'
22+
run: |
23+
git config user.name devops
24+
git config user.email [email protected]
25+
- name: 'Install Python'
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.10'
29+
- name: 'Install Poetry'
30+
uses: Gr1N/setup-poetry@v9
31+
- name: 'Update Poetry files'
32+
run: |
33+
PYKWASM_VERSION="$(cat deps/kwasm_release)"
34+
sed -i 's!pykwasm = { git = "https://github.com/runtimeverification/wasm-semantics.git", tag = "[v0-9\.]*", subdirectory = "pykwasm" }!pykwasm = { git = "https://github.com/runtimeverification/wasm-semantics.git", tag = "v'${PYKWASM_VERSION}'", subdirectory = "pykwasm" }!' pyproject.toml
35+
poetry update
36+
git add . && git commit -m "Sync Poetry files ${PYKWASM_VERSION}" || true
37+
- name: 'Update K release'
38+
run: |
39+
K_VERSION=$(poetry run python3 -c 'import pyk; print(pyk.__version__)')
40+
echo ${K_VERSION} > deps/k_release
41+
git add deps/k_release && git commit -m "deps/k_release: sync release file version ${K_VERSION}" || true
42+
- name: 'Push updates'
43+
run: git push

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist/
2+
__pycache__/
3+
.coverage

Makefile

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
POETRY := poetry
2+
POETRY_RUN := $(POETRY) run
3+
4+
5+
default: check test-unit
6+
7+
all: check cov
8+
9+
.PHONY: clean
10+
clean:
11+
rm -rf dist .coverage cov-* .mypy_cache .pytest_cache
12+
find -type d -name __pycache__ -prune -exec rm -rf {} \;
13+
14+
.PHONY: build
15+
build:
16+
$(POETRY) build
17+
18+
.PHONY: poetry-install
19+
poetry-install:
20+
$(POETRY) install
21+
22+
23+
# Semantics
24+
25+
kdist-build: poetry-install
26+
$(POETRY) run kdist -v build soroban-semantics.llvm
27+
28+
kdist-clean: poetry-install
29+
$(POETRY) run kdist clean
30+
31+
32+
# Tests
33+
34+
TEST_ARGS :=
35+
36+
test: test-all
37+
38+
test-all: poetry-install
39+
$(POETRY_RUN) pytest src/tests --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)
40+
41+
test-unit: poetry-install
42+
$(POETRY_RUN) pytest src/tests/unit --maxfail=1 --verbose $(TEST_ARGS)
43+
44+
test-integration: poetry-install
45+
$(POETRY_RUN) pytest src/tests/integration --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)
46+
47+
48+
# Coverage
49+
50+
COV_ARGS :=
51+
52+
cov: cov-all
53+
54+
cov-%: TEST_ARGS += --cov=ksoroban --no-cov-on-fail --cov-branch --cov-report=term
55+
56+
cov-all: TEST_ARGS += --cov-report=html:cov-all-html $(COV_ARGS)
57+
cov-all: test-all
58+
59+
cov-unit: TEST_ARGS += --cov-report=html:cov-unit-html $(COV_ARGS)
60+
cov-unit: test-unit
61+
62+
cov-integration: TEST_ARGS += --cov-report=html:cov-integration-html $(COV_ARGS)
63+
cov-integration: test-integration
64+
65+
66+
# Checks and formatting
67+
68+
format: autoflake isort black
69+
check: check-flake8 check-mypy check-autoflake check-isort check-black
70+
71+
check-flake8: poetry-install
72+
$(POETRY_RUN) flake8 src
73+
74+
check-mypy: poetry-install
75+
$(POETRY_RUN) mypy src
76+
77+
autoflake: poetry-install
78+
$(POETRY_RUN) autoflake --quiet --in-place src
79+
80+
check-autoflake: poetry-install
81+
$(POETRY_RUN) autoflake --quiet --check src
82+
83+
isort: poetry-install
84+
$(POETRY_RUN) isort src
85+
86+
check-isort: poetry-install
87+
$(POETRY_RUN) isort --check src
88+
89+
black: poetry-install
90+
$(POETRY_RUN) black src
91+
92+
check-black: poetry-install
93+
$(POETRY_RUN) black --check src
94+
95+
96+
# Optional tools
97+
98+
SRC_FILES := $(shell find src -type f -name '*.py')
99+
100+
pyupgrade: poetry-install
101+
$(POETRY_RUN) pyupgrade --py310-plus $(SRC_FILES)

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
# kasmer-soroban
1+
# ksoroban
2+
3+
4+
## Installation
5+
6+
Prerequsites: `python >= 3.10`, `pip >= 20.0.2`, `poetry >= 1.3.2`.
7+
8+
```bash
9+
make build
10+
pip install dist/*.whl
11+
```
12+
13+
14+
## For Developers
15+
16+
Use `make` to run common tasks (see the [Makefile](Makefile) for a complete list of available targets).
17+
18+
* `make build`: Build wheel
19+
* `make check`: Check code style
20+
* `make format`: Format code
21+
* `make test-unit`: Run unit tests
22+
23+
For interactive use, spawn a shell with `poetry shell` (after `poetry install`), then run an interpreter.

deps/k_release

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.0.52

deps/kwasm_release

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.48

0 commit comments

Comments
 (0)