Repository navigation
ci: run Azure SQL tests against per-run servers, including fork PRs - #1844
arthurschreiber wants to merge 11 commits into
Conversation
Replace the four Azure jobs in nodejs.yml, which shared one long-lived server and were skipped for forks, with azure-sql.yml: - Each job logs in via GitHub OIDC, creates its own Azure SQL server (random admin password, Entra group admin, firewall limited to the runner IP) and deletes it in an `always()` teardown step. - azure-sql-cleanup.yml runs hourly and deletes tagged servers and test app client secrets older than two hours. - Pull requests run via pull_request_target. The PR code is exported without .git and run in a locked-down container that only receives the throwaway server's credentials. Fork and bot PRs use an environment that requires approval, never get the Entra test user's password, and skip the Codecov upload. - The token-credential tests use a ClientSecretCredential, so they can run with a short-lived client secret. Setup and the security model are documented in .github/AZURE_SQL_CI.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
They were left out of the previous commit because .gitignore ignores new files under .github. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
Register Microsoft.Sql up front, grant the Graph permission via an app role assignment, add the ROPC test user's requirements, note what the provisioner must not own, and add a manual dry run for before the workflows are merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
Rework the Azure SQL CI so that pull request code never runs where Azure credentials are available, instead of running fork code under pull_request_target in a container: - azure-sql.yml runs on pull_request and push with no Azure access. Each job uploads a request artifact (runner IP and a one-time RSA public key), waits for its credentials and runs the tests. - azure-sql-provision.yml runs on workflow_run from the default branch and never checks out pull request code. When a test run starts, it validates each request, creates a server reachable only from the requesting runner, and uploads the credentials encrypted to the job's key. When the run completes, it deletes that run's servers and client secrets. - The test job only accepts credentials uploaded by the provisioning workflow, so an artifact planted by another run is ignored. This avoids pull_request_target, which GitHub blocks by default in public repositories from December 2, 2026, and the allow-unsafe-pr-checkout opt-out that actions/checkout now requires for fork code. The scripts live in .github/scripts/azure-sql/. The setup guide is updated: one environment, ROPC secrets as repository secrets, and fork run approval through the repository's Actions settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
|
The The steps before the wait passed on a real runner: request key generation, the runner IP lookup, and the request artifact upload. All other checks are green so far. To test end to end before this merges, the provisioning workflow, the cleanup workflow and Generated by Claude Code |
…hnson-se1sc6 # Conflicts: # .github/workflows/actions.lock
The provisioning jobs can still be queued for a runner when the test jobs start waiting, so allow for more than server creation itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
|
The The fix is configuration: set the The rest of the path worked on real GitHub and Azure:
Generated by Claude Code |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1844 +/- ##
==========================================
- Coverage 85.24% 84.97% -0.28%
==========================================
Files 97 97
Lines 4778 4778
Branches 896 896
==========================================
- Hits 4073 4060 -13
- Misses 447 460 +13
Partials 258 258 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Generated by Claude Code |
|
On eac4ef7, The provisioner on On the same run, Generated by Claude Code |
On #1844's first end-to-end run, teardown hung in the first `az sql server delete` for its whole 30-minute timeout, so the run's second server was never deleted at all. teardown.sh now starts every deletion with --no-wait, then polls the resource group until the attempt's servers are gone, for up to 15 minutes. A slow deletion can no longer stop the others, and Azure carries out an accepted deletion even if the job ends first. The hourly cleanup also deletes with --no-wait and retries anything still there on its next run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
Replaces the four Azure jobs in
nodejs.yml, which share one long-lived Azure SQL server and are skipped for fork PRs. Each test job now gets its own Azure SQL server, which is deleted when the run finishes. Fork PRs can run these tests too, and their code never runs where Azure credentials are available.This is the untrusted half. The trusted half, the provisioning and cleanup workflows, landed in #1845, and this branch has
mastermerged in. Setup and the security model are documented in.github/AZURE_SQL_CI.md.How it works
azure-sql.yml(this PR)push,pull_requestazure-sql-provision.yml(#1845)workflow_run(start and end of each test run)azure-sql-cleanup.yml(#1845)request-server.sh) creates a one-time RSA key pair and uploads a request artifact with its runner IP and public key.wait-for-server.sh) accepts the credentials only if they were uploaded by the provisioning workflow from the default branch, so an artifact planted by another run is ignored. It decrypts them and runs the integration tests.What PR code can get: its own server's admin password, and for the SP configs, a client secret that is valid for at most 2h on CI servers only. What it never gets: Azure credentials, write tokens, or the Entra test user's password (a repository secret, which GitHub doesn't pass to fork or Dependabot runs).
Changes in this PR
.github/workflows/azure-sql.yml, plus.github/scripts/azure-sql/request-server.shandwait-for-server.sh.nodejs.yml.test/config.token-credential.tsusesClientSecretCredentialinstead ofUsernamePasswordCredential, so it can run with the short-lived secret. Tedious'stoken-credentialpath is tested the same way.actions.lockentry forazure-sql.yml.Testing
az: request → validation → provisioning → encryption → provenance check → decryption → teardown, including a forged credentials artifact being ignored.npm run lintare clean.Azure SQL (…)jobs are the first end-to-end test against real GitHub and Azure.🤖 Generated with Claude Code
https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm