Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add github CI #113

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 196 additions & 0 deletions .github/workflows/run_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
name: Python

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '0 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"

jobs:
black:
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 black check
run: poetry run black --check .

flake8:
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 flake8 check
run: poetry run flake8 deepl tests

license_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- 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@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 mypy check
run: poetry run mypy --exclude 'examples/' .

package:
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: Build package
run: poetry build --verbose --no-interaction
- name: Upload artifacts
uses: actions/upload-artifact@v2
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 .
Loading