Skip to content

Run Unit & Integration tests #469

Run Unit & Integration tests

Run Unit & Integration tests #469

Workflow file for this run

---
name: Run Unit & Integration tests
on:
workflow_call:
pull_request:
branches:
- develop
- master
workflow_dispatch:
inputs:
hyperon-das-atomdb-version:
description: "Hyperon-das-atomdb version (optional)"
required: false
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: Update hyperon-das-atomdb version
if: ${{inputs.hyperon-das-atomdb-version}}
run: |-
if [[ "${{inputs.hyperon-das-atomdb-version}}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
poetry add hyperon-das-atomdb=${{inputs.hyperon-das-atomdb-version}}
else
echo "The provided version '${{inputs.hyperon-das-atomdb-version}}' is invalid."
exit 1
fi
- 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: Update hyperon-das-atomdb version
if: ${{inputs.hyperon-das-atomdb-version}}
run: |-
if [[ "${{inputs.hyperon-das-atomdb-version}}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
poetry add hyperon-das-atomdb=${{inputs.hyperon-das-atomdb-version}}
else
echo "The provided version '${{inputs.hyperon-das-atomdb-version}}' is invalid."
exit 1
fi
- 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: Update hyperon-das-atomdb version
if: ${{inputs.hyperon-das-atomdb-version}}
run: |-
if [[ "${{inputs.hyperon-das-atomdb-version}}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
poetry add hyperon-das-atomdb=${{inputs.hyperon-das-atomdb-version}}
else
echo "The provided version '${{inputs.hyperon-das-atomdb-version}}' is invalid."
exit 1
fi
- name: Perform Integration Testing
run: make integration-tests
# benchmark:
# runs-on: ubuntu-22.04
# if: ${{ github.ref == 'refs/heads/master' }}
# 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
# echo "$real_time"
# exit 0
# fi
# echo "FAILURE!"
# exit 1