-
Notifications
You must be signed in to change notification settings - Fork 43
183 lines (183 loc) · 6.3 KB
/
main.yml
File metadata and controls
183 lines (183 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# 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!"