From b7ac68e1cfc2725c9a28c97de35b4a4b26702954 Mon Sep 17 00:00:00 2001 From: Javid Ahmed Date: Sat, 7 Mar 2026 19:10:38 +0000 Subject: [PATCH] Add CI and Build actions for frontend with documentation updates --- .../actions/build/build-frontend/action.yml | 21 ++++++++++ .github/actions/ci/frontend/action.yml | 40 +++++++++++++++++++ .gitignore | 2 +- docs/WORKFLOWS.md | 37 +++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 .github/actions/build/build-frontend/action.yml create mode 100644 .github/actions/ci/frontend/action.yml diff --git a/.github/actions/build/build-frontend/action.yml b/.github/actions/build/build-frontend/action.yml new file mode 100644 index 0000000..8747f08 --- /dev/null +++ b/.github/actions/build/build-frontend/action.yml @@ -0,0 +1,21 @@ +name: Build Frontend +description: Build the frontend and upload the build artifacts for use in other jobs. + +runs: + using: composite + steps: + - uses: ./.github/actions/setup/setup-node + if: github.event.repository.name == 'python-template-server' + - uses: javidahmed64592/python-template-server/.github/actions/setup/setup-node@main + if: github.event.repository.name != 'python-template-server' + + - name: Build frontend + run: | + npm run build + working-directory: ${{ github.event.repository.name }}-frontend + shell: bash + - name: Upload frontend build + uses: actions/upload-artifact@v7 + with: + name: ${{ github.event.repository.name }}-frontend-build + path: ${{ github.event.repository.name }}-frontend/out diff --git a/.github/actions/ci/frontend/action.yml b/.github/actions/ci/frontend/action.yml new file mode 100644 index 0000000..17592e3 --- /dev/null +++ b/.github/actions/ci/frontend/action.yml @@ -0,0 +1,40 @@ +name: Build Frontend +description: Build the frontend and upload the build artifacts for use in other jobs. + +runs: + using: composite + steps: + - uses: ./.github/actions/setup/setup-node + if: github.event.repository.name == 'python-template-server' + - uses: javidahmed64592/python-template-server/.github/actions/setup/setup-node@main + if: github.event.repository.name != 'python-template-server' + + - name: Run type checking + run: | + npm run type-check + working-directory: ${{ github.event.repository.name }}-frontend + shell: bash + + - name: Run linting + run: | + npm run lint + working-directory: ${{ github.event.repository.name }}-frontend + shell: bash + + - name: Run formatting check + run: | + npm run format + working-directory: ${{ github.event.repository.name }}-frontend + shell: bash + + - name: Run tests + run: | + npm run test:coverage + working-directory: ${{ github.event.repository.name }}-frontend + shell: bash + + - name: Upload frontend coverage report + uses: actions/upload-artifact@v7 + with: + name: frontend-coverage-report + path: ${{ github.event.repository.name }}-frontend/coverage diff --git a/.gitignore b/.gitignore index d920188..6d1ac71 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ __pycache__/ # Distribution / packaging .Python -build/ +./build/ develop-eggs/ dist/ downloads/ diff --git a/docs/WORKFLOWS.md b/docs/WORKFLOWS.md index 27bc754..a563d6e 100644 --- a/docs/WORKFLOWS.md +++ b/docs/WORKFLOWS.md @@ -12,6 +12,8 @@ This document focuses on the Docker-specific workflow and reusable actions uniqu ## Table of Contents - [Reusable Actions (`./github/actions`)](#reusable-actions-githubactions) - [Setup Actions (`/setup/**/action.yml`)](#setup-actions-setupactionyml) + - [CI Actions (`/ci/**/action.yml`)](#ci-actions-ciactionyml) + - [Build Actions (`/build/**/action.yml`)](#build-actions-buildactionyml) - [Docker Actions (`docker/**/action.yml`)](#docker-actions-dockeractionyml) - [Workflows (`./github/workflows`)](#workflows-githubworkflows) - [Docker Workflow (`docker.yml`)](#docker-workflow-dockeryml) @@ -36,6 +38,41 @@ steps: - uses: javidahmed64592/python-template-server/.github/actions/setup/setup-node@main ``` +### CI Actions (`/ci/**/action.yml`) + +**frontend:** +- Description: Build the frontend and upload the build artifacts for use in other jobs. +- Location: `frontend/action.yml` +- Steps: + - Uses the `setup-node` action + - Runs `npm run type-check` for type checking + - Runs `npm run lint` for static code analysis + - Runs `npm run format` to tidy up scripts + - Runs `npm run test:coverage` for frontend unit tests + - Uploads unit test coverage report using `actions/upload-artifact@v7` + +Usage: +```yaml +steps: + - uses: javidahmed64592/template-python/.github/actions/ci/frontend@main +``` + +### Build Actions (`/build/**/action.yml`) + +**build-frontend:** +- Description: Build the frontend and upload the build artifacts for use in other jobs. +- Location: `build-frontend/action.yml` +- Steps: + - Uses the `setup-node` action + - Runs `npm run build` to build frontend static files + - Uploads static files as build artifact using `actions/upload-artifact@v7` + +Usage: +```yaml +steps: + - uses: javidahmed64592/template-python/.github/actions/build/build-frontend@main +``` + ### Docker Actions (`docker/**/action.yml`) The following actions encapsulate the steps in the Docker workflow and can be referenced locally with `uses: ./.github/actions/docker/`.