From 3a0285d43385497982ea28d8e130348c79ab9d9e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 29 Jun 2022 16:20:23 +1000 Subject: [PATCH] Add github workflows for testing --- .github/workflows/ci.yml | 28 +++++++++++++++++ .github/workflows/poetry-publish.yml | 29 +++++++++++++++++ .github/workflows/poetry-update-merge.yml | 24 ++++++++++++++ .github/workflows/poetry-update.yml | 38 +++++++++++++++++++++++ repo_autoindex/yum.py | 2 +- tox.ini | 7 +---- 6 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/poetry-publish.yml create mode 100644 .github/workflows/poetry-update-merge.yml create mode 100644 .github/workflows/poetry-update.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a8a4734 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/poetry-publish.yml b/.github/workflows/poetry-publish.yml new file mode 100644 index 0000000..910b52c --- /dev/null +++ b/.github/workflows/poetry-publish.yml @@ -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 }} diff --git a/.github/workflows/poetry-update-merge.yml b/.github/workflows/poetry-update-merge.yml new file mode 100644 index 0000000..b822d0a --- /dev/null +++ b/.github/workflows/poetry-update-merge.yml @@ -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 }} diff --git a/.github/workflows/poetry-update.yml b/.github/workflows/poetry-update.yml new file mode 100644 index 0000000..27c9d2c --- /dev/null +++ b/.github/workflows/poetry-update.yml @@ -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. diff --git a/repo_autoindex/yum.py b/repo_autoindex/yum.py index 3f23d2f..3d3366f 100644 --- a/repo_autoindex/yum.py +++ b/repo_autoindex/yum.py @@ -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( diff --git a/tox.ini b/tox.ini index be0ab06..8ef214e 100644 --- a/tox.ini +++ b/tox.ini @@ -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