-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (116 loc) · 4.26 KB
/
tests.yml
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
name: Tests
on: [ pull_request ]
env:
MODULE_NAME: tarn
CI: true
jobs:
test-linux:
runs-on: ubuntu-20.04
env:
OS: ubuntu
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11' ]
services:
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server
openssh-server:
image: linuxserver/openssh-server
ports:
- 2222:2222
env:
PUID: 1001
PGID: 1001
PASSWORD_ACCESS: 'true'
USER_NAME: remote_user
USER_PASSWORD: password
volumes:
- /tmp:/tmp
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Build the package
run: |
python setup.py sdist
- name: Create ssh key
run: |
mkdir ~/.ssh && chmod 770 ~/.ssh
cp tests/assets/ssh_config ~/.ssh/config
# make sure we can connect now
sshpass -p password ssh -o "StrictHostKeyChecking no" remote echo Ok
- name: Install
run: |
pip install dist/*
pip install -r tests/requirements.txt
cd tests
export MODULE_PARENT=$(python -c "import $MODULE_NAME, os; print(os.path.dirname($MODULE_NAME.__path__[0]))")
export MODULE_PARENT=${MODULE_PARENT%"/"}
cd ..
echo $MODULE_PARENT
echo "MODULE_PARENT=$(echo $MODULE_PARENT)" >> $GITHUB_ENV
- name: Setup docker-compose services
run: |
mkdir -p /tmp/http/storage
docker-compose -f tests/assets/docker-compose.yml up -d
- name: Test with pytest
run: |
pytest tests --junitxml=reports/junit-${{ matrix.python-version }}-${OS}.xml --cov="$MODULE_PARENT/$MODULE_NAME" --cov-report=xml --cov-branch
- name: Generate coverage report
run: |
coverage xml -o reports/coverage-${{ matrix.python-version }}-${OS}.xml
sed -i -e "s|$MODULE_PARENT/||g" reports/coverage-${{ matrix.python-version }}-${OS}.xml
sed -i -e "s|$(echo $MODULE_PARENT/ | tr "/" .)||g" reports/coverage-${{ matrix.python-version }}-${OS}.xml
- name: Test older pydantic
run: |
pip install --upgrade "pydantic<2.0.0"
pytest tests --junitxml=reports/junit-${{ matrix.python-version }}-${OS}-pydantic1.xml --cov="$MODULE_PARENT/$MODULE_NAME" --cov-report=xml --cov-branch
coverage xml -o reports/coverage-${{ matrix.python-version }}-${OS}-pydantic1.xml
sed -i -e "s|$MODULE_PARENT/||g" reports/coverage-${{ matrix.python-version }}-${OS}-pydantic1.xml
sed -i -e "s|$(echo $MODULE_PARENT/ | tr "/" .)||g" reports/coverage-${{ matrix.python-version }}-${OS}-pydantic1.xml
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: reports-${{ matrix.python-version }}-${OS}
path: reports/*.xml
if: ${{ always() }}
- name: Upload coverage results
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
files: reports/coverage-*.xml
verbose: true
test-windows:
runs-on: windows-latest
env:
OS: windows
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Build the package
run: |
python setup.py sdist
- name: Install
run: |
pip install $(Get-ChildItem -LiteralPath dist -Filter *.tar.gz)
pip install -r tests/requirements.txt
- name: Test with pytest
run: |
pytest tests -m "not redis and not ssh and not nginx and not s3" --junitxml=reports/junit-${{ matrix.python-version }}-${OS}.xml --cov-branch
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: reports-${{ matrix.python-version }}-${OS}
path: reports/*.xml
if: ${{ always() }}