Skip to content

Commit

Permalink
Merge pull request python-poetry#5 from python-poetry/github-actions
Browse files Browse the repository at this point in the history
Setup GitHub actions
  • Loading branch information
sdispater authored Sep 8, 2021
2 parents 33d2628 + 4528872 commit 2cff745
Show file tree
Hide file tree
Showing 7 changed files with 407 additions and 214 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Code Quality

on:
pull_request:
paths-ignore:
- 'docs/**'
push:
branches: [main]
paths-ignore:
- 'docs/**'

jobs:
pre-commit:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release

on:
push:
tags:
- '*.*.*'

jobs:
Release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get tag
id: tag
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: Install Poetry
run: |
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py \
| python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Build project for distribution
run: poetry build

- name: Check Version
id: check-version
run: |
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \
|| echo ::set-output name=prerelease::true
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: steps.check-version.outputs.prerelease == 'true'

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish
78 changes: 78 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Tests

on:
pull_request: {}
push:
branches: [main]

jobs:
tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: "${{ matrix.os }}-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os: [Ubuntu, MacOS, Windows]
python-version: [3.6, 3.7, 3.8, 3.9]
experimental: [false]
bootstrap-args: [""]
include:
- os: Ubuntu
python-version: pypy3
experimental: false
- os: Ubuntu
python-version: "3.10.0-alpha - 3.10.0"
experimental: true
bootstrap-args: "--git https://github.com/python-poetry/poetry.git"
fail-fast: false
steps:
- uses: actions/checkout@v2

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

- name: Get full Python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Bootstrap poetry
shell: bash
run: |
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py \
| python - -y ${{ matrix.bootstrap-args }}
- name: Update PATH
if: ${{ matrix.os != 'Windows' }}
shell: bash
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Update Path for Windows
if: ${{ matrix.os == 'Windows' }}
shell: bash
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH

- name: Configure poetry
shell: bash
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install dependencies
shell: bash
run: poetry install

- name: Run pytest
shell: bash
run: poetry run python -m pytest -q tests/
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 21.8b0
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.2
hooks:
- id: flake8

- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
rev: 5.9.3
hooks:
- id: isort
additional_dependencies: [toml]
exclude: ^.*/?setup\.py$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.0.1
hooks:
- id: trailing-whitespace
exclude: |
Expand Down
Loading

0 comments on commit 2cff745

Please sign in to comment.