Skip to content

Commit 109bae0

Browse files
Merge pull request #115 from DeepLcom/add-gh-ci
ci: Add github CI
2 parents 3dc0fe6 + 7e872de commit 109bae0

File tree

1 file changed

+227
-0
lines changed

1 file changed

+227
-0
lines changed

.github/workflows/run_ci.yml

+227
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: Python
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '10 0 * * *'
10+
11+
env:
12+
PIP_CACHE_DIR: "${{ github.workspace }}/.cache/pip"
13+
XDG_CACHE_HOME: "${{ github.workspace }}/.cache"
14+
POETRY_VIRTUALENVS_IN_PROJECT: "true"
15+
REQUESTS_CA_BUNDLE: "/etc/ssl/certs/ca-certificates.crt"
16+
SECRET_DETECTION_JSON_REPORT_FILE: "gitleaks.json"
17+
18+
jobs:
19+
black:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Install dependencies
25+
run: |
26+
python3 -m venv .venv
27+
source .venv/bin/activate
28+
pip install --upgrade pip
29+
pip install poetry==1.4.2
30+
poetry install -vv -E keyring
31+
- name: Run black check
32+
run: |
33+
source .venv/bin/activate
34+
poetry run black --check .
35+
36+
flake8:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
- name: Install dependencies
42+
run: |
43+
python3 -m venv .venv
44+
source .venv/bin/activate
45+
pip install --upgrade pip
46+
pip install poetry==1.4.2
47+
poetry install -vv -E keyring
48+
- name: Run flake8 check
49+
run: |
50+
source .venv/bin/activate
51+
poetry run flake8 deepl tests
52+
53+
license_check:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
- name: Run license check
59+
run: |
60+
./license_checker.sh '*.py' | tee license_check_output.txt
61+
[ ! -s license_check_output.txt ]
62+
63+
mypy:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v4
68+
- name: Install dependencies
69+
run: |
70+
python3 -m venv .venv
71+
source .venv/bin/activate
72+
pip install --upgrade pip
73+
pip install poetry==1.4.2
74+
poetry install -vv -E keyring
75+
- name: Run mypy check
76+
run: |
77+
source .venv/bin/activate
78+
poetry run mypy --exclude 'examples/' .
79+
80+
secret_detection:
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v4
85+
with:
86+
fetch-depth: 0
87+
- name: Install and run secret detection
88+
run: |
89+
wget https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz
90+
tar -xzf gitleaks_8.18.4_linux_x64.tar.gz
91+
EXITCODE=0
92+
./gitleaks detect -r ${SECRET_DETECTION_JSON_REPORT_FILE} --source . --log-opts="--all --full-history" || EXITCODE=$?
93+
if [[ $EXITCODE -ne 0 ]]; then
94+
exit $EXITCODE
95+
fi
96+
- name: Upload secret detection artifact
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: secret-detection-results
100+
path: gitleaks.json
101+
102+
package:
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@v4
107+
- name: Install dependencies
108+
run: |
109+
python3 -m venv .venv
110+
source .venv/bin/activate
111+
pip install --upgrade pip
112+
pip install poetry==1.4.2
113+
poetry install -vv -E keyring
114+
- name: Build package
115+
run: |
116+
source .venv/bin/activate
117+
poetry build --verbose --no-interaction
118+
- name: Upload artifacts
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: build-artifacts
122+
path: dist/
123+
124+
# Test and `pypi upload` stage are disabled/missing for now. Code needs to be tested
125+
126+
#######################################################
127+
# test:
128+
# runs-on: ${{ matrix.config.docker-image }}
129+
# strategy:
130+
# matrix:
131+
# config:
132+
# - docker-image: python:3.6
133+
# use-mock-server: use mock server
134+
# use-old-poetry-version: use old poetry version
135+
# - docker-image: python:3.7
136+
# use-mock-server: use mock server
137+
# - docker-image: python:3.8
138+
# use-mock-server: use mock server
139+
# - docker-image: python:3.9
140+
# use-mock-server: use mock server
141+
# - docker-image: python:3.10
142+
# use-mock-server: use mock server
143+
# - docker-image: python:3.11
144+
# use-mock-server: use mock server
145+
# - docker-image: python:3.11
146+
# - docker-image: python:3.6
147+
# use-mock-server: use mock server
148+
# use-old-poetry-version: use old poetry version
149+
# extra-poetry-add-argument: [email protected]
150+
# - docker-image: python:3.9
151+
# use-mock-server: use mock server
152+
# extra-poetry-add-argument: [email protected]
153+
# # Set minimum possible requests and urllib3 versions to work with Python 3.11
154+
# - docker-image: python:3.11
155+
# use-mock-server: use mock server
156+
# extra-poetry-add-argument: [email protected] [email protected]
157+
# steps:
158+
# - name: Checkout
159+
# uses: actions/checkout@v2
160+
# - name: Run tests
161+
# run: |
162+
# if [[ ! -z "${{ matrix.config.extra-poetry-add-argument }}" ]]; then
163+
# echo "Running poetry add ${{ matrix.config.extra-poetry-add-argument }}"
164+
# poetry add ${{ matrix.config.extra-poetry-add-argument }}
165+
# fi
166+
# if [[ ! -z "${{ matrix.config.use-mock-server }}" ]]; then
167+
# echo "Using mock server"
168+
# export DEEPL_SERVER_URL=http://deepl-mock:3000
169+
# export DEEPL_MOCK_SERVER_PORT=3000
170+
# export DEEPL_PROXY_URL=http://deepl-mock:3001
171+
# export DEEPL_MOCK_PROXY_SERVER_PORT=3001
172+
# fi
173+
# poetry run coverage run -m pytest --junit-xml test_report.xml
174+
# poetry run coverage report
175+
# poetry run coverage xml
176+
# - name: Upload test results
177+
# uses: actions/upload-artifact@v2
178+
# with:
179+
# name: test-results
180+
# path: test_report.xml
181+
182+
# mustache_example:
183+
# runs-on: ubuntu-latest
184+
# steps:
185+
# - name: Checkout
186+
# uses: actions/checkout@v2
187+
# - name: Install dependencies
188+
# run: |
189+
# python3 -m venv .venv
190+
# source .venv/bin/activate
191+
# pip install --upgrade pip
192+
# pip install poetry==1.4.2
193+
# poetry install -vv -E keyring
194+
# - name: Run mustache example
195+
# run: |
196+
# cd examples/mustache
197+
# pip install deepl
198+
# python . --help
199+
# python . --from en --to de "Hello {{user}}, your balance is {{{balance}}} dollars." > mustache_result.txt
200+
# cat mustache_result.txt
201+
# grep -q "{{user}}" mustache_result.txt
202+
# grep -q "{{{balance}}}" mustache_result.txt
203+
204+
# basic_usage_example:
205+
# runs-on: ubuntu-latest
206+
# steps:
207+
# - name: Checkout
208+
# uses: actions/checkout@v2
209+
# - name: Install dependencies
210+
# run: |
211+
# python3 -m venv .venv
212+
# source .venv/bin/activate
213+
# pip install --upgrade pip
214+
# pip install poetry==1.4.2
215+
# poetry install -vv -E keyring
216+
# - name: Run basic usage example
217+
# run: |
218+
# poetry build --verbose --no-interaction
219+
# cd examples/basic_usage
220+
# python3 -m venv .examplevenv
221+
# source .examplevenv/bin/activate
222+
# pip install ../../dist/deepl-*.tar.gz
223+
# set -o pipefail
224+
# python . 2>&1 | tee basic_usage_result.txt
225+
# grep -q "Success" basic_usage_result.txt
226+
# pip install mypy
227+
# mypy .

0 commit comments

Comments
 (0)