Skip to content

Commit

Permalink
Re-organize tests on CI (#237)
Browse files Browse the repository at this point in the history
* Remove rule `unittest-python` from `Makefile`

* Fix Python warnings

* Fix target `test-testapi`

* Add target `build-all`

* Consolidate test jobs

* Set Version: 0.1.37

* Set Version: 0.1.38

---------

Co-authored-by: devops <[email protected]>
  • Loading branch information
tothtamas28 and devops authored Apr 18, 2024
1 parent 08aef39 commit a3d0617
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 134 deletions.
158 changes: 41 additions & 117 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,15 @@ jobs:
submodules: recursive
- name: 'Install Poetry'
uses: Gr1N/setup-poetry@v8
- name: 'Build and run code quality checks'
- name: 'Build kmultiversx'
run: make kmultiversx
- name: 'Run code quality checks'
run: make -C kmultiversx check
compilation-tests:
runs-on: [self-hosted, linux, normal]
name: 'Compilation Tests'
needs: [python-code-quality-checks]
timeout-minutes: 30
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
with:
container-name: elrond-semantics-ci-${{ github.sha }}
- name: 'Build Haskell'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make build-haskell'
- name: 'Tear down Docker'
if: always()
run: |
docker stop --time=0 elrond-semantics-ci-${GITHUB_SHA}

simple-tests:
tests:
runs-on: [self-hosted, linux, normal]
name: 'Simple Tests'
needs: [python-code-quality-checks]
timeout-minutes: 30
name: 'Tests'
timeout-minutes: 45
steps:
- name: 'Check out code'
uses: actions/checkout@v3
Expand All @@ -80,14 +61,28 @@ jobs:
uses: ./.github/actions/with-docker
with:
container-name: elrond-semantics-ci-${{ github.sha }}
- name: 'Build'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make build'
- name: 'Run Python Unit Tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make unittest-python'
- name: 'Run Simple Test'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-simple -j6'
- name: 'Run Mandos Tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make mandos-test -j6'
- name: 'Build kmultiversx'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make kmultiversx
- name: 'Build plugin submodule'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make plugin-deps
- name: 'Build K definitions'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make build-all
- name: 'KMultiversX Tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make -C kmultiversx test
- name: 'Simple Tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-simple -j6
- name: 'Mandos Tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make mandos-test -j6
- name: 'TestApi tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-testapi
- name: 'Contract Test: Adder'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-elrond-adder
- name: 'Contract Test: Crowdfunding ESDT'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-elrond-crowdfunding-esdt
- name: 'Contract Test: Multisig'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-elrond-multisig
- name: 'Contract Tests: Custom'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-custom-contracts
- name: 'Tear down Docker'
if: always()
run: |
Expand All @@ -96,84 +91,7 @@ jobs:
feature-tests:
runs-on: [self-hosted, linux, normal]
name: 'Feature Tests'
needs: [simple-tests]
timeout-minutes: 120
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
with:
container-name: elrond-semantics-ci-${{ github.sha }}
- name: 'Build'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make build'
- name: 'Run Basic Feature Test'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-elrond-basic-features -j6'
- name: 'Run Alloc Feature Test'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-elrond-alloc-features -j6'
- name: 'Run Composability Feature Test'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-elrond-composability-features -j6'
- name: 'Tear down Docker'
if: always()
run: |
docker stop --time=0 elrond-semantics-ci-${GITHUB_SHA}
example-contract-tests:
runs-on: [self-hosted, linux, normal]
name: 'Example Contract Tests'
needs: [feature-tests]
timeout-minutes: 60
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
with:
container-name: elrond-semantics-ci-${{ github.sha }}
- name: 'Build'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make build'
- name: 'Run Adder Contract Test'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-elrond-adder'
- name: 'Run Crowdfunding ESDT Contract Test'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-elrond-crowdfunding-esdt'
- name: 'Run Multisig Contract Test'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-elrond-multisig'
- name: 'Tear down Docker'
if: always()
run: |
docker stop --time=0 elrond-semantics-ci-${GITHUB_SHA}
custom-contract-tests:
runs-on: [self-hosted, linux, normal]
name: 'Custom Contract Tests'
needs: [feature-tests]
timeout-minutes: 30
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
with:
container-name: elrond-semantics-ci-${{ github.sha }}
- name: 'Build'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make build'
- name: 'Run Custom Contract Tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-custom-contracts'
- name: 'Tear down Docker'
if: always()
run: |
docker stop --time=0 elrond-semantics-ci-${GITHUB_SHA}
kmultiversx-tests:
needs: simple-tests
name: 'KMultiversX Tests'
runs-on: [self-hosted, linux, normal]
timeout-minutes: 45
steps:
- name: 'Check out code'
uses: actions/checkout@v3
Expand All @@ -183,12 +101,18 @@ jobs:
uses: ./.github/actions/with-docker
with:
container-name: elrond-semantics-ci-${{ github.sha }}
- name: 'Build Kasmer'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make build-kasmer'
- name: 'Run tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make -C kmultiversx test'
- name: 'Run TestApi tests'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} /bin/bash -c 'make test-testapi'
- name: 'Build kmultiversx'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make kmultiversx
- name: 'Build plugin submodule'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make plugin-deps
- name: 'Build K definition'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make build
- name: 'Feature Test: Basic'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-elrond-basic-features -j6
- name: 'Feature Test: Alloc'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-elrond-alloc-features -j6
- name: 'Feature Test: Composability'
run: docker exec -t elrond-semantics-ci-${GITHUB_SHA} make test-elrond-composability-features -j6
- name: 'Tear down Docker'
if: always()
run: |
Expand Down
29 changes: 14 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ build-kasmer: kmultiversx plugin-deps
build-haskell: kmultiversx
$(POETRY) run kdist -v build mx-semantics.haskell-\* -j2

