Skip to content

Commit

Permalink
update github workflow (#37)
Browse files Browse the repository at this point in the history
* create test.yml for run test only
* create dev.yml for run format, lint, and build docs
* remove ci.yml and pr.yml
* update release.yml
* remove development environtment
  • Loading branch information
kiraware authored Jul 16, 2024
1 parent 6d232fa commit 578cea2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 52 deletions.
35 changes: 9 additions & 26 deletions .github/workflows/pr.yml → .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
name: pr
name: Dev

on:
push:
branches:
- main
pull_request:
branches:
- "**"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
- main

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
dev:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
environment: development
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: "3.12"
- name: Install Poetry
uses: snok/install-poetry@v1.3.4
with:
Expand All @@ -41,9 +34,7 @@ jobs:
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with docs
- name: Install library
run: poetry install --no-interaction
run: poetry install --no-interaction --no-root --without test --with docs
- name: Activate virtual environment
run: source $VENV
- name: Lint with Ruff
Expand All @@ -54,13 +45,5 @@ jobs:
run: poetry run mypy
- name: Format with Ruff
run: poetry run ruff format --check
- name: Test with pytest
run: poetry run pytest --cov=src --cov-report=xml
- name: Build docs with Material for MkDocs
run: poetry run mkdocs build
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ on:

jobs:
publish:
strategy:
fail-fast: false
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
id-token: write
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout source code
uses: actions/checkout@v4
Expand All @@ -35,3 +33,5 @@ jobs:
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build
strategy:
fail-fast: false
38 changes: 17 additions & 21 deletions .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
name: ci
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
test:
if: github.event_name == 'pull_request'
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
Expand All @@ -40,26 +39,23 @@ jobs:
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with docs
- name: Install library
run: poetry install --no-interaction
run: poetry install --no-interaction --no-root --without dev,docs
- name: Activate virtual environment
run: source $VENV
- name: Lint with Ruff
run: poetry run ruff check
- name: Check code security with Bandit
run: poetry run bandit -c pyproject.toml -r .
- name: Typing with mypy
run: poetry run mypy
- name: Format with Ruff
run: poetry run ruff format --check
- name: Test with pytest
env:
PASTEBIN_API_DEV_KEY: ${{ secrets.PASTEBIN_API_DEV_KEY }}
PASTEBIN_USERNAME: ${{ secrets.PASTEBIN_USERNAME }}
PASTEBIN_PASSWORD: ${{ secrets.PASTEBIN_PASSWORD }}
run: poetry run pytest --cov=src --cov-report=xml
- name: Build docs with Material for MkDocs
run: poetry run mkdocs build
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]

0 comments on commit 578cea2

Please sign in to comment.