-
Notifications
You must be signed in to change notification settings - Fork 80
227 lines (215 loc) · 7.17 KB
/
run_ci.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Python
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '10 0 * * *'
env:
PIP_CACHE_DIR: "${{ github.workspace }}/.cache/pip"
XDG_CACHE_HOME: "${{ github.workspace }}/.cache"
POETRY_VIRTUALENVS_IN_PROJECT: "true"
REQUESTS_CA_BUNDLE: "/etc/ssl/certs/ca-certificates.crt"
SECRET_DETECTION_JSON_REPORT_FILE: "gitleaks.json"
jobs:
black:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install poetry==1.4.2
poetry install -vv -E keyring
- name: Run black check
run: |
source .venv/bin/activate
poetry run black --check .
flake8:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install poetry==1.4.2
poetry install -vv -E keyring
- name: Run flake8 check
run: |
source .venv/bin/activate
poetry run flake8 deepl tests
license_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run license check
run: |
./license_checker.sh '*.py' | tee license_check_output.txt
[ ! -s license_check_output.txt ]
mypy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install poetry==1.4.2
poetry install -vv -E keyring
- name: Run mypy check
run: |
source .venv/bin/activate
poetry run mypy --exclude 'examples/' .
secret_detection:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install and run secret detection
run: |
wget https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz
tar -xzf gitleaks_8.18.4_linux_x64.tar.gz
EXITCODE=0
./gitleaks detect -r ${SECRET_DETECTION_JSON_REPORT_FILE} --source . --log-opts="--all --full-history" || EXITCODE=$?
if [[ $EXITCODE -ne 0 ]]; then
exit $EXITCODE
fi
- name: Upload secret detection artifact
uses: actions/upload-artifact@v4
with:
name: secret-detection-results
path: gitleaks.json
package:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install poetry==1.4.2
poetry install -vv -E keyring
- name: Build package
run: |
source .venv/bin/activate
poetry build --verbose --no-interaction
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: dist/
# Test and `pypi upload` stage are disabled/missing for now. Code needs to be tested
#######################################################
# test:
# runs-on: ${{ matrix.config.docker-image }}
# strategy:
# matrix:
# config:
# - docker-image: python:3.6
# use-mock-server: use mock server
# use-old-poetry-version: use old poetry version
# - docker-image: python:3.7
# use-mock-server: use mock server
# - docker-image: python:3.8
# use-mock-server: use mock server
# - docker-image: python:3.9
# use-mock-server: use mock server
# - docker-image: python:3.10
# use-mock-server: use mock server
# - docker-image: python:3.11
# use-mock-server: use mock server
# - docker-image: python:3.11
# - docker-image: python:3.6
# use-mock-server: use mock server
# use-old-poetry-version: use old poetry version
# extra-poetry-add-argument: [email protected]
# - docker-image: python:3.9
# use-mock-server: use mock server
# extra-poetry-add-argument: [email protected]
# # Set minimum possible requests and urllib3 versions to work with Python 3.11
# - docker-image: python:3.11
# use-mock-server: use mock server
# extra-poetry-add-argument: [email protected] [email protected]
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Run tests
# run: |
# if [[ ! -z "${{ matrix.config.extra-poetry-add-argument }}" ]]; then
# echo "Running poetry add ${{ matrix.config.extra-poetry-add-argument }}"
# poetry add ${{ matrix.config.extra-poetry-add-argument }}
# fi
# if [[ ! -z "${{ matrix.config.use-mock-server }}" ]]; then
# echo "Using mock server"
# export DEEPL_SERVER_URL=http://deepl-mock:3000
# export DEEPL_MOCK_SERVER_PORT=3000
# export DEEPL_PROXY_URL=http://deepl-mock:3001
# export DEEPL_MOCK_PROXY_SERVER_PORT=3001
# fi
# poetry run coverage run -m pytest --junit-xml test_report.xml
# poetry run coverage report
# poetry run coverage xml
# - name: Upload test results
# uses: actions/upload-artifact@v2
# with:
# name: test-results
# path: test_report.xml
# mustache_example:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Install dependencies
# run: |
# python3 -m venv .venv
# source .venv/bin/activate
# pip install --upgrade pip
# pip install poetry==1.4.2
# poetry install -vv -E keyring
# - name: Run mustache example
# run: |
# cd examples/mustache
# pip install deepl
# python . --help
# python . --from en --to de "Hello {{user}}, your balance is {{{balance}}} dollars." > mustache_result.txt
# cat mustache_result.txt
# grep -q "{{user}}" mustache_result.txt
# grep -q "{{{balance}}}" mustache_result.txt
# basic_usage_example:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Install dependencies
# run: |
# python3 -m venv .venv
# source .venv/bin/activate
# pip install --upgrade pip
# pip install poetry==1.4.2
# poetry install -vv -E keyring
# - name: Run basic usage example
# run: |
# poetry build --verbose --no-interaction
# cd examples/basic_usage
# python3 -m venv .examplevenv
# source .examplevenv/bin/activate
# pip install ../../dist/deepl-*.tar.gz
# set -o pipefail
# python . 2>&1 | tee basic_usage_result.txt
# grep -q "Success" basic_usage_result.txt
# pip install mypy
# mypy .