Skip to content

Add GitHub Copilot environment setup and increase test coverage to 87% - #4

Merged
marcelo-m7 merged 3 commits into
fix-enviromentfrom
copilot/vscode1761562140247
Oct 27, 2025
Merged

marcelo-m7 merged 3 commits into
fix-enviromentfrom
copilot/vscode1761562140247

Conversation

Copilot AI commented Oct 27, 2025 •

Copy link
Copy Markdown

Addresses the need to configure GitHub Copilot's development environment and improve test coverage across the codebase.

Changes

Environment Setup

  • Added .github/workflows/copilot-setup-steps.yml to pre-configure Python 3.10, install dependencies, and initialize the database before Copilot agents start working
  • Workflow triggers on workflow_dispatch, push, and PR changes for validation

Test Coverage: 70% → 87%

  • src/api.py: 93% → 99% — Added tests for school/area filters, pagination offset, and template fallback
  • src/scrape_ualg.py: 51% → 79% — Added tests for document download, error handling, module/area parsing, and scraping limits

Test Suite: 36 → 46 tests (+10)

API tests now cover:

# Filter validation
def test_list_courses_with_school_filter(self, client):
    response = client.get("/courses?school=Escola de Tecnologia")
    assert all(course.get("school_id") is not None for course in response.json())

# Fallback behavior
def test_read_root_fallback(self, client, monkeypatch):
    monkeypatch.setattr(os.path, "exists", lambda p: False if "index.html" in p else True)
    response = client.get("/")
    assert "API de Cursos da UAlg" in response.text

Scraper tests now cover:

# Error recovery
def test_save_document_download_error(self, mock_get, scraper):
    mock_get.side_effect = requests.RequestException("Connection error")
    # Verifies document metadata saved even when download fails
    scraper.save_document(conn, course_id, "Plano", "https://test.com/doc.pdf")

All tests pass. CodeQL reports zero vulnerabilities.

Original prompt

Can you create a Inssures setup the enviroment for developments, fix the remanings erros and improve the etest covering?

Customizing the development environment for GitHub Copilot coding agent
Learn how to customize GitHub Copilot's development environment with additional tools.

In this article
About customizing Copilot coding agent's development environment
While working on a task, Copilot has access to its own ephemeral development environment, powered by GitHub Actions, where it can explore your code, make changes, execute automated tests and linters and more.

You can customize Copilot's environment to:

Preinstall tools or dependencies in Copilot's environment
Set environment variables in Copilot's environment
Upgrade from standard GitHub-hosted GitHub Actions runners to larger runners
Enable Git Large File Storage (LFS)
Disable or customize the agent's firewall.
Preinstalling tools or dependencies in Copilot's environment
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 default branch.

Here is a simple example of a copilot-setup-steps.yml file for a TypeScript project that clones the project, installs Node.js and downloads and caches the project's dependencies. You should customize this to fit your own project's language(s) and dependencies:

YAML
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@v5

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

  • name: Install JavaScript dependencies
    run: npm ci
    In your copilot-setup-steps.yml file, you can only customize the following settings of the copilot-setup-steps job. If you try to customize other settings, your changes will be ignored.

steps (see above)
permissions (see above)
runs-on (see below)
services
snapshot
timeout-minutes (maximum value: 59)
For more information on these options, see Workflow syntax for GitHub Actions.

Any value that is set for the fetch-depth option of the actions/checkout action will be overridden to allow the agent to rollback commits upon request, while mitigating security risks. For more information, see actions/checkout/README.md.

Your copilot-setup-steps.yml file will automatically be run as a normal GitHub Actions workflow when changes are made, so you can see if it runs successfully. This will show alongside other checks in a pull request where you create or modify the file.

Once you have merged the yml file into your default branch, you can manually run the workflow from the repository's Actions tab at any time to check that everything works as expected. For more information, see Manually running a workflow.

When Copilot starts work, your setup steps will be run, and updates will show in the session logs. See Tracking GitHub Copilot's sessions.

If any setup step fails by returning...

Created from VS Code via the GitHub Pull Request extension.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits October 27, 2025 11:02
Co-authored-by: marcelo-m7 <117441129+marcelo-m7@users.noreply.github.com>
Co-authored-by: marcelo-m7 <117441129+marcelo-m7@users.noreply.github.com>
Copilot AI changed the title [WIP] Customize development environment for GitHub Copilot Add GitHub Copilot environment setup and increase test coverage to 87% Oct 27, 2025
Copilot AI requested a review from marcelo-m7 October 27, 2025 11:13
@marcelo-m7
marcelo-m7 marked this pull request as ready for review October 27, 2025 11:14

@marcelo-m7 marcelo-m7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks better now.

@marcelo-m7
marcelo-m7 merged commit d834e2d into fix-enviroment Oct 27, 2025
2 checks passed
@marcelo-m7
marcelo-m7 deleted the copilot/vscode1761562140247 branch October 27, 2025 11:15
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.

2 participants