-
Notifications
You must be signed in to change notification settings - Fork 320
Add PR gate tests for azd ai agent extension #8754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
v1212
wants to merge
9
commits into
main
Choose a base branch
from
wujia/ai-agent-pr-gate-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5eda204
Add PR gate tests for azd ai agent extension (Tier 0 + Tier 1)
ffbe718
fix: replace false assertions with real ARM resolution checks + add n…
8bccd86
fix: address review — pin .env value, fix neg-control comments, use s…
1f77c54
ci: retrigger pipeline
fb59fc5
Update GitHub Actions to latest major versions in CI workflow
Copilot 0c9ac36
address review: split test files, remove pull-requests:write
c23efbb
ci: retrigger ext workflow
8706a4a
fix: sanitize cassette PII, fix workflow permissions, strengthen asse…
1acaafe
refactor: move ai agent tests to subdirectory, split workflows, add C…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: ext-azure-ai-agents-test | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "cli/azd/extensions/azure.ai.agents/**" | ||
| - "cli/azd/test/functional/ai_agents/**" | ||
| - ".github/workflows/test-ext-azure-ai-agents.yml" | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: cli/azd/go.mod | ||
|
|
||
| - name: Build azd | ||
| working-directory: cli/azd | ||
| run: go build -tags=record -o azd-record ./ | ||
|
|
||
| - name: Build extension (record-tagged) | ||
| working-directory: cli/azd/extensions/azure.ai.agents | ||
| run: go build -tags=record -o azure-ai-agents . | ||
|
|
||
| - name: Install extension | ||
| run: | | ||
| EXT_DIR="$HOME/.azd/extensions/azure.ai.agents" | ||
| mkdir -p "$EXT_DIR" | ||
| cp cli/azd/extensions/azure.ai.agents/azure-ai-agents "$EXT_DIR/azure-ai-agents-linux-amd64" | ||
| # Register extension in azd config | ||
| mkdir -p "$HOME/.azd" | ||
| python3 -c " | ||
| import json, pathlib | ||
| config = { | ||
| 'extension': { | ||
| 'installed': { | ||
| 'azure.ai.agents': { | ||
| 'id': 'azure.ai.agents', | ||
| 'namespace': 'ai.agent', | ||
| 'capabilities': ['custom-commands', 'lifecycle-events', 'mcp-server', 'service-target-provider', 'metadata'], | ||
| 'displayName': 'Foundry agents (Preview)', | ||
| 'description': 'Ship agents with Microsoft Foundry from your terminal. (Preview)', | ||
| 'version': '0.0.0-test', | ||
| 'usage': 'azd ai agent <command> [options]', | ||
| 'path': 'extensions/azure.ai.agents/azure-ai-agents-linux-amd64', | ||
| 'source': 'azd' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| pathlib.Path.home().joinpath('.azd', 'config.json').write_text(json.dumps(config, indent=2)) | ||
| " | ||
| cat "$HOME/.azd/config.json" | ||
|
|
||
| - name: Run Tier 0 tests (offline) | ||
| working-directory: cli/azd | ||
| env: | ||
| CLI_TEST_AZD_PATH: ${{ github.workspace }}/cli/azd/azd-record | ||
| run: | | ||
| go test -tags=record -run "Test_AIAgent_(Version|Help|Init_NoPrompt_MissingFlags|SampleList|Doctor_Help)" \ | ||
| ./test/functional/ai_agents/ -v -timeout 5m | ||
|
|
||
| - name: Run Tier 1 tests (playback) | ||
| working-directory: cli/azd | ||
| env: | ||
| AZURE_RECORD_MODE: playback | ||
| CLI_TEST_AZD_PATH: ${{ github.workspace }}/cli/azd/azd-record | ||
| run: | | ||
| # Make azd-record available as "azd" on PATH so that | ||
| # azidentity.AzureDeveloperCLICredential (exec.LookPath("azd")) works in playback | ||
| sudo ln -sf "$GITHUB_WORKSPACE/cli/azd/azd-record" /usr/local/bin/azd | ||
| go test -tags=record -run "Test_AIAgent_Init_(NoPrompt_(Defer|WithProject)|NegativeControl_BadCassette)" \ | ||
| ./test/functional/ai_agents/ -v -timeout 5m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,3 +81,5 @@ words: | |
| - deepseek | ||
| - ttfb | ||
| - Bhadauria | ||
| # Test infrastructure | ||
| - recordproxy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
cli/azd/extensions/azure.ai.agents/internal/pkg/recordproxy/transport.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| //go:build !record | ||
|
|
||
| package recordproxy | ||
|
|
||
| import "net/http" | ||
|
|
||
| // Transport is nil in non-record builds — no proxy is used. | ||
| var Transport http.RoundTripper |
51 changes: 51 additions & 0 deletions
51
cli/azd/extensions/azure.ai.agents/internal/pkg/recordproxy/transport_record.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| //go:build record | ||
|
|
||
| // Package recordproxy intercepts ALL outbound HTTP traffic when the "record" | ||
| // build tag is active, routing it through the recording proxy (azd-record). | ||
| // This includes http.DefaultTransport (covers http.Client{} and similar) and | ||
| // Azure SDK clients (via client_options.go). Third-party SDKs that accept a | ||
| // custom transport parameter should also use Transport from this package to | ||
| // ensure their traffic is captured during recording/playback. | ||
| package recordproxy | ||
|
|
||
| import ( | ||
| "crypto/tls" | ||
| "net/http" | ||
| "net/url" | ||
| "os" | ||
| ) | ||
|
|
||
| // Transport is the proxy-aware transport for record/playback mode. | ||
| // It routes all HTTP traffic through the recording proxy (AZD_TEST_HTTPS_PROXY). | ||
| // nil when the env var is not set. | ||
| var Transport http.RoundTripper | ||
|
|
||
| func init() { | ||
| val, ok := os.LookupEnv("AZD_TEST_HTTPS_PROXY") | ||
| if !ok { | ||
| return | ||
| } | ||
| proxyUrl, err := url.Parse(val) | ||
| if err != nil { | ||
| panic("recordproxy: invalid AZD_TEST_HTTPS_PROXY URL: " + err.Error()) | ||
| } | ||
|
|
||
| base, ok := http.DefaultTransport.(*http.Transport) | ||
| if !ok { | ||
| panic("recordproxy: http.DefaultTransport is not *http.Transport") | ||
| } | ||
| transport := base.Clone() | ||
| transport.TLSClientConfig = &tls.Config{ | ||
| MinVersion: tls.VersionTLS12, | ||
| InsecureSkipVerify: true, //nolint:gosec // recording proxy uses self-signed cert | ||
| } | ||
| transport.Proxy = http.ProxyURL(proxyUrl) | ||
|
|
||
| // This affects extension's own http.Client{} (init.go:937) which uses DefaultTransport. | ||
| // Azure SDK ARM clients are handled separately via ClientOptions.Transport in client_options.go. | ||
| http.DefaultTransport = transport | ||
| Transport = transport | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.