Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 24, 2025

This PR sets up the Copilot agent environment following GitHub's official documentation to improve the development experience for AI-assisted coding.

Changes Made

Copilot Setup Workflow:

  • Created .github/workflows/copilot-setup-steps.yml following GitHub's official documentation and example structure
  • Added proper workflow triggers (workflow_dispatch, push, pull_request) with path filtering for easy validation
  • Configured minimal permissions (contents: read) as recommended by GitHub
  • Pre-configures Copilot's environment with Python 3.11, uv package manager, and all project dependencies
  • Installs development tools (pre-commit, pyright) and sets up pre-commit hooks automatically
  • Uses pip-based uv installation to avoid network restrictions in Copilot environment
  • Verifies installation to ensure environment is properly configured before agent starts

Environment Setup:

  • Implemented uv for Python environment and dependency management (faster than pip)
  • Added uv tool install for development tools (pre-commit, pyright)
  • Configured pre-commit as the preferred tool for code quality checks

Updated Copilot Instructions:

  • Modified .github/copilot-instructions.md to prefer pre-commit run --all-files over direct ruff usage
  • Added comprehensive Copilot agent environment setup section
  • Updated validation workflow to use modern tooling
  • Added fallback instructions for network-restricted environments

Configuration Fixes:

  • Updated pyproject.toml to use modern ruff configuration format ([tool.ruff.lint])
  • Eliminated deprecation warnings about top-level linter settings
  • Removed deprecated ignore-init-module-imports option

Benefits

  • Reliable agent environment through pre-configured workflow steps that run before the agent starts
  • Faster dependency resolution with uv package manager
  • Network restriction compatibility by avoiding blocked domains during setup
  • Comprehensive code quality checks through pre-commit hooks (ruff, prettier, velin, blacken-docs)
  • Better developer experience for Copilot agents with proper tool installation
  • Modern tooling practices following GitHub's recommendations
  • Consistent code quality across all contributors

The copilot-setup-steps.yml workflow ensures that Copilot agents have a deterministic, fast, and reliable environment setup instead of relying on trial-and-error dependency discovery.

Fixes #535.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Set up Copilot agent environment feat: set up Copilot agent environment with uv and pre-commit Aug 24, 2025
@Copilot Copilot AI requested a review from njzjz August 24, 2025 10:49
Copilot finished work on behalf of njzjz August 24, 2025 10:49
Copy link
Member

@njzjz njzjz left a comment

Choose a reason for hiding this comment

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

@copilot please follow https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment to set up .github/workflows/copilot-setup-steps.yml.

In its ephemeral development environment, Copilot can build or compile your project and run automated tests, linters and other tools. To do this, it will need to install your project's dependencies.

Copilot can discover and install these dependencies itself via a process of trial and error, but this can be slow and unreliable, given the non-deterministic nature of large language models (LLMs), and in some cases, it may be completely unable to download these dependencies—for example, if they are private.

Instead, you can preconfigure Copilot's environment before the agent starts by creating a special GitHub Actions workflow file, located at .github/workflows/copilot-setup-steps.yml within your repository.

A copilot-setup-steps.yml file looks like a normal GitHub Actions workflow file, but must contain a single copilot-setup-steps job. This job will be executed in GitHub Actions before Copilot starts working. For more information on GitHub Actions workflow files, see Workflow syntax for GitHub Actions.

Note

The copilot-setup-steps.yml workflow won't trigger unless it's present on your main branch.

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

Copilot AI commented Aug 24, 2025

@copilot please follow https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment to set up .github/workflows/copilot-setup-steps.yml.

In its eph...

Created .github/workflows/copilot-setup-steps.yml following GitHub's documentation. The workflow pre-configures the Copilot agent environment with Python 3.11, uv package manager, project dependencies, development tools (pre-commit, pyright), and pre-commit hooks. This ensures reliable and fast environment setup before the agent starts working. Commit: 363dea8

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI changed the title feat: set up Copilot agent environment with uv and pre-commit feat: set up Copilot agent environment with uv, pre-commit, and workflow setup Aug 24, 2025
@Copilot Copilot AI requested a review from njzjz August 24, 2025 10:58
Copilot finished work on behalf of njzjz August 24, 2025 10:58
Copy link
Member

@njzjz njzjz left a comment

Choose a reason for hiding this comment

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

@copilot please refer to the following example to revise the workflow.

name: "Copilot Setup Steps"

# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
  workflow_dispatch:
  push:
    paths:
      - .github/workflows/copilot-setup-steps.yml
  pull_request:
    paths:
      - .github/workflows/copilot-setup-steps.yml

jobs:
  # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
  copilot-setup-steps:
    runs-on: ubuntu-latest

    # Set the permissions to the lowest permissions possible needed for your steps.
    # Copilot will be given its own token for its operations.
    permissions:
      # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
      contents: read

    # You can define any steps you want, and they will run before the agent starts.
    # If you do not check out your code, Copilot will do this for you.
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: "npm"

      - name: Install JavaScript dependencies
        run: npm ci

…oper triggers and permissions

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

Copilot AI commented Aug 24, 2025

@copilot please refer to the following example to revise the workflow.

Revised the workflow following the provided example. Key changes:

  • Added proper trigger conditions (workflow_dispatch, push, pull_request with path filters)
  • Added minimal permissions configuration (contents: read)
  • Replaced blocked astral-sh/setup-uv action with pip-based uv installation
  • Updated action versions and structure to match the example format
  • Added comprehensive comments following GitHub's documentation style

Commit: 9c97dc8

@Copilot Copilot AI changed the title feat: set up Copilot agent environment with uv, pre-commit, and workflow setup feat: set up Copilot agent environment with uv, pre-commit, and GitHub Actions workflow Aug 24, 2025
Copilot finished work on behalf of njzjz August 24, 2025 11:06
@Copilot Copilot AI requested a review from njzjz August 24, 2025 11:06
Copy link

codecov bot commented Aug 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.25%. Comparing base (43d6e67) to head (09e7b45).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #536      +/-   ##
==========================================
- Coverage   60.33%   60.25%   -0.08%     
==========================================
  Files          39       39              
  Lines        3890     3890              
==========================================
- Hits         2347     2344       -3     
- Misses       1543     1546       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@njzjz
Copy link
Member

njzjz commented Aug 24, 2025

pre-commit.ci autofix

@njzjz njzjz marked this pull request as ready for review August 24, 2025 11:26
@njzjz njzjz enabled auto-merge (squash) August 24, 2025 11:26
@njzjz njzjz merged commit 41872d2 into master Aug 24, 2025
57 checks passed
@njzjz njzjz deleted the copilot/fix-535 branch August 24, 2025 11:31
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.

Set up Copilot agent environment
2 participants