Skip to content

Fix tests workflow to run from checkout root and upload correct artifact path - #2

Closed
tgerbeau with Copilot wants to merge 2 commits into
masterfrom
copilot/update-tests-yml-workflow
Closed

tgerbeau with Copilot wants to merge 2 commits into
masterfrom
copilot/update-tests-yml-workflow

Conversation

Copilot AI commented Jun 1, 2026 •

Copy link
Copy Markdown

The Tests workflow failed before dependency install because it attempted cd geocontext-test even though actions/checkout already places execution in the repository workspace. The same extra path prefix also caused .pytest_cache artifact collection to miss files.

  • Workflow command path correction

    • Removed cd geocontext-test from:
      • Install dependencies
      • Run tests
    • Commands now execute directly from the checked-out repo root.
  • Artifact path correction

    • Updated upload path from geocontext-test/.pytest_cache to .pytest_cache so artifact lookup matches the actual workspace layout.
- name: Install dependencies
  run: |
    python -m pip install --upgrade pip
    pip install -e .

- name: Run tests
  run: |
    pytest -v --tb=short

- name: Upload test results
  with:
    path: .pytest_cache
Original prompt

The GitHub Actions job failed in repository tgerbeau/geocontext-test.

Failure details:

  • Workflow: .github/workflows/tests.yml
  • Failing job log shows: cd: geocontext-test: No such file or directory
  • The checkout step already places the runner in the repository workspace, so the workflow incorrectly attempts to cd geocontext-test before installing dependencies and running tests.
  • The artifact upload path also incorrectly uses geocontext-test/.pytest_cache instead of the repository root-relative path.

Please update the workflow to:

  1. Remove the unnecessary cd geocontext-test commands from the install and test steps.
  2. Fix the artifact upload path to .pytest_cache.
  3. Keep the rest of the workflow behavior unchanged.

Use the existing workflow file and open a pull request with the fix.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is caused by an incorrect working directory in the workflow, not by the tests themselves.

Root cause

The logs show:

  • /home/runner/work/_temp/...sh: line 1: cd: geocontext-test: No such file or directory

In GitHub Actions, after checkout, the runner is already placed in the repository workspace. This repo itself is geocontext-test, so trying to cd geocontext-test adds an extra directory level that does not exist.

The bad lines are in the job definition here:

Fix

Remove the unnecessary cd geocontext-test commands and upload the artifact from the current workspace.

Suggested patch:

name: Tests

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  test:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        python-version: ['3.13']

    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -e .

      - name: Run tests
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          MODEL_NAME: anthropic:claude-haiku-4-5
        run: |
          pytest -v --tb=short

      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: pytest-results
          path: .pytest_cache
          include-hidden-files: true

Minimal change version

If you want the smallest possible edit to the current file:

      - name: Install dependencies
        run: |
-         cd geocontext-test
          python -m pip install --upgrade pip
          pip install -e .

      - name: Run tests
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          MODEL_NAME: anthropic:claude-haiku-4-5
        run: |
-         cd geocontext-test
          pytest -v --tb=short

      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: pytest-results
-         path: geocontext-test/.pytest_cache
+         path: .pytest_cache
          include-hidden-files: true

Why this is the right fix

The repository layout is consistent with running commands from the root:

  • README.md shows commands like uv run pytest from the repo root.
  • The failure happens before dependency installation or test execution, so no test code changes are needed for this job failure.

If you want to make the workflow more robust, you can also set a default working directory explicitly, but for this repo the direct fix above is sufficient.

User: fix it for me

Assistant: I’m waiting for your confirmation on the proposed repository change so I can continue and open the fix as a pull request.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix failing GitHub Actions job in tests.yml Fix tests workflow to run from checkout root and upload correct artifact path Jun 1, 2026
Copilot AI requested a review from tgerbeau June 1, 2026 13:10
@tgerbeau

tgerbeau commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

@tgerbeau tgerbeau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

good to me

@tgerbeau
tgerbeau marked this pull request as ready for review June 1, 2026 13:14
@tgerbeau tgerbeau closed this Jun 1, 2026
Copilot AI requested a review from tgerbeau June 1, 2026 13:15

Copilot AI commented Jun 1, 2026

Copy link
Copy Markdown
Author

@copilot resolve the merge conflicts in this pull request

Conflicts are resolved in commit 1fb5c9c. The workflow now merges cleanly with master while keeping the root-level test/install commands and .pytest_cache artifact path fix.

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