Skip to content

Commit

Permalink
ci(Github): Refactor Github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilian-kruse committed Jan 19, 2025
1 parent 2b481c0 commit eb3b8ff
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 107 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ on:

# -- Jobs ------------------------------------------------------------------------------------------
jobs:
# Check code with Ruff
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v4
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Format code with Ruff
id: format-ruff
run: |
uv sync --only-group style
uv run ruff format --check
#Build documentation without deploying
docs:
runs-on: ubuntu-latest
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Docs
run-name: Re-create docs on Gihub pages from tagged commit

# -- Trigger Events --------------------------------------------------------------------------------
on:
workflow_dispatch:
push:
tags:
- v*

# -- Concurrency -----------------------------------------------------------------------------------
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}s

# -- Jobs ------------------------------------------------------------------------------------------
jobs:
#Build documentation and upload as artifact
build-docs:
runs-on: ubuntu-latest
environment: main
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v4
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Install dependencies
id: install-deps
run: uv sync --only-group docs
- name: Build MkDocs documentation
id: build-docs
run: uv run mkdocs build
- name: Upload static files as artifact
id: upload_artifact
uses: actions/upload-pages-artifact@v3
with:
path: site/

# Deploy documentation artifact to Github Pages
deploy-docs:
runs-on: ubuntu-latest
if :
${{
github.event_name == 'workflow_dispatch'||
github.event_name == 'push' ||
github.event.pull_request.merged == true
}}
needs: build-docs
permissions:
pages: write
id-token: write
environment:
name: main
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
89 changes: 10 additions & 79 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,15 @@ concurrency:

# -- Jobs ------------------------------------------------------------------------------------------
jobs:
# Check code with Ruff
format:
#Build documentation without deploying
docs:
runs-on: ubuntu-latest
if :
${{
github.event_name == 'workflow_dispatch'||
github.event_name == 'push' ||
github.event.pull_request.merged == true
}}
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v4
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Format code with Ruff
id: format-ruff
run: |
uv sync --only-group style
uv run ruff format --check
#Build documentation and upload as artifact
build-docs:
runs-on: ubuntu-latest
if :
${{
github.event_name == 'workflow_dispatch'||
github.event_name == 'push' ||
github.event.pull_request.merged == true
}}
environment: main
steps:
- name: Checkout code
id: checkout-code
Expand All @@ -68,34 +43,8 @@ jobs:
- name: Build MkDocs documentation
id: build-docs
run: uv run mkdocs build
- name: Upload static files as artifact
id: upload_artifact
uses: actions/upload-pages-artifact@v3
with:
path: site/

# Deploy documentation artifact to Github Pages
deploy-docs:
runs-on: ubuntu-latest
if :
${{
github.event_name == 'workflow_dispatch'||
github.event_name == 'push' ||
github.event.pull_request.merged == true
}}
needs: build-docs
permissions:
pages: write
id-token: write
environment:
name: main
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

# Run tests with Pytest
# Run tests with Pytest, upload coverage report if main is changed
test:
runs-on: ubuntu-latest
if :
Expand All @@ -119,29 +68,11 @@ jobs:
run: uv sync --group test
- name: Run tests with Pytest
id: run-tests
run: uv run pytest --cov-branch --cov-report=xml
- name: Store coverage report
id: store-coverage
uses: actions/upload-artifact@v4
run: uv run pytest --cov-branch --cov-report=xml:coverage.xml
- name: Upload coverage report
id: upload-coverage
if: ${{ github.event_name == 'push' }}
uses: codecov/codecov-action@v5
with:
name: coverage-report
path: coverage.xml

# Upload coverage report
coverage:
runs-on: ubuntu-latest
if :
${{
github.event_name == 'workflow_dispatch'||
github.event_name == 'push' ||
github.event.pull_request.merged == true
}}
environment: main
needs: test
steps:
- name: Upload coverage report
id: upload-coverage
if: ${{ github.event_name == 'push' }}
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -- Github Workflow for Publishing toIndices ------------------------------------------------------
# Workflow is manual
name: Publish
run-name: Publish Python package to indices
name: Publish-PyPI
run-name: Publish Python package to PyPI

# -- Trigger Events --------------------------------------------------------------------------------
on:
Expand All @@ -13,7 +11,7 @@ concurrency:

# -- Jobs ------------------------------------------------------------------------------------------
jobs:
# Publish to Test-PyPI
# Publish to PyPI
publish-pypi:
runs-on: ubuntu-latest
environment: publish
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -- Github Workflow for Publishing to Text Indices ------------------------------------------------
# Workflow is manual
name: Publish-Test
run-name: Publish Python package to test indices
name: Publish-Test-PyPI
run-name: Publish Python package to Test-PyPI

# -- Trigger Events --------------------------------------------------------------------------------
on:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ concurrency:

# -- Jobs ------------------------------------------------------------------------------------------
jobs:
# Create Github release with changelog
release:
runs-on: ubuntu-latest
environment: release
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ci",
"coverage",
"readme",
"index"
"index",
"Github"
]
}

0 comments on commit eb3b8ff

Please sign in to comment.