Skip to content

feat: hathorlib move runner #9261

feat: hathorlib move runner

feat: hathorlib move runner #9261

Workflow file for this run

# yamllint disable rule:line-length
name: ci
on: # yamllint disable-line rule:truthy
push:
branches:
- master
- dev
tags:
- v*
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
shell: python
run: |
import os
import json
full_matrix = {
'python': ['3.11', '3.12', '3.13'],
# available OS's: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
'os': ['ubuntu-22.04', 'macos-15'],
}
# this is the fastest one:
reduced_matrix = {
'python': ['3.12'],
'os': ['ubuntu-22.04'],
}
github_repository = os.environ['GITHUB_REPOSITORY']
if github_repository.lower() == 'hathornetwork/hathor-core':
matrix = full_matrix
else:
matrix = reduced_matrix
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write('matrix={}\n'.format(json.dumps(matrix)))
check-matrix:
runs-on: ubuntu-latest
needs: matrix
steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- name: Check matrix definition
run: |
matrix='${{ needs.matrix.outputs.matrix }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
lint:
name: lint py${{ matrix.python }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: matrix
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup-hathor-env
name: Setup Hathor node environment
with:
python: ${{ matrix.python }}
os: ${{ matrix.os }}
- name: Cache mypy
uses: actions/cache@v4
with:
path: .mypy_cache
# this key is setup such that every branch has its cache and new branches can reuse dev's cache, but not the other way around
key: ${{ runner.os }}-py${{ matrix.python }}-mypy-${{ github.head_ref || github.ref }}
restore-keys: |
${{ runner.os }}-py${{ matrix.python }}-mypy-refs/heads/dev-
${{ runner.os }}-py${{ matrix.python }}-mypy-
- name: Run linters
run: poetry run make check
test-cli:
name: test-cli py${{ matrix.python }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: matrix
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup-hathor-env
name: Setup Hathor node environment
with:
python: ${{ matrix.python }}
os: ${{ matrix.os }}
- name: Run CLI tests
run: poetry run make tests-cli
- name: Upload coverage
uses: codecov/codecov-action@v4
if: matrix.python == 3.12 && startsWith(matrix.os, 'ubuntu')
with:
flags: test-cli
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
test-lib:
name: test-lib py${{ matrix.python }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: matrix
timeout-minutes: 120
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup-hathor-env
name: Setup Hathor node environment
with:
python: ${{ matrix.python }}
os: ${{ matrix.os }}
- name: Run lib tests
run: poetry run make tests-lib
- name: Upload coverage
uses: codecov/codecov-action@v4
if: matrix.python == 3.12 && startsWith(matrix.os, 'ubuntu')
with:
flags: test-lib
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
test-other:
name: test-other py${{ matrix.python }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: matrix
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup-hathor-env
name: Setup Hathor node environment
with:
python: ${{ matrix.python }}
os: ${{ matrix.os }}
- name: Run genesis tests
run: |
HATHOR_TEST_CONFIG_YAML='./hathorlib/hathorlib/conf/mainnet.yml' poetry run pytest -n0 --cov=hathor hathor_tests/tx/test_genesis.py
HATHOR_TEST_CONFIG_YAML='./hathorlib/hathorlib/conf/testnet.yml' poetry run pytest -n0 --cov=hathor --cov-append hathor_tests/tx/test_genesis.py
HATHOR_TEST_CONFIG_YAML='./hathorlib/hathorlib/conf/nano_testnet.yml' poetry run pytest -n0 --cov=hathor --cov-append hathor_tests/tx/test_genesis.py
- name: Run custom tests
run: poetry run bash ./extras/custom_tests.sh
- name: Run CI tests
run: poetry run pytest --cov=hathor --cov-append extras/github/
- name: Upload coverage
uses: codecov/codecov-action@v4
if: matrix.python == 3.12 && startsWith(matrix.os, 'ubuntu')
with:
flags: test-other
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
all-checks:
name: all-checks
runs-on: ubuntu-latest
if: always()
needs: [lint, test-cli, test-lib, test-other]
steps:
- name: Check job results
run: |
if [[ "${{ needs.lint.result }}" != "success" ||
"${{ needs.test-cli.result }}" != "success" ||
"${{ needs.test-lib.result }}" != "success" ||
"${{ needs.test-other.result }}" != "success" ]]; then
echo "One or more jobs failed or were cancelled:"
echo " lint: ${{ needs.lint.result }}"
echo " test-cli: ${{ needs.test-cli.result }}"
echo " test-lib: ${{ needs.test-lib.result }}"
echo " test-other: ${{ needs.test-other.result }}"
exit 1
fi
echo "All checks passed!"