Skip to content

Fix E2E testing race condition in progress syncing#95

Open
SAN-MUYUN wants to merge 3 commits intogit-mastery:mainfrom
SAN-MUYUN:e2e/race-condition
Open

Fix E2E testing race condition in progress syncing#95
SAN-MUYUN wants to merge 3 commits intogit-mastery:mainfrom
SAN-MUYUN:e2e/race-condition

Conversation

@SAN-MUYUN
Copy link
Copy Markdown
Contributor

Fixes #70

shell: bash
env:
GH_PAT: ${{ secrets.GH_PAT }}
GH_PAT: >-
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.

Can add a new step to set the PAT instead

GH_PAT: >-
${{
matrix.os == 'ubuntu-latest' &&
secrets.E2E_BOT_PAT_UBUNTU ||
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.

Perhaps lets standardise the name of the secret, eg. GH_PAT_UBUNTU

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.

Also is it set already in the environment?

@jovnc jovnc changed the title E2e/race condition Fix E2E testing race condition in progress syncing Mar 30, 2026
Copy link
Copy Markdown

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

Adjusts GitHub Actions E2E workflows to reduce credential contention by selecting different PAT secrets per matrix OS and standardizing on GH_TOKEN for E2E authentication.

Changes:

  • Selects GH_PAT_UBUNTU for ubuntu-latest and falls back to GH_PAT for other OSes.
  • Exports the selected PAT as GH_TOKEN via $GITHUB_ENV and validates it before running E2E tests.
  • Removes the per-step GH_TOKEN env injection from the E2E pytest step.

Reviewed changes

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

File Description
.github/workflows/test.yml Chooses OS-specific PAT and exports GH_TOKEN globally for the job before running E2E tests.
.github/workflows/test-pr.yml Same PAT selection/export approach for pull_request_target E2E workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +36
- name: Set GH_TOKEN
shell: bash
env:
GH_PAT: ${{ secrets.GH_PAT }}
GH_PAT: >-
${{
matrix.os == 'ubuntu-latest' &&
secrets.GH_PAT_UBUNTU ||
(matrix.os != 'ubuntu-latest' && secrets.GH_PAT) ||
''
}}
run: |
if [ -z "$GH_PAT" ]; then
echo "GH_PAT secret is required to run E2E tests."
echo "GH_TOKEN=$GH_PAT" >> $GITHUB_ENV
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

In the pull_request_target workflow, this step writes the PAT into $GITHUB_ENV, which makes GH_TOKEN available to all subsequent steps (including checkout/build of untrusted PR code). Previously the PAT was only scoped to the E2E test step. To avoid secret exposure, keep the PAT scoped to just the step(s) that need it (e.g., set env: GH_TOKEN: ... only on Run E2E tests, and do validation without exporting to $GITHUB_ENV).

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +31
matrix.os == 'ubuntu-latest' &&
secrets.GH_PAT_UBUNTU ||
(matrix.os != 'ubuntu-latest' && secrets.GH_PAT) ||
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This change still selects the same secrets.GH_PAT for both macos-latest and windows-latest, so two matrix jobs can still run concurrently against the same PAT. If the race condition is caused by parallel matrix jobs sharing a token, consider providing distinct secrets per OS (or serializing the GitHub-mutating portion via concurrency) so each job uses its own credentials.

Suggested change
matrix.os == 'ubuntu-latest' &&
secrets.GH_PAT_UBUNTU ||
(matrix.os != 'ubuntu-latest' && secrets.GH_PAT) ||
matrix.os == 'ubuntu-latest' && secrets.GH_PAT_UBUNTU ||
matrix.os == 'macos-latest' && secrets.GH_PAT_MACOS ||
matrix.os == 'windows-latest' && secrets.GH_PAT_WINDOWS ||

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +32
matrix.os == 'ubuntu-latest' &&
secrets.GH_PAT_UBUNTU ||
(matrix.os != 'ubuntu-latest' && secrets.GH_PAT) ||
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This change still selects the same secrets.GH_PAT for both macos-latest and windows-latest, so two matrix jobs can still run concurrently against the same PAT. If the race condition is caused by parallel matrix jobs sharing a token, consider providing distinct secrets per OS (or serializing the GitHub-mutating portion via concurrency) so each job uses its own credentials.

Suggested change
matrix.os == 'ubuntu-latest' &&
secrets.GH_PAT_UBUNTU ||
(matrix.os != 'ubuntu-latest' && secrets.GH_PAT) ||
matrix.os == 'ubuntu-latest' && secrets.GH_PAT_UBUNTU ||
matrix.os == 'macos-latest' && secrets.GH_PAT_MACOS ||
matrix.os == 'windows-latest' && secrets.GH_PAT_WINDOWS ||

Copilot uses AI. Check for mistakes.
Comment on lines +24 to 43
- name: Set GH_TOKEN
shell: bash
env:
GH_PAT: ${{ secrets.GH_PAT }}
GH_PAT: >-
${{
matrix.os == 'ubuntu-latest' &&
secrets.GH_PAT_UBUNTU ||
(matrix.os != 'ubuntu-latest' && secrets.GH_PAT) ||
''
}}
run: |
if [ -z "$GH_PAT" ]; then
echo "GH_PAT secret is required to run E2E tests."
echo "GH_TOKEN=$GH_PAT" >> $GITHUB_ENV

- name: Validate GH_TOKEN
shell: bash
run: |
if [ -z "$GH_TOKEN" ]; then
echo "Required PAT secret is missing for ${{ matrix.os }}."
exit 1
fi
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

Writing GH_TOKEN to $GITHUB_ENV makes it available to every later step in this job (install/build/configure git). If only the E2E tests need the PAT, scope it to the Run E2E tests step to reduce the blast radius of secrets in logs/process env.

Copilot uses AI. Check for mistakes.
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.

E2E testing race condition in progress syncing

3 participants