Skip to content

Commit

Permalink
ci: replace travis with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bretello committed Oct 29, 2023
1 parent bccec94 commit 5f525e7
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 89 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: lint

on:
push:
branches:
- "master"
- "release-*"
pull_request:
branches:
- "master"
- "release-*"
workflow_dispatch:

jobs:
tests:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
pyv: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.pyv }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.pyv }}

- name: set PY_CACHE_KEY
run: echo "PY_CACHE_KEY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
- name: Cache .tox
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.tox/checkqa
key: "tox-lint|${{ matrix.os }}|${{ env.PY_CACHE_KEY }}|${{ hashFiles('tox.ini', 'setup.*') }}"

- name: Update pip/setuptools
run: |
pip install -U pip setuptools
- name: Install tox
run: python -m pip install tox

- name: Version information
run: python -m pip list

- name: Lint
run: tox -v -e checkqa
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish package to PyPI

on:
release:
types:
- published
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install requirements
run: |
pip install -U pip twine build
- name: Build
run: python -m build
- run: check-manifest
- run: twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
85 changes: 85 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Tests

on:
push:
branches:
- "master"
- "release-*"
pull_request:
branches:
- "master"
- "release-*"
workflow_dispatch:

env:
PYTEST_ADDOPTS: "-vv --cov-report=xml:coverage-ci.xml"
PIP_DISABLE_PIP_VERSION_CHECK: true

defaults:
run:
shell: bash

jobs:
tests:
name: Tests
runs-on: ${{ matrix.os }}
timeout-minutes: 5

strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python: ["3.8"]
tox_env: ["coverage"]
include:
- tox_env: "py39-coverage"
os: ubuntu-20.04
python: "3.9"
- tox_env: "py310-coverage"
python: "3.10"
os: ubuntu-20.04
- tox_env: "py311-coverage"
python: "3.11"
os: ubuntu-20.04

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: set PY_CACHE_KEY
run: echo "PY_CACHE_KEY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
- name: Cache .tox
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.tox/${{ matrix.tox_env }}
key: "tox|${{ matrix.os }}|${{ matrix.tox_env }}|${{ env.PY_CACHE_KEY }}|${{ hashFiles('tox.ini', 'setup.*') }}"

- name: Update tools and print info
run: |
pip install -U pip setuptools virtualenv
pip list
- name: Install tox
run: pip install tox

- name: Setup tox environment
id: setup_tox
run: tox --notest -v -e ${{ matrix.tox_env }}

- name: Run tests
run: |
python -m tox -v -e ${{ matrix.tox_env }}
- name: Report coverage
if: always() && (contains(matrix.tox_env, 'coverage') && (steps.setup_tox.outcome == 'success'))
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./coverage-ci.xml
flags: ${{ runner.os }}
name: ${{ matrix.tox_env }}
fail_ci_if_error: true
89 changes: 0 additions & 89 deletions .travis.yml

This file was deleted.

0 comments on commit 5f525e7

Please sign in to comment.