Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #49 from staticdev/actions
Browse files Browse the repository at this point in the history
Add actions
  • Loading branch information
Thiago C. D'Ávila committed May 28, 2020
2 parents d483161 + 8ea1ad7 commit 8494af4
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pip==20.1
pip==20.1.1
nox==2019.11.9
poetry==1.0.5
pre-commit==2.3.0
virtualenv==20.0.21
69 changes: 60 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,72 @@
name: Release

on:
release:
types: [published]
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.1.0
- uses: actions/setup-python@v1.2.0
- name: Check out the repository
uses: actions/checkout@v2.1.1
with:
fetch-depth: 2

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

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=.github/workflows/constraints.txt nox poetry
# - run: nox --force-color
- run: poetry build --ansi
- uses: pypa/gh-action-pypi-publish@v1.1.0
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Detect and tag new version
id: check-version
uses: salsify/action-detect-and-tag-new-version@v1.0.3
with:
version-command: |
poetry version | awk '{ print $2 }'
- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)
- name: Build package
run: |
poetry build --ansi
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/gh-action-pypi-publish@v1.1.0
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@v1.1.0
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/release-drafter@v5.8.0
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 changes: 96 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Tests

on:
- push
- pull_request

jobs:
tests:
name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { python-version: 3.8, os: ubuntu-latest, session: "pre-commit" }
- { python-version: 3.8, os: ubuntu-latest, session: "safety" }
- { python-version: 3.8, os: ubuntu-latest, session: "mypy-3.8" }
- { python-version: 3.7, os: ubuntu-latest, session: "mypy-3.7" }
- { python-version: 3.6, os: ubuntu-latest, session: "mypy-3.6" }
- { python-version: 3.8, os: ubuntu-latest, session: "tests-3.8" }
- { python-version: 3.7, os: ubuntu-latest, session: "tests-3.7" }
- { python-version: 3.6, os: ubuntu-latest, session: "tests-3.6" }
# - { python-version: 3.8, os: windows-latest, session: "tests-3.8" }
- { python-version: 3.8, os: macos-latest, session: "tests-3.8" }
# - { python-version: 3.8, os: ubuntu-latest, session: "docs" }

env:
NOXSESSION: ${{ matrix.session }}

steps:
- name: Check out the repository
uses: actions/checkout@v2.1.1

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

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox
nox --version
- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
shell: python
run: |
import hashlib
import sys
python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
print("::set-output name=result::{}".format(result))
- name: Restore pre-commit cache
uses: actions/cache@v1.2.0
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.pre-commit-cache.outputs.result }}-
- name: Run Nox
run: |
nox --force-color
# - name: Upload documentation
# if: matrix.session == 'docs'
# uses: actions/upload-artifact@v2
# with:
# name: docs
# path: docs/_build

- name: Create coverage report
if: always() && matrix.session == 'tests'
run: |
nox --force-color --session=coverage -- xml
- name: Upload coverage report
if: always() && matrix.session == 'tests'
uses: codecov/codecov-action@v1.0.7
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

0 comments on commit 8494af4

Please sign in to comment.