Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 23, 2025

This PR implements comprehensive CI formatting checks to ensure all TypeSpec, Markdown, and Rust source code follows the defined prettier and rustfmt rules, integrated with the existing Azure DevOps pipeline.

What's Added

Azure DevOps Integration

  • eng/pipelines/templates/steps/build-test.yaml - Added formatting checks to existing CI pipeline
  • eng/pipelines/templates/steps/set-env.yaml - Added prettier installation
  • Runs after the lint step in the existing pipeline structure

Developer Scripts

  • scripts/check-all-formats.sh - Comprehensive format checking for all file types
  • scripts/format-all.sh - Auto-format all supported files
  • scripts/check-rust-format.sh - Rust-specific formatting with proper edition handling
  • scripts/check-typespec-format.sh - TypeSpec file validation (prettier parser not available)

Package Integration

Updated packages/typespec-rust/package.json with:

  • Prettier dependency for consistent formatting
  • New npm scripts: format, format:check, format:prettier, format:eslint
  • Zero-warnings policy for ESLint checks

Configuration

  • .prettierignore - Excludes generated code, build artifacts, and .tsp files
  • .editorconfig - Consistent formatting rules across different editors to prevent unnecessary whitespace changes
  • Preserves existing configurations (.prettierrc, eslint.config.js, rust-toolchain.toml)

Documentation

  • .github/copilot-instructions.md - Added guidance on source regeneration and testing procedures including TypeSpec compilation, running tests, and operating the spector server

Usage

Local Development:

# Check all formatting
./scripts/check-all-formats.sh

# Auto-format all files
./scripts/format-all.sh

# Package-specific commands
cd packages/typespec-rust
pnpm run format:check    # Check formatting
pnpm run format          # Fix formatting

Source Generation and Testing:

cd packages/typespec-rust
pnpm run tspcompile      # Regenerate Rust code from TypeSpec
pnpm run test            # Run TypeScript tests
pnpm run spector --serve # Run spector server for testing

CI Pipeline:

  • Automatically runs on all pushes and pull requests
  • Must pass before code can be merged
  • Provides clear feedback on formatting violations

File Type Coverage

File Type Tool Status
TypeScript/JavaScript ESLint ✅ Zero warnings enforced
Markdown/JSON Prettier ✅ Formatting validated
Rust rustfmt ✅ Edition 2021, excludes generated code
TypeSpec Custom validation ✅ Basic syntax validation

The implementation handles edge cases like generated test files with Rust edition conflicts and provides clear error messages for developers.

Fixes #516.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…st code

Co-authored-by: RickWinter <4430337+RickWinter@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CI pipeline checks to verify that all typespec, markdown, and rust source code is formatted according to the defined prettier and rustfmt rules. Add CI pipeline checks to verify code formatting for TypeSpec, Markdown, and Rust files Jul 23, 2025
Copilot AI requested a review from RickWinter July 23, 2025 15:54
@LarryOsterman
Copy link
Member

The CI pipeline for this repo is an Azure DevOps pipeline, not a github workflow. Please fix this PR so it works with the existing pipeline.

…mat existing code

Co-authored-by: LarryOsterman <8220172+LarryOsterman@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 23, 2025

The CI pipeline for this repo is an Azure DevOps pipeline, not a github workflow. Please fix this PR so it works with the existing pipeline.

Fixed! I've removed the GitHub Actions workflow and integrated the formatting checks into the existing Azure DevOps pipeline structure instead. The changes are in commit 8ebcc4f:

  • Removed .github/workflows/format-check.yml
  • Added formatting checks to eng/pipelines/templates/steps/build-test.yaml
  • Added prettier installation to eng/pipelines/templates/steps/set-env.yaml
  • Applied consistent formatting to all existing code files

The formatting validation now runs as part of the existing CI pipeline after the lint step.

@LarryOsterman
Copy link
Member

/azp run Azure.typespec-rust

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@LarryOsterman
Copy link
Member

There appear to be CI pipeline errors related to formatting.

Co-authored-by: LarryOsterman <8220172+LarryOsterman@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 23, 2025

