From 927bdeee3baf4fe8312d5509141be87aa1e82571 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 11:06:51 +0000 Subject: [PATCH 1/3] refactor: Modify Prettier workflows - Change the formatting workflow to be manually triggered to prevent unexpected commits. - Update the CI workflow to use a more robust `npx` command for Prettier linting. --- .github/workflows/ci.yml | 7 ++----- .github/workflows/prettier.yml | 10 +++------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec70b9a..262ef9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,5 @@ jobs: with: node-version: "20" - - name: Install Prettier - run: npm install --global prettier - - - name: Run Prettier - run: prettier --check . + - name: Check Formatting with Prettier + run: npx prettier --check . diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 730d50f..dcc1cb6 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -1,14 +1,10 @@ # .github/workflows/prettier.yml -name: Format Code with Prettier +name: Manual Format with Prettier -# This workflow is triggered on pushes to the `main` branch and on pull -# requests. +# This workflow is manually triggered from the Actions tab. on: - push: - branches: - - main - pull_request: + workflow_dispatch: jobs: format: From 6edd427ba9b00feab47c9c4a1db972dba3a20b18 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 11:14:39 +0000 Subject: [PATCH 2/3] docs: Update documentation for Prettier workflow changes - Update docs/development.prettier.md to reflect the new manual format workflow and linting check. - Update docs/workflows.ci.md to reflect the simplified npx command. - Rewrite docs/workflows.prettier.md to describe the manual workflow. - Update docs/workflows.md to correctly link and describe the manual workflow. --- docs/development.prettier.md | 20 +++++++++++++------- docs/workflows.ci.md | 3 +-- docs/workflows.md | 2 +- docs/workflows.prettier.md | 13 +++++-------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/docs/development.prettier.md b/docs/development.prettier.md index bcbab77..3ed0d05 100644 --- a/docs/development.prettier.md +++ b/docs/development.prettier.md @@ -2,16 +2,23 @@ # Prettier for Code Formatting -[Prettier](https://prettier.io/) is an opinionated code formatter that enforces a consistent code style across the entire project. This repository is configured to use Prettier in two ways: automatically via a GitHub workflow and manually for local development. +[Prettier](https://prettier.io/) is an opinionated code formatter that enforces a consistent code style across the entire project. This repository uses Prettier in two ways: +- A **linting check** that runs automatically on pull requests to verify formatting. +- A **manual workflow** that can be run to format the entire repository. -## Automated Formatting with GitHub Actions +## Linting with GitHub Actions -This repository includes a [GitHub Actions workflow](./workflows.prettier.md) that automatically formats all code. +This repository includes a [CI workflow](./workflows.ci.md) that automatically checks for formatting issues on every pull request. -- **How it works**: The workflow runs on every push to the `main` branch and on every pull request. It runs `prettier --write .` to format all files and commits any changes with the message "style: Format code with Prettier". -- **What you need to do**: Nothing! The workflow handles everything automatically. If you push code that isn't formatted, the workflow will create a new commit with the required formatting changes. +- **How it works**: The workflow runs `prettier --check .`. If it finds any files that are not correctly formatted, the workflow will fail. This prevents code with incorrect formatting from being merged. +- **What you need to do**: Make sure to run Prettier on your code before pushing it. If the check fails, you will need to format your code and push the changes. -This ensures that all code merged into the `main` branch is consistently formatted. +## Manual Formatting Workflow + +For convenience, this repository also includes a [manual formatting workflow](./workflows.prettier.md) that you can trigger from the Actions tab in GitHub. + +- **How it works**: This workflow runs `prettier --write .` on all files and commits any changes back to your branch. +- **When to use it**: You can use this if you forget to format your code locally, or if you want to format a large number of files at once. ## Manual Formatting @@ -39,6 +46,5 @@ You can run Prettier from the command line to format your files. ```bash npx prettier . --check ``` - The [CI workflow](./workflows.ci.md) uses this command to validate formatting on pull requests. For more detailed information on using Prettier, refer to the [official Prettier documentation](https://prettier.io/docs/en/). diff --git a/docs/workflows.ci.md b/docs/workflows.ci.md index 8ea9dba..fbbe063 100644 --- a/docs/workflows.ci.md +++ b/docs/workflows.ci.md @@ -19,7 +19,6 @@ This job, named "Lint Code Base", runs on the latest version of Ubuntu. It perfo 1. **Checkout Code**: Checks out the repository's code. 2. **Setup Node.js**: Sets up Node.js version 20. -3. **Install Prettier**: Installs the Prettier code formatter globally. -4. **Run Prettier**: Runs `prettier --check .` to verify that all files in the repository are formatted correctly according to the Prettier configuration. +3. **Check Formatting with Prettier**: Runs `npx prettier --check .` to verify that all files in the repository are formatted correctly according to the Prettier configuration. The purpose of this workflow is to ensure that all code pushed to the `main` branch or included in a pull request to `main` adheres to the project's coding style, as defined by Prettier. This helps maintain code consistency and quality. diff --git a/docs/workflows.md b/docs/workflows.md index 8413d5f..d3e68f2 100644 --- a/docs/workflows.md +++ b/docs/workflows.md @@ -10,7 +10,7 @@ Below is an overview of the available workflows. For more detailed information a - [**CI Workflow**](./workflows.ci.md) (`ci.yml`) - Ensures code quality by running linting checks on every push and pull request to the `main` branch. - [**GitHub Pages Deployment**](./workflows.pages.md) (`pages.yml`) - Builds and deploys the repository's content as a GitHub Pages website. -- [**Prettier Workflow**](./workflows.prettier.md) (`prettier.yml`) - Automatically formats the code in the repository using Prettier and commits the changes. +- [**Manual Prettier Workflow**](./workflows.prettier.md) (`prettier.yml`) - Manually formats the code in the repository using Prettier and commits the changes. - [**Release on Tag**](./workflows.release-on-tag.md) (`release-on-tag.yml`) - Automates the creation of GitHub Releases when a new version tag is pushed. - [**Secrets Management**](./workflows.secrets-management.md) - Best practices for managing secrets in GitHub Actions. - [**Workflow Scheduling**](./workflows.scheduling.md) - Automating recurring tasks with cron. diff --git a/docs/workflows.prettier.md b/docs/workflows.prettier.md index dd58d7f..80427fd 100644 --- a/docs/workflows.prettier.md +++ b/docs/workflows.prettier.md @@ -1,15 +1,12 @@ -[base](../README.md) > [docs](./README.md) > [workflows](./workflows.md) > Prettier Workflow +[base](../README.md) > [docs](./README.md) > [workflows](./workflows.md) > Manual Prettier Workflow -# Prettier Workflow +# Manual Prettier Workflow -The Prettier workflow, defined in `.github/workflows/prettier.yml`, automates code formatting for the entire repository. +The Manual Prettier workflow, defined in `.github/workflows/prettier.yml`, provides a way to format the entire repository on demand. ## Triggers -This workflow is triggered on: - -- `push` to the `main` branch -- Any `pull_request` +This workflow is triggered manually using the `workflow_dispatch` event. You can run it from the "Actions" tab in the GitHub repository. ## Jobs @@ -23,4 +20,4 @@ This job runs on `ubuntu-latest` and performs the following steps: 4. **Run Prettier**: Executes `npx prettier --write .` to format all files in the repository in-place. 5. **Commit Changes**: Uses the `stefanzweifel/git-auto-commit-action` to check if Prettier made any changes. If there are changes, it commits them back to the current branch with the commit message "style: Format code with Prettier". This action is configured to check all files. -The purpose of this workflow is to ensure that all code in the repository is consistently formatted according to the Prettier rules, without requiring developers to run Prettier manually before committing. +The purpose of this workflow is to provide a convenient way for developers to format the entire repository without needing to run Prettier locally. It is especially useful for large-scale formatting changes or for ensuring consistency after pulling in changes from multiple sources. From ea5493dd1cef62a4cb75c0c994883be716472e0f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 18 Sep 2025 11:18:35 +0000 Subject: [PATCH 3/3] fix: Run prettier on documentation files The previous commit missed running prettier on the updated documentation, causing the linting check to fail. This commit applies the correct formatting. --- docs/development.prettier.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/development.prettier.md b/docs/development.prettier.md index 3ed0d05..f003646 100644 --- a/docs/development.prettier.md +++ b/docs/development.prettier.md @@ -3,6 +3,7 @@ # Prettier for Code Formatting [Prettier](https://prettier.io/) is an opinionated code formatter that enforces a consistent code style across the entire project. This repository uses Prettier in two ways: + - A **linting check** that runs automatically on pull requests to verify formatting. - A **manual workflow** that can be run to format the entire repository.