refactor(metadata): static metadata assertion #6443
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
# yamllint disable rule:line-length | |
name: tests | |
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.10', '3.11', '3.12'], | |
# available OS's: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
'os': ['ubuntu-22.04', 'macos-13'], | |
} | |
# 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 | |
test: | |
name: python-${{ matrix.python }} (${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
needs: matrix | |
timeout-minutes: 120 # default is 360 | |
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 | |
- name: Run tests | |
run: poetry run make tests | |
- name: Upload coverage | |
uses: codecov/codecov-action@v4 | |
if: matrix.python == 3.11 && startsWith(matrix.os, 'ubuntu') | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |