Add github workflows for testing

This commit is contained in:
Rohan McGovern 2022-06-29 16:20:23 +10:00
parent 119f0ea9b6
commit 3a0285d433
6 changed files with 121 additions and 7 deletions

28
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,28 @@
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
run-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install -U pip
pip install tox
- name: Run tests
run: |
tox

29
.github/workflows/poetry-publish.yml vendored Normal file
View file

@ -0,0 +1,29 @@
name: Publish on PyPI
on:
push:
tags:
- v*
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install -U pip
pip install poetry
- name: Publish
run: |
poetry publish --build -vv --no-interaction
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}

View file

@ -0,0 +1,24 @@
on:
workflow_dispatch: {}
schedule:
# Tuesday
- cron: "20 20 * * 2"
name: "poetry: merge PR"
jobs:
poetry_update_merge:
name: poetry update automerge
runs-on: ubuntu-latest
steps:
- name: Look up pull request
uses: juliangruber/find-pull-request-action@v1
id: find-pull-request
with:
branch: deps/poetry-update
- name: Merge Pull Request
uses: juliangruber/merge-pull-request-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.find-pull-request.outputs.number }}
method: merge
if: ${{ steps.find-pull-request.outputs.number }}

38
.github/workflows/poetry-update.yml vendored Normal file
View file

@ -0,0 +1,38 @@
on:
workflow_dispatch: {}
schedule:
# Sunday
- cron: "20 20 * * 0"
name: "poetry: create PR"
jobs:
poetry_update:
name: poetry update
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: poetry update
uses: technote-space/create-pr-action@v2
with:
EXECUTE_COMMANDS: |
python -m pip install -U pip
pip install poetry
poetry update
COMMIT_MESSAGE: "chore: scheduled poetry update"
COMMIT_NAME: "GitHub Actions"
COMMIT_EMAIL: "noreply@github.com"
GITHUB_TOKEN: ${{ secrets.APPROVAL_TOKEN }}
PR_BRANCH_PREFIX: deps/
PR_BRANCH_NAME: poetry-update
PR_TITLE: "chore: scheduled poetry update"
PR_BODY: |-
## Update dependencies
This is a scheduled update of Python dependencies within this
repo managed by poetry.
This change will be approved automatically and merged within
a few days if all checks have succeeded.

View file

@ -107,7 +107,7 @@ class YumRepo(Repo):
# TODO: raise proper error
assert timestamp_node
time = datetime.datetime.utcfromtimestamp(
timestamp_node.toxml()
int(timestamp_node.toxml())
).isoformat()
out.append(

View file

@ -1,6 +1,6 @@
[tox]
isolated_build = True
envlist = py39,precommit,mypy
envlist = py39,mypy
envdir = {toxworkdir}/poetry
[testenv]
@ -10,11 +10,6 @@ commands =
poetry install -v
py.test -v {posargs}
[testenv:precommit]
commands =
poetry install -v
poetry run pre-commit run --all-files
[testenv:mypy]
commands =
poetry install -v