-
Notifications
You must be signed in to change notification settings - Fork 193
203 lines (177 loc) · 7.41 KB
/
test-changes.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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions and Operating Systems
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Test Changes
on:
push:
branches: [ "master" ]
pull_request:
types: [opened, reopened, synchronize, ready_for_review, labeled]
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
environment:
description: 'Environment to run tests against'
type: environment
required: true
jobs:
run-guard:
# it succeeds if any of the following conditions are met:
# - when the PR is not a draft and is not labeled 'prevent-ci'
# - when the PR is labeled 'force-ci'
runs-on: ubuntu-latest
if: |
( (!github.event.pull_request.draft) &&
(github.event.action != 'labeled') &&
(!contains( github.event.pull_request.labels.*.name, 'prevent-ci')) )
|| ((github.event.action != 'labeled') && contains( github.event.pull_request.labels.*.name, 'force-ci'))
|| (github.event.label.name == 'force-ci')
steps:
- name: Checking if CI shoud run for this push/PR...
run: echo Resuming CI. Continuing next jobs...
test-source-code:
needs: run-guard
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "windows-latest", "macos-latest" ]
python: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
include:
- python: '2.7'
os: "ubuntu-latest"
runs-on: "${{ matrix.os }}"
env:
testing: simple
python_eol: no
steps:
- name: Determine what scope of testing is available on ${{ matrix.os }}
if: |
(matrix.python >= '3.' ) && ( matrix.os != 'windows-latest' )
run: |
echo 'testing=full' >> $GITHUB_ENV
- name: Determine if the python ${{ matrix.python }} is available on ${{ matrix.os }}
if: |
(matrix.python < '3.' ) || ( matrix.python == '3.6' && matrix.os == 'ubuntu-latest' )
run: |
echo 'python_eol=yes' >> $GITHUB_ENV
- name: Checkout source code
uses: actions/checkout@v4
- name: Install linux tools
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends python3-h5py
- name: Set up Python ${{ matrix.python }}
if: env.python_eol == 'no'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Set up Python ${{ matrix.python }} discontinued on ${{ matrix.os }}
if: env.python_eol == 'yes'
uses: MatteoH2O1999/setup-python@v3
with:
python-version: ${{ matrix.python }}
cache: pip
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --prefer-binary -r requirements-tests.txt
- name: Setup environment variables for remote filesystem testing
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.8'
run: |
echo "Setup SMB environment variable to trigger testing in Petl"
echo 'PETL_TEST_SMB=smb://WORKGROUP;petl:test@localhost/public/' >> $GITHUB_ENV
echo "Setup SFTP environment variable to trigger testing in Petl"
echo 'PETL_TEST_SFTP=sftp://petl:test@localhost:2244/public/' >> $GITHUB_ENV
echo "::group::Install remote test dependencies"
python -m pip install --prefer-binary -r requirements-remote.txt
echo "::endgroup::"
- name: Install optional test dependencies for mode ${{ env.testing }}
if: matrix.os == 'ubuntu-latest' && matrix.python >= '3.7'
env:
DISABLE_BLOSC_AVX2: 1
run: |
echo "::group::Install tricky test dependencies"
if ! pip install --prefer-binary -r requirements-optional.txt ; then
echo 'Dismissed failure installing some optional package. Resuming tests...'
fi
# DISABLE_BLOSC_AVX2=1 && export DISABLE_BLOSC_AVX2
# pip install --prefer-binary bcolz
echo "::endgroup::"
- name: Install containers for remote filesystem testing
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.8'
run: |
echo "::group::Setup docker for SMB at: ${{ env.PETL_TEST_SMB }}$"
docker run -it --name samba -p 139:139 -p 445:445 -d "dperson/samba" -p -u "petl;test" -s "public;/public-dir;yes;no;yes;all"
echo "::endgroup::"
echo "::group::Setup docker for SFTP at: ${{ env.PETL_TEST_SFTP }}$"
docker run -it --name sftp -p 2244:22 -d atmoz/sftp petl:test:::public
echo "::endgroup::"
- name: Install containers for remote database testing
if: matrix.os == 'ubuntu-latest' && matrix.python >= '3.6'
run: |
echo "::group::Setup docker for MySQL"
docker run -it --name mysql -p 3306:3306 -p 33060:33060 -e MYSQL_ROOT_PASSWORD=pass0 -e MYSQL_DATABASE=petl -e MYSQL_USER=petl -e MYSQL_PASSWORD=test -d mysql:latest
echo "::endgroup::"
echo "::group::Setup docker for Postgres"
docker run -it --name postgres -p 5432:5432 -e POSTGRES_DB=petl -e POSTGRES_USER=petl -e POSTGRES_PASSWORD=test -d postgres:latest
echo "::endgroup::"
echo "::group::Install database test dependencies"
python -m pip install --prefer-binary -r requirements-database.txt
echo "::endgroup::"
- name: Setup petl package
run: python setup.py sdist bdist_wheel
- name: Test python source code for mode simple
if: env.testing == 'simple'
run: pytest --cov=petl petl
- name: Test documentation inside source code for mode full
if: env.testing == 'full'
run: |
echo "::group::Install extra packages test dependencies"
python -m pip install --prefer-binary -r requirements-formats.txt
echo "::endgroup::"
echo "::group::Perform doctest-modules execution with coverage"
pytest --doctest-modules --cov=petl petl
echo "::endgroup::"
- name: Coveralls
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.8'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python -m pip install --upgrade coveralls
coveralls --service=github
- name: Print source code coverage
run: coverage report -m
test-documentation:
needs: run-guard
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.8]
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install doc generation dependencies
run: |
python -m pip install --prefer-binary -r requirements-docs.txt
- name: Setup petl package
run: python setup.py build
- name: Test docs generation
run: |
cd docs
sphinx-build -W -b singlehtml -d ../build/doctrees . ../build/singlehtml