Skip to content

Conversation

@dikjain
Copy link

@dikjain dikjain commented Oct 11, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Added a ReScript formatter check to the CI/CD pipeline to ensure consistent code formatting across the codebase.

Changes made:

  • Created .github/workflows/formatter-check.yml workflow file
  • Workflow runs on every pull request and push to main branch
  • Executes npm run re:format to format files
  • Uses git diff to verify no formatting changes are needed
  • Provides clear error messages indicating which files need formatting

Motivation and Context

This change addresses issue #3559.

Problem:
Currently, the project does not have an automated check in the CI/CD pipeline to ensure that code is formatted with the ReScript formatter. This leads to:

  • Inconsistent code style across the codebase
  • Increased code review effort on formatting issues
  • Manual formatting checks by reviewers

Solution:
By integrating a formatter check into the pipeline, we can automatically verify formatting during pull requests and enforce consistency across the project.

How it works:

  1. Runs npm run re:format in the CI environment
  2. Checks if any files were modified by the formatter using git status --porcelain
  3. If files were modified → formatting was incorrect → CI fails ❌
  4. If no files were modified → formatting was correct → CI passes ✅

Closes #3559

How did you test it?

Testing performed:

  • Verified the workflow file syntax is valid
  • Tested formatter command locally: npm run re:format
  • Tested formatter check command locally: npx rescript format -all -check
  • Workflow will be automatically tested when this PR is created (CI will run)

Expected CI behavior:

  • ✅ CI should pass if all files are properly formatted
  • ❌ CI should fail if any files need formatting (with clear error messages)

Where to test it?

  • GitHub Actions (automatically runs on PR)
  • INTEG
  • SANDBOX
  • PROD

Checklist

  • I ran npm run re:build
  • I reviewed submitted code
  • I added unit tests for my changes where possible (N/A - this is a CI/CD workflow)

Additional Notes

For Developers:
To check formatting locally before pushing:

# Check if files are formatted (doesn't modify)
npx rescript format -all -check

# Format files (modifies files)
npm run re:format

The CI check will ensure all ReScript files (.res and .resi) are properly formatted according to ReScript's standard formatting rules.

@dikjain dikjain requested a review from a team as a code owner October 11, 2025 20:51
@semanticdiff-com
Copy link

semanticdiff-com bot commented Oct 11, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  .github/workflows/formatter-check.yml  0% smaller

@dikjain
Copy link
Author

dikjain commented Oct 26, 2025

hey @JeevaRamu0104 , i've fixed this isse, can you please review it ?

uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.AUTO_RELEASE_PAT || github.token }}
Copy link
Contributor

@susrithasabbini susrithasabbini Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add AUTO_RELEASE_PAT in github secrets @JeevaRamu0104 or else default token will be generated by github actions each time it runs the workflow i guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GIF : CI/CD pipeline for ReScript formatter

4 participants