There appear to be CI pipeline errors related to formatting.

Fixed the CI formatting errors! The issue was a conflict between Prettier and ESLint indentation rules. I've resolved it by disabling the ESLint indent rule (which conflicts with Prettier) and applied proper formatting to the affected files. All formatting checks now pass. See commit 7b1afed.

@LarryOsterman
Copy link
Member

/azp run Azure.typespec-rust

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@RickWinter RickWinter marked this pull request as ready for review July 28, 2025 19:18
Copilot AI review requested due to automatic review settings July 28, 2025 19:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements comprehensive CI formatting checks to ensure all TypeSpec, Markdown, and Rust source code follows defined formatting rules. The implementation includes GitHub Actions workflows, developer scripts, and package integration to enforce consistent code style across the project.

Key Changes

  • Automated CI pipeline checks for TypeScript/JavaScript (ESLint), Markdown/JSON (Prettier), Rust (rustfmt), and TypeSpec files
  • Developer scripts for local formatting validation and auto-formatting
  • Package integration with new npm scripts and Prettier dependency

Reviewed Changes

Copilot reviewed 37 out of 51 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/format-all.sh Auto-format all supported files with appropriate tools
scripts/check-all-formats.sh Comprehensive format checking for all file types
scripts/check-rust-format.sh Rust-specific formatting validation with edition handling
scripts/check-typespec-format.sh TypeSpec file validation (basic syntax checking)
packages/typespec-rust/package.json Added Prettier dependency and formatting npm scripts
packages/typespec-rust/eslint.config.js Disabled indent rule to avoid conflicts with Prettier
Multiple TypeScript files Applied consistent formatting using ESLint and Prettier
Documentation files Updated formatting and added development workflow instructions
Files not reviewed (1)
  • packages/typespec-rust/pnpm-lock.yaml: Language not supported

…itors

Co-authored-by: heaths <1532486+heaths@users.noreply.github.com>
Copilot AI requested a review from heaths July 28, 2025 22:22
Co-authored-by: heaths <1532486+heaths@users.noreply.github.com>
Copilot AI requested a review from heaths July 28, 2025 22:33
Co-authored-by: heaths <1532486+heaths@users.noreply.github.com>
Copilot AI requested a review from heaths July 28, 2025 22:37
@heaths heaths marked this pull request as draft August 1, 2025 17:55
@heaths
Copy link
Member

heaths commented Aug 1, 2025

Moving PRs we don't want for the release today to draft. @copilot, please rebase this PR.

Copy link
Contributor Author

Copilot AI commented Aug 1, 2025

Moving PRs we don't want for the release today to draft. @copilot, please rebase this PR.

I'm unable to perform a git rebase operation due to environment limitations - force push is not available in my sandbox environment. Additionally, I can't fetch the latest changes from the remote due to authentication restrictions.

Could you clarify what specific changes you'd like me to make? I can:

  • Make new commits with changes
  • Reset and recreate commits (if you specify what should be included)
  • Reorganize the code changes

What would be the preferred approach for updating this PR?

@RickWinter
Copy link
Member

@copilot rebase the changes with main.

Co-authored-by: RickWinter <4430337+RickWinter@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 8, 2025

@copilot rebase the changes with main.

I'm unable to perform a git rebase operation due to environment limitations - force push is not available in my sandbox environment. Could you clarify what specific changes you'd like me to make? I can make new commits with changes or reorganize the code changes in another way.

@RickWinter
Copy link
Member

@copilot merge with main

Copy link
Contributor Author

Copilot AI commented Sep 9, 2025

@copilot merge with main

I'm unable to perform a git merge with main due to environment limitations - I cannot fetch from the remote repository due to authentication restrictions, and force push operations are not available in my sandbox environment.

Could you clarify what specific changes you'd like me to make instead? I can:

  • Make new commits with updated changes
  • Modify specific files if there are conflicts you'd like me to resolve
  • Reorganize the code changes in another way

What would be the preferred approach for updating this PR?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CI pipeline checks to verify that all typespec, markdown, and rust source code is formatted according to the defined prettier and rustfmt rules.

4 participants