Run Unit & Integration tests #297
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
--- | |
name: Run Unit & Integration tests | |
on: | |
workflow_call: | |
pull_request: | |
branches: | |
- develop | |
- master | |
workflow_dispatch: | |
jobs: | |
lint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ^3.10 | |
cache: "pip" | |
- name: Install dependencies | |
run: |- | |
pip3 install poetry | |
poetry lock --no-update | |
poetry export --dev -f requirements.txt | pip3 install -r /dev/stdin | |
- name: Check if the lint configuration matches the one in the DAS repository. | |
run: | | |
config_files=(".black.cfg" ".flake8.cfg" ".isort.cfg") | |
for config_file in "${config_files[@]}"; do | |
master_lint=$(curl -s https://raw.githubusercontent.com/singnet/das/master/.lint/${config_file} | shasum -a 256 | cut -d ' ' -f 1) | |
local_lint=$(shasum -a 256 ${config_file} | cut -d ' ' -f 1) | |
if [ "$master_lint" != "$local_lint" ]; then | |
echo "The local lint configuration differs from the one in the DAS repository." | |
exit 1 | |
fi | |
done | |
echo "All lint configurations match the ones in the DAS repository." | |
- name: Perform Code Linting | |
run: make lint | |
unit-tests: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ^3.10 | |
cache: "pip" | |
- name: Install dependencies | |
run: |- | |
pip3 install poetry | |
poetry lock --no-update | |
poetry export --dev -f requirements.txt | pip3 install -r /dev/stdin | |
- name: Execute Unit Test Suite | |
run: make unit-tests | |
coverage: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ^3.10 | |
cache: "pip" | |
- name: Install dependencies | |
run: |- | |
pip3 install poetry | |
poetry lock --no-update | |
poetry export --dev -f requirements.txt | pip3 install -r /dev/stdin | |
- name: Generate Coverage Report | |
run: make unit-tests-coverage | |
integration-tests: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ^3.10 | |
cache: "pip" | |
- name: Install dependencies | |
run: |- | |
pip3 install poetry | |
poetry lock --no-update | |
poetry export --dev -f requirements.txt | pip3 install -r /dev/stdin | |
- name: Perform Integration Testing | |
run: make integration-tests | |
benchmark: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ^3.10 | |
cache: "pip" | |
- name: Install dependencies | |
run: |- | |
pip3 install poetry hyperon | |
poetry lock --no-update | |
poetry install | |
- name: Build hyperon-das | |
run: poetry build | |
- name: Install hyperon-das | |
run: pip install $(find ./dist -name *.whl) | |
- name: Perform Benchmark | |
run: | | |
output=$(make performance-tests 2>&1) | |
real_time=$(echo "$output" | grep "^real" | awk 'NR==2 {print $2}') | |
if echo "$output" | grep -q 'SUCCESS!'; then | |
status="SUCCESS!" | |
else | |
status="FAILURE!" | |
fi | |
echo "$real_time $status" | |
if [ "$status" == "SUCCESS!" ]; then | |
exit 0 | |
else | |
exit 1 | |
fi |