Skip to content

Commit 7a0ca8a

Browse files
committed
chore(github): Split GitHub main action into lint, test-cli, test-lib, test-other
1 parent 683d475 commit 7a0ca8a

File tree

2 files changed

+115
-8
lines changed

2 files changed

+115
-8
lines changed

.github/actions/setup-hathor-env/action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ runs:
1818
python-version: ${{ inputs.python }}
1919
cache: 'poetry'
2020

21+
- name: Configure in-project virtualenv
22+
shell: bash
23+
run: poetry config virtualenvs.in-project true
24+
25+
- name: Cache virtualenv
26+
uses: actions/cache@v4
27+
with:
28+
path: .venv
29+
key: venv-${{ runner.os }}-py${{ inputs.python }}-${{ hashFiles('poetry.lock') }}
30+
restore-keys: |
31+
venv-${{ runner.os }}-py${{ inputs.python }}-
32+
2133
- name: Install Ubuntu dependencies
2234
if: startsWith(inputs.os, 'ubuntu')
2335
run: |
@@ -35,5 +47,5 @@ runs:
3547
shell: bash
3648

3749
- name: Install Poetry dependencies
38-
run: poetry install -n --no-root
50+
run: poetry sync -n --no-root
3951
shell: bash

.github/workflows/main.yml

Lines changed: 102 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# yamllint disable rule:line-length
2-
name: tests
2+
name: ci
33
on: # yamllint disable-line rule:truthy
44
push:
55
branches:
@@ -52,14 +52,14 @@ jobs:
5252
echo $matrix
5353
echo $matrix | jq .
5454
echo $matrix | json2yaml
55-
test:
56-
name: python-${{ matrix.python }} (${{ matrix.os }})
55+
lint:
56+
name: lint py${{ matrix.python }} (${{ matrix.os }})
5757
runs-on: ${{ matrix.os }}
5858
needs: matrix
59-
timeout-minutes: 120 # default is 360
59+
timeout-minutes: 30
6060
strategy:
6161
fail-fast: false
62-
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
62+
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
6363
steps:
6464
- name: Checkout
6565
uses: actions/checkout@v4
@@ -79,10 +79,105 @@ jobs:
7979
${{ runner.os }}-py${{ matrix.python }}-mypy-
8080
- name: Run linters
8181
run: poetry run make check
82-
- name: Run tests
83-
run: poetry run make tests
82+
test-cli:
83+
name: test-cli py${{ matrix.python }} (${{ matrix.os }})
84+
runs-on: ${{ matrix.os }}
85+
needs: matrix
86+
timeout-minutes: 30
87+
strategy:
88+
fail-fast: false
89+
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
- uses: ./.github/actions/setup-hathor-env
94+
name: Setup Hathor node environment
95+
with:
96+
python: ${{ matrix.python }}
97+
os: ${{ matrix.os }}
98+
- name: Run CLI tests
99+
run: poetry run make tests-cli
84100
- name: Upload coverage
85101
uses: codecov/codecov-action@v4
86102
if: matrix.python == 3.12 && startsWith(matrix.os, 'ubuntu')
103+
with:
104+
flags: test-cli
87105
env:
88106
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
107+
test-lib:
108+
name: test-lib py${{ matrix.python }} (${{ matrix.os }})
109+
runs-on: ${{ matrix.os }}
110+
needs: matrix
111+
timeout-minutes: 120
112+
strategy:
113+
fail-fast: false
114+
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
115+
steps:
116+
- name: Checkout
117+
uses: actions/checkout@v4
118+
- uses: ./.github/actions/setup-hathor-env
119+
name: Setup Hathor node environment
120+
with:
121+
python: ${{ matrix.python }}
122+
os: ${{ matrix.os }}
123+
- name: Run lib tests
124+
run: poetry run make tests-lib
125+
- name: Upload coverage
126+
uses: codecov/codecov-action@v4
127+
if: matrix.python == 3.12 && startsWith(matrix.os, 'ubuntu')
128+
with:
129+
flags: test-lib
130+
env:
131+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
132+
test-other:
133+
name: test-other py${{ matrix.python }} (${{ matrix.os }})
134+
runs-on: ${{ matrix.os }}
135+
needs: matrix
136+
timeout-minutes: 30
137+
strategy:
138+
fail-fast: false
139+
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
140+
steps:
141+
- name: Checkout
142+
uses: actions/checkout@v4
143+
- uses: ./.github/actions/setup-hathor-env
144+
name: Setup Hathor node environment
145+
with:
146+
python: ${{ matrix.python }}
147+
os: ${{ matrix.os }}
148+
- name: Run genesis tests
149+
run: |
150+
HATHOR_TEST_CONFIG_YAML='./hathor/conf/mainnet.yml' poetry run pytest -n0 --cov=hathor hathor_tests/tx/test_genesis.py
151+
HATHOR_TEST_CONFIG_YAML='./hathor/conf/testnet.yml' poetry run pytest -n0 --cov=hathor --cov-append hathor_tests/tx/test_genesis.py
152+
HATHOR_TEST_CONFIG_YAML='./hathor/conf/nano_testnet.yml' poetry run pytest -n0 --cov=hathor --cov-append hathor_tests/tx/test_genesis.py
153+
- name: Run custom tests
154+
run: poetry run bash ./extras/custom_tests.sh
155+
- name: Run CI tests
156+
run: poetry run pytest --cov=hathor --cov-append extras/github/
157+
- name: Upload coverage
158+
uses: codecov/codecov-action@v4
159+
if: matrix.python == 3.12 && startsWith(matrix.os, 'ubuntu')
160+
with:
161+
flags: test-other
162+
env:
163+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
164+
all-checks:
165+
name: all-checks
166+
runs-on: ubuntu-latest
167+
if: always()
168+
needs: [lint, test-cli, test-lib, test-other]
169+
steps:
170+
- name: Check job results
171+
run: |
172+
if [[ "${{ needs.lint.result }}" != "success" ||
173+
"${{ needs.test-cli.result }}" != "success" ||
174+
"${{ needs.test-lib.result }}" != "success" ||
175+
"${{ needs.test-other.result }}" != "success" ]]; then
176+
echo "One or more jobs failed or were cancelled:"
177+
echo " lint: ${{ needs.lint.result }}"
178+
echo " test-cli: ${{ needs.test-cli.result }}"
179+
echo " test-lib: ${{ needs.test-lib.result }}"
180+
echo " test-other: ${{ needs.test-other.result }}"
181+
exit 1
182+
fi
183+
echo "All checks passed!"

0 commit comments

Comments
 (0)