Skip to content

Commit 97986c3

Browse files
CaselITashb
andauthored
Add test workflox and tox (#74)
* add tests * fix pipeline * Update .github/workflows/run-test.yaml Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com> Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com>
1 parent 586ae19 commit 97986c3

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

.github/workflows/run-test.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
env:
8+
# global env to all steps
9+
TOX_WORKERS: -n2
10+
11+
jobs:
12+
run-test:
13+
name: ${{ matrix.python-version }}-${{ matrix.sqlalchemy }}
14+
runs-on: "ubuntu-latest"
15+
strategy:
16+
matrix:
17+
python-version:
18+
- "3.9"
19+
sqlalchemy:
20+
- sqla_release
21+
- sqla_master
22+
23+
fail-fast: false
24+
25+
# steps to run in each job. Some are github actions, others run shell commands
26+
steps:
27+
- name: Checkout repo
28+
uses: actions/checkout@v2
29+
30+
- name: Set up python
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
architecture: ${{ matrix.architecture }}
35+
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install --upgrade tox setuptools
40+
pip list
41+
42+
- name: Set env
43+
run: |
44+
echo "SQLA_REF=$(python .github/workflows/scripts/find_version.py ${{ matrix.sqlalchemy }})" >> $GITHUB_ENV
45+
46+
- name: Run tests
47+
run: |
48+
tox
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import json
2+
import sys
3+
from urllib import request
4+
5+
6+
def go(argv):
7+
if "sqla_release" in argv:
8+
result = request.urlopen(
9+
"https://pypi.org/pypi/SQLAlchemy/json", timeout=10
10+
)
11+
assert result.status == 200
12+
parsed = json.loads(result.read())
13+
version = parsed["info"]["version"]
14+
print(f"rel_{version}".replace(".", "_"))
15+
else:
16+
print("master")
17+
18+
if __name__ == "__main__":
19+
go(sys.argv)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ dist/
77
*.egg-info
88

99

10+
sqla

tox.ini

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[tox]
2+
3+
; envlist = py
4+
5+
SQLA_REPO = {env:SQLA_REPO:https://github.com/sqlalchemy/sqlalchemy.git}
6+
SQLA_REF = {env:SQLA_REF:master}
7+
8+
[testenv]
9+
10+
allowlist_externals=
11+
git
12+
13+
setenv=
14+
WORKERS={env:TOX_WORKERS:-n2}
15+
16+
deps=
17+
pytest>=6.2
18+
pytest-xdist
19+
greenlet != 0.4.17
20+
importlib_metadata; python_version < '3.8'
21+
mypy
22+
patch==1.*
23+
24+
changedir = sqla
25+
26+
commands_pre=
27+
python -c 'import shutil; shutil.rmtree(".", ignore_errors=True)'
28+
git clone --depth 1 {[tox]SQLA_REPO} --branch {[tox]SQLA_REF} .
29+
30+
31+
commands =
32+
pytest {env:WORKERS} -v test/ext/mypy/test_mypy_plugin_py3k.py {posargs}

0 commit comments

Comments
 (0)