@@ -2,7 +2,7 @@ name: check
2
2
on :
3
3
workflow_dispatch :
4
4
push :
5
- branches : " main"
5
+ branches : [ "main"]
6
6
tags-ignore : ["**"]
7
7
pull_request :
8
8
schedule :
@@ -36,45 +36,47 @@ jobs:
36
36
uses : actions/setup-python@v5
37
37
with :
38
38
python-version : " 3.12"
39
- - name : Install tox
40
- run : python -m pip install tox
39
+ - name : Pick environment to run
40
+ run : |
41
+ import codecs; import os
42
+ py = "${{ matrix.py }}"
43
+ py = "test.{}".format(py if py.startswith("pypy") else f"py{py}")
44
+ print(f"Picked {py}")
45
+ with codecs.open(os.environ["GITHUB_ENV"], mode="a", encoding="utf-8") as file_handler:
46
+ file_handler.write("FORCE_COLOR=1\n")
47
+ file_handler.write(f"ENV={py}\n")
48
+ shell : python
49
+ - name : Install hatch
50
+ run : python -m pip install hatch
41
51
- uses : actions/checkout@v4
42
52
with :
43
53
fetch-depth : 0
44
54
- name : Setup python for test ${{ matrix.py }}
45
55
uses : actions/setup-python@v5
46
56
with :
47
57
python-version : ${{ matrix.py }}
48
- - name : Pick environment to run
58
+ - name : Setup test environment
49
59
run : |
50
- import codecs
51
- import os
52
- import platform
53
- import sys
54
- cpy = platform.python_implementation() == "CPython"
55
- base =("{}{}{}" if cpy else "{}{}").format("py" if cpy else "pypy", *sys.version_info[0:2])
56
- env = "TOXENV={}\n".format(base)
57
- print("Picked:\n{}for{}".format(env, sys.version))
58
- with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler:
59
- file_handler.write(env)
60
- shell : python
61
- - name : Setup test suite
62
- run : tox -vv --notest
60
+ hatch -v env create ${ENV}
61
+ hatch run ${ENV}:pip freeze
62
+ shell : bash
63
63
- name : Run test suite
64
- run : tox --skip-pkg-install
64
+ run : hatch -v run ${ENV}:run
65
65
env :
66
66
PYTEST_ADDOPTS : " -vv --durations=20"
67
67
CI_RUN : " yes"
68
+ shell : bash
68
69
- name : Rename coverage report file
69
70
run : |
70
71
import os; import sys;
71
- os.rename(f".tox/ .coverage.{os.environ['TOXENV']} ", f".tox/ .coverage.{os.environ['TOXENV'] }-{sys.platform}")
72
+ os.rename(f"report{os.sep} .coverage.${{ matrix.py }} ", f"report{os.sep} .coverage.${{ matrix.py } }-{sys.platform}")
72
73
shell : python
73
74
- name : Upload coverage data
74
- uses : actions/upload-artifact@v3
75
+ uses : actions/upload-artifact@v4
75
76
with :
76
- name : coverage-data
77
- path : " .tox/.coverage.*"
77
+ name : coverage-${{ matrix.os }}-${{ matrix.py }}
78
+ path : " report/.coverage.*"
79
+ retention-days : 3
78
80
79
81
coverage :
80
82
name : Combine coverage
@@ -87,43 +89,42 @@ jobs:
87
89
- uses : actions/setup-python@v5
88
90
with :
89
91
python-version : " 3.12"
90
- - name : Install tox
91
- run : python -m pip install tox
92
+ - name : Let us have colors
93
+ run : echo "FORCE_COLOR=true" >> "$GITHUB_ENV"
94
+ - name : Install hatch
95
+ run : python -m pip install hatch
92
96
- name : Setup coverage tool
93
- run : tox -e coverage --notest
94
- - name : Install package builder
95
- run : python -m pip install build
96
- - name : Build package
97
- run : pyproject-build --wheel .
97
+ run : |
98
+ hatch -v env create coverage
99
+ hatch run coverage:pip freeze
98
100
- name : Download coverage data
99
- uses : actions/download-artifact@v3
101
+ uses : actions/download-artifact@v4
100
102
with :
101
- name : coverage-data
102
- path : .tox
103
+ path : report
104
+ pattern : coverage-*
105
+ merge-multiple : true
103
106
- name : Combine and report coverage
104
- run : tox -e coverage
107
+ run : hatch run coverage:run
105
108
- name : Upload HTML report
106
- uses : actions/upload-artifact@v3
109
+ uses : actions/upload-artifact@v4
107
110
with :
108
111
name : html-report
109
- path : .tox/htmlcov
112
+ path : report/html
110
113
111
114
check :
112
- name : ${{ matrix.tox_env }} - ${{ matrix.os }}
115
+ name : ${{ matrix.env.name }} - ${{ matrix.os }}
113
116
runs-on : ${{ matrix.os }}
114
117
strategy :
115
118
fail-fast : false
116
119
matrix :
117
120
os :
118
121
- ubuntu-22.04
119
122
- windows-2022
120
- tox_env :
121
- - dev
122
- - type
123
- - docs
124
- - readme
125
- exclude :
126
- - { os: windows-latest, tox_env: readme }
123
+ env :
124
+ - {"name": "default", "target": "show"}
125
+ - {"name": "type", "target": "run"}
126
+ - {"name": "docs", "target": "build"}
127
+ - {"name": "readme", "target": "run"}
127
128
steps :
128
129
- uses : actions/checkout@v4
129
130
with :
@@ -132,9 +133,11 @@ jobs:
132
133
uses : actions/setup-python@v5
133
134
with :
134
135
python-version : " 3.12"
135
- - name : Install tox
136
- run : python -m pip install tox
137
- - name : Setup test suite
138
- run : tox -vv --notest -e ${{ matrix.tox_env }}
139
- - name : Run test suite
140
- run : tox --skip-pkg-install -e ${{ matrix.tox_env }}
136
+ - name : Install hatch
137
+ run : python -m pip install hatch
138
+ - name : Setup ${{ matrix.env.name }}
139
+ run : |
140
+ hatch -v env create ${{ matrix.env.name }}
141
+ hatch run ${{ matrix.env.name }}:pip freeze
142
+ - name : Run ${{ matrix.env.name }}
143
+ run : hatch -v run ${{ matrix.env.name }}:${{ matrix.env.target }}
0 commit comments