Skip to content

Commit

Permalink
Merge test & publish workflows
Browse files Browse the repository at this point in the history
Update both to allow pypi publish from publish job
  • Loading branch information
alorence committed Mar 3, 2022
1 parent 35bc0cb commit 36740f0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 29 deletions.
51 changes: 48 additions & 3 deletions .github/workflows/unit-tests.yml → .github/workflows/default.yml
@@ -1,4 +1,4 @@
name: Tests
name: Tests & Publish

on:
push:
Expand All @@ -10,6 +10,18 @@ on:
# * is a special character in YAML so you have to quote this string
- cron: '55 2 */7 * *'

# Manually triggered workflow
workflow_dispatch:
inputs:
target_repo:
description: 'The repository to publish the package'
required: true
default: 'pypi.org'
type: choice
options:
- pypi.org
- test.pypi.org

env:
INSTALL_POETRY_VERSION: 1.*
POETRY_INSTALLER_PARALLEL: true
Expand Down Expand Up @@ -60,7 +72,7 @@ jobs:
poetry install --no-interaction
poetry run pip install -U "django==${{ matrix.django-version }}.*"
- name: Run unit & functional tests
- name: Pytest
run: |
echo "Django version: $(poetry run django-admin --version)"
poetry run pytest --cov=modernrpc --cov-report=term --cov-report=xml:coverage.xml .
Expand All @@ -80,6 +92,7 @@ jobs:

black:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v2
- name: Install Poetry
Expand All @@ -94,6 +107,7 @@ jobs:

flake8:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v2
- name: Install Poetry
Expand All @@ -108,6 +122,7 @@ jobs:

pylint:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v2
- name: Install Poetry
Expand All @@ -122,6 +137,7 @@ jobs:

mypy:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v2
- name: Install Poetry
Expand All @@ -131,5 +147,34 @@ jobs:
- name: Install dependencies
run: |
poetry install --no-interaction
- name: Pylint
- name: Mypy
run: poetry run mypy -p modernrpc

publish:
runs-on: ubuntu-latest
needs: [tests, flake8, mypy, black, pylint]
# Only ran on tag push and manual trigger
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event.inputs.target_repo != ''
env:
# inputs.target_repo is set only when workflow was manually triggered. Default to 'pypi.org' for tags push
pypi_repository: ${{ github.event.inputs.target_repo || 'pypi.org' }}

steps:
- uses: actions/checkout@v2
- name: Install Poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: ${{ env.INSTALL_POETRY_VERSION }}

- name: Publish on Pypi
if: env.pypi_repository == 'pypi.org'
run: |
echo "Publish on ${{ env.pypi_repository }}"
poetry publish --build -u __token__ -p ${{ secrets.PYPI_AUTH_TOKEN }} --dry-run
- name: Publish on TestPypi
if: env.pypi_repository == 'test.pypi.org'
run: |
echo "Publish on ${{ env.pypi_repository }}"
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish --build -u __token__ -p ${{ secrets.PYPI_AUTH_TOKEN_TEST }} -r testpypi --dry-run
26 changes: 0 additions & 26 deletions .github/workflows/publish.yml

This file was deleted.

0 comments on commit 36740f0

Please sign in to comment.