.PHONY: build-all
build-all: kmultiversx plugin-deps
K_OPTS='$(K_OPTS)' $(POETRY) run kdist -v build mx-semantics.\* -j4

.PHONY: clean
clean: kmultiversx
$(POETRY) run kdist clean
Expand Down Expand Up @@ -223,16 +227,11 @@ TEST_KASMER := $(POETRY_RUN) kasmer
TEST_TESTAPI_DIR := tests/contracts/test_testapi
testapi_tests=$(shell find $(TEST_TESTAPI_DIR) -name "*.scen.json")

test-testapi: build sc-build/$(TEST_TESTAPI_DIR)
test-testapi: build-kasmer sc-build/$(TEST_TESTAPI_DIR)
$(TEST_KASMER) -d $(TEST_TESTAPI_DIR)

# Unit Tests
# ----------
PYTHON_UNITTEST_FILES =
unittest-python: $(PYTHON_UNITTEST_FILES:=.unit)

MANDOS_KOMPILED := $(shell $(POETRY_RUN) kdist which mx-semantics.llvm-mandos)
KWASM_SRC_DIR := $(shell $(POETRY_RUN) python -c 'from pykwasm.kdist.plugin import K_DIR; print(K_DIR)')
# Coverage
# --------

ELROND_FILE_NAMES := elrond.md \
elrond-config.md \
Expand All @@ -243,13 +242,13 @@ ELROND_FILE_NAMES := elrond.md \
kasmer.md \
$(wildcard data/*.k) \
$(wildcard vmhooks/*.md)
ELROND_FILES_KWASM_DIR := $(patsubst %,$(KWASM_SRC_DIR)/%,$(ELROND_FILE_NAMES))

%.unit: %
python3 $<

rule-coverage:
python3 rule_coverage.py $(MANDOS_KOMPILED) $(ELROND_FILES_KWASM_DIR)
rule-coverage: kmultiversx
$(eval MANDOS_KOMPILED := $(shell $(POETRY_RUN) kdist which mx-semantics.llvm-mandos))
$(eval KWASM_SRC_DIR := $(shell $(POETRY_RUN) python -c 'from pykwasm.kdist.plugin import K_DIR; print(K_DIR)'))
$(eval ELROND_FILES := $(patsubst %,$(KWASM_SRC_DIR)/%,$(ELROND_FILE_NAMES)))
python3 rule_coverage.py $(MANDOS_KOMPILED) $(ELROND_FILES)

clean-coverage:
clean-coverage: kmultiversx
$(eval MANDOS_KOMPILED := $(shell $(POETRY_RUN) kdist which mx-semantics.llvm-mandos))
rm $(MANDOS_KOMPILED)/*_coverage.txt $(MANDOS_KOMPILED)/coverage.txt
2 changes: 1 addition & 1 deletion kmultiversx/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kmultiversx"
version = "0.1.37"
version = "0.1.38"
description = "Python tools for Elrond semantics"
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.37
0.1.38

0 comments on commit a3d0617

Please sign in to comment.