-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 <devops@runtimeverification.com>
- Loading branch information
1 parent
7fa2c93
commit cc0c6cd
Showing
28 changed files
with
1,773 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"template": "https://github.com/runtimeverification/python-project-template", | ||
"commit": "601d5e2a0e8a98c87dcb1ae694d22d76d0114e01", | ||
"checkout": null, | ||
"context": { | ||
"cookiecutter": { | ||
"project_name": "ksoroban", | ||
"project_slug": "ksoroban", | ||
"package_name": "ksoroban", | ||
"version": "0.1.0", | ||
"description": "K tooling for the Soroban platform", | ||
"author_name": "Runtime Verification, Inc.", | ||
"author_email": "contact@runtimeverification.com", | ||
"_template": "https://github.com/runtimeverification/python-project-template" | ||
} | ||
}, | ||
"directory": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
extend-select = B9, TC1 | ||
extend-ignore = B950,E,W1,W2,W3,W4,W5 | ||
per-file-ignores = | ||
*/__init__.py: F401 | ||
type-checking-strict = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ARG K_VERSION | ||
FROM runtimeverificationinc/kframework-k:ubuntu-jammy-${K_VERSION} | ||
|
||
ARG PYTHON_VERSION=3.10 | ||
|
||
RUN apt-get -y update \ | ||
&& apt-get -y install \ | ||
graphviz \ | ||
python${PYTHON_VERSION} \ | ||
python${PYTHON_VERSION}-dev \ | ||
&& apt-get -y clean | ||
|
||
ARG USER_ID=9876 | ||
ARG GROUP_ID=9876 | ||
RUN groupadd -g ${GROUP_ID} user \ | ||
&& useradd -m -u ${USER_ID} -s /bin/bash -g user user | ||
|
||
USER user | ||
WORKDIR /home/user | ||
|
||
ENV PATH=/home/user/.local/bin:${PATH} | ||
RUN curl -sSL https://install.python-poetry.org | python3 - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: 'With Docker' | ||
description: 'Run a given stage with Docker Image' | ||
inputs: | ||
container-name: | ||
description: 'Docker container name to use' | ||
type: string | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 'Set up Docker' | ||
shell: bash {0} | ||
run: | | ||
set -euxo pipefail | ||
CONTAINER_NAME=${{ inputs.container-name }} | ||
TAG=runtimeverificationinc/${CONTAINER_NAME} | ||
K_VERSION=$(cat deps/k_release) | ||
docker build . \ | ||
--file .github/actions/with-docker/Dockerfile \ | ||
--tag ${TAG} \ | ||
--build-arg K_VERSION=${K_VERSION} | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: 'Master Push' | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
|
||
release: | ||
name: 'Publish Release' | ||
runs-on: [self-hosted, linux, flyweight] | ||
steps: | ||
- name: 'Check out code' | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.push.head.sha }} | ||
fetch-depth: 0 | ||
- name: 'Make release' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
set -x | ||
VERSION=v$(cat package/version) | ||
gh release create ${VERSION} --target ${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: 'Test' | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
|
||
version-bump: | ||
name: 'Version Bump' | ||
runs-on: [self-hosted, linux, flyweight] | ||
steps: | ||
- name: 'Check out code' | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.JENKINS_GITHUB_PAT }} | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: 'Configure GitHub user' | ||
run: | | ||
git config user.name devops | ||
git config user.email devops@runtimeverification.com | ||
- name: 'Update version' | ||
run: | | ||
og_version=$(git show origin/${GITHUB_BASE_REF}:package/version) | ||
./package/version.sh bump ${og_version} | ||
./package/version.sh sub | ||
new_version=$(cat package/version) | ||
git add --update && git commit --message "Set Version: ${new_version}" || true | ||
- name: 'Push updates' | ||
run: git push origin HEAD:${GITHUB_HEAD_REF} | ||
|
||
code-quality-checks: | ||
needs: version-bump | ||
name: 'Code Quality Checks' | ||
runs-on: [self-hosted, linux, flyweight] | ||
steps: | ||
- name: 'Check out code' | ||
uses: actions/checkout@v3 | ||
- name: 'Run code quality checks' | ||
run: make check | ||
- name: 'Run pyupgrade' | ||
run: make pyupgrade | ||
- name: 'Run unit tests' | ||
run: make test-unit | ||
|
||
integration-tests: | ||
needs: code-quality-checks | ||
name: 'Integration Tests' | ||
runs-on: [self-hosted, linux, normal] | ||
env: | ||
CONTAINER: ksoroban-integration-${{ github.sha }} | ||
steps: | ||
- name: 'Check out code' | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 'Set up Docker' | ||
uses: ./.github/actions/with-docker | ||
with: | ||
container-name: ${CONTAINER} | ||
- name: 'Build ksoroban' | ||
run: docker exec --user user ${CONTAINER} poetry install | ||
- name: 'Build semantics' | ||
run: docker exec --user user ${CONTAINER} make kdist-build | ||
- name: 'Run integration tests' | ||
run: docker exec --user user ${CONTAINER} make test-integration | ||
- name: 'Tear down Docker' | ||
if: always() | ||
run: docker stop --time=0 ${CONTAINER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: 'Update Version' | ||
on: | ||
push: | ||
branches: | ||
- '_update-deps/runtimeverification/wasm-semantics' | ||
workflow_dispatch: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
update-deps: | ||
name: 'Update Dependecies' | ||
runs-on: [self-hosted, linux, flyweight] | ||
steps: | ||
- name: 'Check out code' | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.JENKINS_GITHUB_PAT }} | ||
- name: 'Configure GitHub user' | ||
run: | | ||
git config user.name devops | ||
git config user.email devops@runtimeverification.com | ||
- name: 'Install Python' | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- name: 'Install Poetry' | ||
uses: Gr1N/setup-poetry@v9 | ||
- name: 'Update Poetry files' | ||
run: | | ||
PYKWASM_VERSION="$(cat deps/kwasm_release)" | ||
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 | ||
poetry update | ||
git add . && git commit -m "Sync Poetry files ${PYKWASM_VERSION}" || true | ||
- name: 'Update K release' | ||
run: | | ||
K_VERSION=$(poetry run python3 -c 'import pyk; print(pyk.__version__)') | ||
echo ${K_VERSION} > deps/k_release | ||
git add deps/k_release && git commit -m "deps/k_release: sync release file version ${K_VERSION}" || true | ||
- name: 'Push updates' | ||
run: git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/dist/ | ||
__pycache__/ | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
POETRY := poetry | ||
POETRY_RUN := $(POETRY) run | ||
|
||
|
||
default: check test-unit | ||
|
||
all: check cov | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf dist .coverage cov-* .mypy_cache .pytest_cache | ||
find -type d -name __pycache__ -prune -exec rm -rf {} \; | ||
|
||
.PHONY: build | ||
build: | ||
$(POETRY) build | ||
|
||
.PHONY: poetry-install | ||
poetry-install: | ||
$(POETRY) install | ||
|
||
|
||
# Semantics | ||
|
||
kdist-build: poetry-install | ||
$(POETRY) run kdist -v build soroban-semantics.llvm | ||
|
||
kdist-clean: poetry-install | ||
$(POETRY) run kdist clean | ||
|
||
|
||
# Tests | ||
|
||
TEST_ARGS := | ||
|
||
test: test-all | ||
|
||
test-all: poetry-install | ||
$(POETRY_RUN) pytest src/tests --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS) | ||
|
||
test-unit: poetry-install | ||
$(POETRY_RUN) pytest src/tests/unit --maxfail=1 --verbose $(TEST_ARGS) | ||
|
||
test-integration: poetry-install | ||
$(POETRY_RUN) pytest src/tests/integration --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS) | ||
|
||
|
||
# Coverage | ||
|
||
COV_ARGS := | ||
|
||
cov: cov-all | ||
|
||
cov-%: TEST_ARGS += --cov=ksoroban --no-cov-on-fail --cov-branch --cov-report=term | ||
|
||
cov-all: TEST_ARGS += --cov-report=html:cov-all-html $(COV_ARGS) | ||
cov-all: test-all | ||
|
||
cov-unit: TEST_ARGS += --cov-report=html:cov-unit-html $(COV_ARGS) | ||
cov-unit: test-unit | ||
|
||
cov-integration: TEST_ARGS += --cov-report=html:cov-integration-html $(COV_ARGS) | ||
cov-integration: test-integration | ||
|
||
|
||
# Checks and formatting | ||
|
||
format: autoflake isort black | ||
check: check-flake8 check-mypy check-autoflake check-isort check-black | ||
|
||
check-flake8: poetry-install | ||
$(POETRY_RUN) flake8 src | ||
|
||
check-mypy: poetry-install | ||
$(POETRY_RUN) mypy src | ||
|
||
autoflake: poetry-install | ||
$(POETRY_RUN) autoflake --quiet --in-place src | ||
|
||
check-autoflake: poetry-install | ||
$(POETRY_RUN) autoflake --quiet --check src | ||
|
||
isort: poetry-install | ||
$(POETRY_RUN) isort src | ||
|
||
check-isort: poetry-install | ||
$(POETRY_RUN) isort --check src | ||
|
||
black: poetry-install | ||
$(POETRY_RUN) black src | ||
|
||
check-black: poetry-install | ||
$(POETRY_RUN) black --check src | ||
|
||
|
||
# Optional tools | ||
|
||
SRC_FILES := $(shell find src -type f -name '*.py') | ||
|
||
pyupgrade: poetry-install | ||
$(POETRY_RUN) pyupgrade --py310-plus $(SRC_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
# kasmer-soroban | ||
# ksoroban | ||
|
||
|
||
## Installation | ||
|
||
Prerequsites: `python >= 3.10`, `pip >= 20.0.2`, `poetry >= 1.3.2`. | ||
|
||
```bash | ||
make build | ||
pip install dist/*.whl | ||
``` | ||
|
||
|
||
## For Developers | ||
|
||
Use `make` to run common tasks (see the [Makefile](Makefile) for a complete list of available targets). | ||
|
||
* `make build`: Build wheel | ||
* `make check`: Check code style | ||
* `make format`: Format code | ||
* `make test-unit`: Run unit tests | ||
|
||
For interactive use, spawn a shell with `poetry shell` (after `poetry install`), then run an interpreter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.0.52 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.48 |
Oops, something went wrong.