Skip to content

Commit

Permalink
Update GitHub workflow (#33)
Browse files Browse the repository at this point in the history
* create test.yml to run the test only, on PR or push to main
* create dev.yml to run the format, lint, and build docs, on PR or push to main
* delete the ci.yml and pr.yml
* update badge in readme and doca index
* remove environtment, so that it run without waiting approval
  • Loading branch information
kiraware authored Jul 14, 2024
1 parent f3dc004 commit b668c31
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 53 deletions.
39 changes: 9 additions & 30 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/[email protected]
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,17 +45,5 @@ jobs:
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
34 changes: 13 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,30 +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]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# paspybin

[![CI](https://github.com/kiraware/paspybin/workflows/ci/badge.svg)](https://github.com/kiraware/paspybin/actions/workflows/ci.yml)
[![Test](https://github.com/kiraware/paspybin/workflows/test/badge.svg)](https://github.com/kiraware/paspybin/actions/workflows/test.yml)
[![CodeQL](https://github.com/kiraware/paspybin/workflows/CodeQL/badge.svg)](https://github.com/kiraware/paspybin/actions/workflows/codeql.yml)
[![Docs](https://readthedocs.org/projects/paspybin/badge/?version=latest)](https://paspybin.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/kiraware/paspybin/graph/badge.svg?token=PH6EUFT4V0)](https://codecov.io/gh/kiraware/paspybin)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# paspybin

[![CI](https://github.com/kiraware/paspybin/workflows/ci/badge.svg)](https://github.com/kiraware/paspybin/actions/workflows/ci.yml)
[![Test](https://github.com/kiraware/paspybin/workflows/test/badge.svg)](https://github.com/kiraware/paspybin/actions/workflows/test.yml)
[![CodeQL](https://github.com/kiraware/paspybin/workflows/CodeQL/badge.svg)](https://github.com/kiraware/paspybin/actions/workflows/codeql.yml)
[![Docs](https://readthedocs.org/projects/paspybin/badge/?version=latest)](https://paspybin.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/kiraware/paspybin/graph/badge.svg?token=PH6EUFT4V0)](https://codecov.io/gh/kiraware/paspybin)
Expand Down

0 comments on commit b668c31

Please sign in to comment.