Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/ci/frontend/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build Frontend
description: Build the frontend and upload the build artifacts for use in other jobs.
name: Frontend
description: Runs frontend validation checks (type-checking, linting, formatting, testing) and uploads coverage reports.

runs:
using: composite
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/setup/check-frontend-exists/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check Frontend Exists
description: Check if the frontend directory exists in the repository.

runs:
using: composite
steps:
- name: Check if frontend directory exists
id: check-frontend
run: |
if [ -d "${{ github.event.repository.name }}-frontend" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Frontend directory does not exist, skipping frontend build"
fi
shell: bash
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,36 @@ on:
- main

jobs:
build-frontend:
runs-on: ubuntu-latest
outputs:
frontend-exists: ${{ steps.check-frontend.outputs.exists }}
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/setup/check-frontend-exists
if: github.event.repository.name == 'python-template-server'
# - uses: javidahmed64592/python-template-server/.github/actions/setup/check-frontend-exists@main
# if: github.event.repository.name != 'python-template-server'

- uses: ./.github/actions/build/build-frontend
if: steps.check-frontend.outputs.exists == 'true' && github.event.repository.name == 'python-template-server'
- uses: javidahmed64592/python-template-server/.github/actions/build/build-frontend@main
if: steps.check-frontend.outputs.exists == 'true' && github.event.repository.name != 'python-template-server'

build-wheel:
runs-on: ubuntu-latest
needs: build-frontend
steps:
- uses: actions/checkout@v6

- name: Download frontend build
if: needs.build-frontend.outputs.frontend-exists == 'true'
uses: actions/download-artifact@v8
with:
name: ${{ github.event.repository.name }}-frontend-build
path: static

- uses: ./.github/actions/build/build-wheel
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/build/build-wheel@main
Expand All @@ -23,6 +49,7 @@ jobs:
needs: build-wheel
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/build/verify-structure
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/ci/validate-pyproject
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/ci/validate-pyproject@main
Expand All @@ -22,6 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/ci/ruff
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/ci/ruff@main
Expand All @@ -31,6 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/ci/mypy
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/ci/mypy@main
Expand All @@ -40,6 +43,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/ci/pytest
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/ci/pytest@main
Expand All @@ -49,6 +53,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/ci/bandit
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/ci/bandit@main
Expand All @@ -58,6 +63,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/ci/pip-audit
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/ci/pip-audit@main
Expand All @@ -67,7 +73,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/ci/version-check
if: github.event.repository.name == 'template-python'
- uses: javidahmed64592/template-python/.github/actions/ci/version-check@main
if: github.event.repository.name != 'template-python'

frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/setup/check-frontend-exists
if: github.event.repository.name == 'python-template-server'
# - uses: javidahmed64592/python-template-server/.github/actions/setup/check-frontend-exists@main
# if: github.event.repository.name != 'python-template-server'

- uses: ./.github/actions/ci/frontend
if: steps.check-frontend.outputs.exists == 'true' && github.event.repository.name == 'python-template-server'
- uses: javidahmed64592/python-template-server/.github/actions/ci/frontend@main
if: steps.check-frontend.outputs.exists == 'true' && github.event.repository.name != 'python-template-server'
56 changes: 53 additions & 3 deletions docs/WORKFLOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ This document focuses on the Docker-specific workflow and reusable actions uniqu
- [Build Actions (`/build/**/action.yml`)](#build-actions-buildactionyml)
- [Docker Actions (`docker/**/action.yml`)](#docker-actions-dockeractionyml)
- [Workflows (`./github/workflows`)](#workflows-githubworkflows)
- [CI Workflow (`ci.yml`)](#ci-workflow-ciyml)
- [Build Workflow (`build.yml`)](#build-workflow-buildyml)
- [Docker Workflow (`docker.yml`)](#docker-workflow-dockeryml)

## Reusable Actions (`./github/actions`)
Expand All @@ -24,6 +26,26 @@ The following actions can be referenced from other repositories using `javidahme

### Setup Actions (`/setup/**/action.yml`)

**check-frontend-exists:**
- Description: Check if the frontend directory exists in the repository to conditionally execute frontend CI and build jobs.
- Location: `check-frontend-exists/action.yml`
- Outputs:
- `exists` - `"true"` if frontend directory exists, `"false"` otherwise
- Steps:
- Checks for directory named `<repository name>-frontend`
- Sets output to `true` or `false` based on directory existence
- Logs message if directory doesn't exist
- Note: Used by CI and Build workflows to skip frontend jobs when no frontend directory is present

Usage:
```yaml
steps:
- uses: javidahmed64592/python-template-server/.github/actions/setup/check-frontend-exists@main
id: check-frontend
```

---

**setup-node:**
- Description: Set up Node.js with npm cache and install dependencies.
- Location: `setup-node/action.yml`
Expand All @@ -41,7 +63,7 @@ steps:
### CI Actions (`/ci/**/action.yml`)

**frontend:**
- Description: Build the frontend and upload the build artifacts for use in other jobs.
- Description: Runs frontend validation checks (type-checking, linting, formatting, testing) and uploads coverage reports.
- Location: `frontend/action.yml`
- Steps:
- Uses the `setup-node` action
Expand All @@ -54,7 +76,7 @@ steps:
Usage:
```yaml
steps:
- uses: javidahmed64592/template-python/.github/actions/ci/frontend@main
- uses: javidahmed64592/python-template-server/.github/actions/ci/frontend@main
```

### Build Actions (`/build/**/action.yml`)
Expand All @@ -70,7 +92,7 @@ steps:
Usage:
```yaml
steps:
- uses: javidahmed64592/template-python/.github/actions/build/build-frontend@main
- uses: javidahmed64592/python-template-server/.github/actions/build/build-frontend@main
```

### Docker Actions (`docker/**/action.yml`)
Expand Down Expand Up @@ -232,6 +254,34 @@ steps:

## Workflows (`./github/workflows`)

### CI Workflow (`ci.yml`)

The CI workflow runs on pushes and pull requests to the `main` branch.
It inherits all Python validation jobs from `template-python` and adds frontend-specific validation.

**Additional Jobs:**
- `frontend` - Conditionally executes validation checks on frontend if frontend directory exists
- Uses `check-frontend-exists` to detect frontend directory
- Runs `frontend` action only when frontend is present

### Build Workflow (`build.yml`)

The Build workflow runs on pushes and pull requests to the `main` branch.
It extends the base `template-python` build process with optional frontend building.

**Additional Jobs:**
- `build-frontend` - Conditionally builds frontend and outputs existence flag
- Uses `check-frontend-exists` to detect frontend directory
- Builds frontend static files using `build-frontend` action if present
- Outputs `frontend-exists` flag for downstream jobs
- Uploads frontend build artifacts

**Modified Jobs:**
- `build-wheel` - Enhanced to include frontend builds
- Depends on `build-frontend` job
- Downloads frontend build artifacts to `static/` directory if `frontend-exists` is `true`
- Proceeds with standard wheel building from `template-python`

### Docker Workflow (`docker.yml`)

The Docker workflow runs on pushes and pull requests to the `main` branch, and supports manual dispatch.
Expand Down