Skip to content

Commit

Permalink
Breaks up jobs into reusable actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jkwill87 committed Dec 22, 2022
1 parent 78503a8 commit f426ba5
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 95 deletions.
23 changes: 23 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint
description: Lints the codebase with black, isort, pyflakes, and mypy

runs:
using: composite
steps:
- uses: ./.github/actions/init

- name: Linting with black
run: black --check mnamer tests
shell: sh

- name: Linting isort
run: isort --check-only mnamer tests
shell: sh

- name: Linting pyflakes
run: pyflakes mnamer tests
shell: sh

- name: Linting mypy
run: mypy mnamer tests
shell: sh
46 changes: 46 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test
description: Tests the codebase with pytest

runs:
using: composite
steps:
- uses: ./.github/actions/init

- name: Running Local Unit Tests
run: >-
python -m pytest
-m local
--durations=10
--cov=./
--cov-append
--cov-report=term-missing
--cov-report=xml
shell: sh

- name: Running Network Unit Tests
run: >-
python -m pytest
-m network
--reruns 3
--durations=10
--cov=./
--cov-append
--cov-report=term-missing
--cov-report=xml
shell: sh

- name: Running End to End Tests
run: >-
python -m pytest
-m e2e
--reruns 3
--durations=10
--cov=./
--cov-append
--cov-report=term-missing
--cov-report=xml
shell: sh

- name: Reporting Coverage Statistics
uses: codecov/codecov-action@v1
if: success() && github.ref == 'refs/heads/main'
24 changes: 7 additions & 17 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,16 @@ name: pr
on: pull_request

jobs:

lint: # ------------------------------------------------------------------------------
lint:
runs-on: ubuntu-latest

steps:
- uses: ./.github/actions/init

- name: Linting with black
run: black --check mnamer tests

- name: Linting isort
run: isort --check-only mnamer tests
- uses: actions/checkout@v3
- uses: ./.github/actions/lint

- name: Linting mypy
run: mypy mnamer

test: # ------------------------------------------------------------------------------
test:
runs-on: ubuntu-latest
steps:
- uses: ./.github/actions/init

- run: >-
python -m pytest -m 'not tvdb'
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/test
88 changes: 12 additions & 76 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,108 +3,44 @@ name: push
on:
push:
schedule:
- cron: "0 8 * * 1" # Mondays at 8am
- cron: "0 8 * * 1" # mondays at 8am

jobs:
build: # -----------------------------------------------------------------------------
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with: { fetch-depth: 0 }
- uses: ./.github/actions/lint

- uses: ./.github/actions/init

- name: Attempting build
run: python3 -m build --sdist --wheel --no-isolation

- run: python3 -m mnamer --version

lint: # ------------------------------------------------------------------------------
test:
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/init

- name: Linting with black
run: black --check mnamer tests
- uses: ./.github/actions/test

- name: Linting isort
run: isort --check-only mnamer tests

- name: Linting pyflakes
run: pyflakes mnamer tests

- name: Linting mypy
run: mypy mnamer tests

test: # ------------------------------------------------------------------------------
publish:
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/init

- name: Running Local Unit Tests
run: >-
python -m pytest
-m local
--durations=10
--cov=./
--cov-append
--cov-report=term-missing
--cov-report=xml
- name: Running Network Unit Tests
run: >-
python -m pytest
-m network
--reruns 3
--durations=10
--cov=./
--cov-append
--cov-report=term-missing
--cov-report=xml
- name: Running End to End Tests
run: >-
python -m pytest
-m e2e
--reruns 3
--durations=10
--cov=./
--cov-append
--cov-report=term-missing
--cov-report=xml
- name: Reporting Coverage Statistics
uses: codecov/codecov-action@v1
if: >-
success()
&& github.event_name == 'push'
&& github.ref == 'refs/heads/main'
publish: # ---------------------------------------------------------------------------
runs-on: ubuntu-latest
if: >-
success()
&& github.event_name == 'push'
&& github.ref == 'refs/heads/main'
needs:
- build
- lint
- test

steps:
- uses: actions/checkout@v3
with: { fetch-depth: 0 }

- uses: ./.github/actions/init

- name: Building
run: python3 -m build --sdist --wheel --no-isolation

- name: Reporting Version
run: python3 -m mnamer --version

- name: Uploading to PyPI
run: >-
twine upload
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM python:alpine
ARG MNAMER_VERSION=2.4.2
ARG MNAMER_VERSION=2.5.2
ARG UID=1000
ARG GID=1000
RUN addgroup mnamer -g $GID
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/test_moving.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

pytestmark = [
pytest.mark.e2e,
pytest.mark.flaky(reruns=1),
pytest.mark.flaky(reruns=2),
]


Expand Down

0 comments on commit f426ba5

Please sign in to comment.