Refactor FederatedCredentials e2e test to use stable repository with config-based disabling#2104
Refactor FederatedCredentials e2e test to use stable repository with config-based disabling#2104
Conversation
…repository Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…rove pagination and timestamp comparison Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…federated credentials Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…function, exclude tmp-bingmaps from cleanup Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Done. Updated |
…ce to avoid auto-cleanup Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…cs, add null checks, improve config validation Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…ps; handle settings push race condition Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot can you please remove the trailing whitespace in the modified files |
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Re-apply the custom repository settings that were lost during reset | ||
| $tempPath = [System.IO.Path]::GetTempPath() | ||
| $repoPath = Join-Path $tempPath ([System.Guid]::NewGuid().ToString()) | ||
| New-Item $repoPath -ItemType Directory | Out-Null | ||
| Push-Location $repoPath | ||
| try { | ||
| Write-Host "Re-applying repository settings..." | ||
| invoke-gh repo clone $repository . | ||
| $repoSettingsFile = ".github\AL-Go-Settings.json" | ||
| if (Test-Path $repoSettingsFile) { | ||
| Add-PropertiesToJsonFile -path $repoSettingsFile -properties @{"ghTokenWorkflowSecretName" = "e2eghTokenWorkflow"} | ||
| invoke-git add $repoSettingsFile | ||
| invoke-git commit -m "Update repository settings for test" --quiet | ||
| invoke-git push --quiet | ||
| Write-Host "Settings push completed. This will trigger a CI/CD workflow run." | ||
| } | ||
| else { | ||
| Write-Host "Warning: .github\AL-Go-Settings.json not found after cloning. Settings may not be applied correctly." | ||
| } | ||
| } | ||
| finally { | ||
| Pop-Location | ||
| Remove-Item -Path $repoPath -Force -Recurse -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| # Upgrade AL-Go System Files to test version | ||
| RunUpdateAlGoSystemFiles -directCommit -wait -templateUrl $template -repository $repository | Out-Null | ||
| RunUpdateAlGoSystemFiles -directCommit -wait -repository $repository | Out-Null | ||
|
|
||
| # Wait for CI/CD workflow to start (triggered by Update AL-Go System Files) | ||
| # This follows the established pattern from CommitAndPush: poll until a new run appears | ||
| Write-Host "Waiting for CI/CD workflow to start (triggered by Update AL-Go System Files push)..." | ||
|
|
||
| # Poll for new workflow run that wasn't in the previous list | ||
| $maxAttempts = 60 # 10 minutes maximum wait (60 * 10 seconds) | ||
| $attempts = 0 | ||
| $run = $null | ||
|
|
||
| while ($attempts -lt $maxAttempts) { | ||
| Start-Sleep -Seconds 10 | ||
| $attempts++ | ||
|
|
||
| $currentRuns = invoke-gh api /repos/$repository/actions/runs -silent -returnValue | ConvertFrom-Json | ||
| # Find new push workflow runs that weren't in our previous list | ||
| $newRuns = $currentRuns.workflow_runs | Where-Object { | ||
| $_.event -eq 'push' -and $previousRunIds -notcontains $_.id | ||
| } | ||
|
|
||
| if ($newRuns) { | ||
| # Get the most recent new run (first one, since API returns newest first) | ||
| $run = $newRuns | Select-Object -First 1 | ||
| Write-Host "Found new CI/CD workflow run: $($run.id) (created at $($run.created_at))" | ||
| break | ||
| } | ||
|
|
||
| Write-Host "Waiting for new CI/CD workflow run to appear (attempt $attempts/$maxAttempts)..." | ||
| } |
There was a problem hiding this comment.
The manual push at lines 106-128 triggers a CI/CD workflow run, but the polling logic starting at line 133 waits for workflow runs triggered by RunUpdateAlGoSystemFiles at line 131. This creates a race condition where the poller might pick up the workflow run from the manual settings push instead of the one from RunUpdateAlGoSystemFiles. Consider capturing workflow run IDs after the manual settings push completes and before calling RunUpdateAlGoSystemFiles to ensure proper tracking.
| WaitWorkflow -repository $repository -runid $run.id -noError | ||
|
|
||
| # The CI/CD workflow should fail because the version number of the app in thie repository is lower than the version number in AppSource | ||
| # The CI/CD workflow should fail because the version number of the app in the repository is lower than the version number in AppSource |
There was a problem hiding this comment.
The comment says "thie repository" but it should be "the repository" (typo: "thie" → "the").
There was a problem hiding this comment.
Already fixed in commit b8d28e8. The comment originally said "tmp repo" (referring to the old repository name) and was updated to "e2e-bingmaps.appsource repo" to reflect the new repository name.
…e duplicate null check Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
❔What, Why & How
Federated credentials require stable repository identity. The FederatedCredentials e2e test was deleting/recreating
tmp-bingmaps.appsourceon each run, breaking federated credential authentication.This PR refactors the test to reuse a pre-existing
e2e-bingmaps.appsourcerepository instead of deleting and recreating it, and implements a config-based mechanism for disabling test scenarios.Helper functions added to
e2eTestHelper.psm1:CleanupWorkflowRuns: Deletes all workflow runs in a repository with pagination support (ensures clean tracking state)ResetRepositoryToSource: Hard resets repository content to match source viagit reset --hard+ force push (preserves identity, resets content) with individual error handling for each git operationTest flow changes in
scenarios/FederatedCredentials/runtest.ps1:tmp-bingmaps.appsource→e2e-bingmaps.appsource(avoidstmp*cleanup pattern)bcsamples-bingmaps.appsourcecontent before each runghTokenWorkflowSecretName) after resetCommitAndPushfunction for workflow run tracking (replaces timestamp-based approach):Workflow changes in
.github/workflows/E2E.yaml:e2eTests/disabled-scenarios.jsonconfig file to manage disabled scenarios (array format with scenario and reason in each object)Technical improvements:
-- --quietflag fromgh repo cloneTo re-enable FederatedCredentials test: Remove the FederatedCredentials object from the array in
e2eTests/disabled-scenarios.json.When re-enabled, the test will use the stable repository instead of recreating it, maintaining federated credential authentication.
✅ Checklist
Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.