-
Notifications
You must be signed in to change notification settings - Fork 615
feat: add sources upload pipeline #16656
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
PawelWMS
wants to merge
84
commits into
tomls/base/main
Choose a base branch
from
asalinas/tomls/pr-check
base: tomls/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
84 commits
Select commit
Hold shift + click to select a range
ac2d118
Init PR checks
fc68715
PR check calls CT api
13bd561
Fixed minor format err
54deac1
fix: Removed group vars
77722f2
Set default container to azl3
884357e
Use azl agent pool
ebf57c3
Trying a Linux container instead of custom agent pool.
PawelWMS ab05a66
Removing 'addSpnToEnvironment: true' to hide sensitive data.
PawelWMS 9b5125c
Passing 'API_TOKEN' through 'env'.
PawelWMS 65ab31f
Security and refactoring tweaks.
PawelWMS 59949c4
Trying to fix variable access.
PawelWMS 7cb83df
Trying to enable network in OB.
PawelWMS bcac4d7
Adding 'azldev'.
PawelWMS 4524da0
Using internal Go proxy.
PawelWMS 7e35406
Fix command.
PawelWMS 8e02390
Move failing stuff to the top.
PawelWMS 3451bb6
Add SC check.
PawelWMS a51e774
Disabling rendering.
PawelWMS b45a6b8
Moving variables group around.
PawelWMS a1acfb5
Revert "Moving variables group around."
PawelWMS f6e2aaa
Hard-coding the SC.
PawelWMS e79f6e3
Removing unused argument.
PawelWMS 4a8ae72
Added scaffolding for AI.
PawelWMS decc6c6
Clean-up + adding dummy delta components listing
PawelWMS c9c9495
Clean-up
PawelWMS d3fbbc4
Switching to the test branch.
PawelWMS 4875caf
Fixing "trim"
PawelWMS 48655d3
Adding build reason to CT call.
PawelWMS 48e2b65
Making template NonOfficial for debugging.
PawelWMS b5abce9
Revert "Making template NonOfficial for debugging."
PawelWMS 2a8d0d8
Always printing the service response.
PawelWMS eccbca2
Refactoring
PawelWMS 0384f1f
Fixing the SC name.
PawelWMS b5bc996
Empty commit.
PawelWMS c3e6348
Moving the pipeline YAML.
PawelWMS 933ce3d
Testing 'mock'.
PawelWMS f71e678
Refactoring.
PawelWMS 298122b
Moving the pipeline YAML.
PawelWMS 289c16b
Testing 'mock'.
PawelWMS 36c30ff
Listing changed components.
PawelWMS ea27929
Testing 'mock'.
PawelWMS 8eef5b7
Testing 'mock'.
PawelWMS eec5648
Full run
PawelWMS 5f098f1
Fixing mock
PawelWMS 53dcc26
Fixing mock
PawelWMS 09f6aec
Trying to run on host.
PawelWMS d21fe10
Fixing mock
PawelWMS 405c251
Fixing git config
PawelWMS 73d3f0f
Fixing git config
PawelWMS fe1a2ec
Making component render quiet.
PawelWMS 8485fc3
Forcing render overwrite.
PawelWMS 3231fcf
Debugging with simple input
PawelWMS ccd745b
Dummy 'atlas' change - REVERT ME
PawelWMS e834162
Add logging.
PawelWMS 39713b8
Switching to using a Python script for change detection.
PawelWMS cdd9929
Add logging.
PawelWMS ebde7f7
Add logging.
PawelWMS d5c6c69
Failing on updated specs.
PawelWMS f4ac9a6
Adding extra logging.
PawelWMS 9f2b512
Revert "Dummy 'atlas' change - REVERT ME"
PawelWMS 7c308d9
Going back to checking all components.
PawelWMS 0ef9e56
Fix comments.
PawelWMS 0c2bb12
Extend VS Code settings.
PawelWMS dd68939
Refactoring, clean-up.
PawelWMS 81ab293
Moving CT call to a Python script.
PawelWMS 4db3223
Checking with upstream pip
PawelWMS 9d4d2ec
Re-naming the script
PawelWMS ef0b05d
Adding job status polling.
PawelWMS 3bb83f6
Restoring 'PipAuthenticate'.
PawelWMS 4e513e4
Restoring 'PipAuthenticate'.
PawelWMS 3bd3d41
Debugging with simple input
PawelWMS af97a2e
Revert "Debugging with simple input"
PawelWMS c7774b0
Merge branch 'tomls/base/main' into asalinas/tomls/pr-check
PawelWMS f79a0f4
Initial ADO YAML instructions.
PawelWMS 3b0efd6
Refactoring the ADO template into raw + wrapper.
PawelWMS cc7c643
Debugging with dummy components
PawelWMS f30d577
Disabling spec render check.
PawelWMS 3571917
Supporting source branch or commit.
PawelWMS 37cc40e
Disabling target commit.
PawelWMS 45c4671
Adjusting pipeline config.
PawelWMS 7bb4788
Add VS Code configs for ADO pipelines.
PawelWMS 453f787
Add --clean-stale + document TODOs.
PawelWMS a90c807
Address some feedback.
PawelWMS e08780b
Address more Copilot feedback.
PawelWMS 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
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,72 @@ | ||
| # Microsoft Corporation | ||
| # | ||
| # Wrapper pipeline — passed to ADO as the entry point. This file owns all | ||
| # OneBranch-specific wiring (governed templates repo, Official vs NonOfficial | ||
| # variant, featureFlags) and delegates the actual stages/jobs/steps to the | ||
| # raw stages template at: | ||
| # .github/workflows/ado/templates/sources-upload-stages.yml | ||
| # | ||
| # Authenticates via Workload Identity Federation (OIDC) and calls the Control | ||
| # Tower prcheck API with PR context. | ||
| # | ||
| # Prerequisites (ADO / Azure Portal): | ||
| # 1. Entra ID App Registration with audience URI | ||
| # "api://<ControlTower-ClientId>" (see variable group below). | ||
| # 2. Federated identity credential on the app registration for the ADO | ||
| # service connection (issuer: https://vstoken.dev.azure.com/<org-id>, | ||
| # subject: sc://<org>/<project>/<service-connection-name>). | ||
| # 3. ARM service connection in ADO project settings using Workload Identity | ||
| # Federation (manual). | ||
| # 4. ADO branch policy or pipeline PR trigger configured to fire on PRs. | ||
| # | ||
| # Variable Group (ADO Pipelines > Library): | ||
| # Name: "ControlTower-PRCheck" | ||
| # Required variables: | ||
| # - ApiAudience : Entra ID audience URI for the Control Tower app | ||
| # - ApiBaseUrl : Base URL of the Control Tower service | ||
| # - AzldevCommit : Commit hash for azldev (go install ...@<commit>) | ||
|
|
||
| # Trigger controlled by ADO branch policy — not YAML triggers. | ||
| trigger: none | ||
|
|
||
| pr: none | ||
|
|
||
| resources: | ||
| repositories: | ||
| - repository: templates | ||
| type: git | ||
| name: OneBranch.Pipelines/GovernedTemplates | ||
| ref: refs/heads/main | ||
|
|
||
| extends: | ||
| template: v2/OneBranch.Official.CrossPlat.yml@templates | ||
| parameters: | ||
| featureFlags: | ||
| golang: | ||
| internalModuleProxy: | ||
| enabled: true | ||
| LinuxHostVersion: | ||
| Network: R1 | ||
| runOnHost: true | ||
| EnableCDPxPAT: false | ||
|
|
||
| # https://aka.ms/obpipelines/sdl | ||
| globalSdl: | ||
| disableLegacyManifest: true | ||
| sbom: | ||
| enabled: false | ||
| tsa: | ||
| enabled: false | ||
|
|
||
| stages: | ||
| - template: /.github/workflows/ado/templates/sources-upload-stages.yml@self | ||
| parameters: | ||
| outputDirectory: $(Build.ArtifactStagingDirectory)/output | ||
| artifactBaseName: prcheck | ||
| containerImage: mcr.microsoft.com/onebranch/azurelinux/build:3.0 | ||
| poolType: linux | ||
| serviceConnection: CT-Endpoints-Access-ServiceConnection-DEV | ||
| variableGroup: ControlTower-PRCheck | ||
| # Must exceed the script's --poll-timeout-seconds (default 7200s = 120m) | ||
| # with enough headroom for setup steps and the final API call. | ||
| timeoutInMinutes: 150 | ||
194 changes: 194 additions & 0 deletions
194
.github/workflows/ado/templates/sources-upload-stages.yml
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,194 @@ | ||
| # Microsoft Corporation | ||
| # | ||
| # Raw stages template for the sources-upload PR check pipeline. | ||
| # | ||
| # This template is OneBranch-agnostic: it declares the stages/jobs/steps that | ||
| # do the actual work and exposes the OneBranch-coupled knobs as parameters. | ||
| # The wrapper at .github/workflows/ado/sources-upload.yml is responsible for | ||
| # choosing the OneBranch governed template variant (Official vs NonOfficial), | ||
| # configuring its featureFlags, and supplying concrete values for the | ||
| # parameters declared below. | ||
|
|
||
| parameters: | ||
| - name: outputDirectory | ||
| type: string | ||
| - name: artifactBaseName | ||
| type: string | ||
| - name: containerImage | ||
| type: string | ||
| - name: poolType | ||
| type: string | ||
| default: linux | ||
| - name: serviceConnection | ||
| type: string | ||
| - name: variableGroup | ||
| type: string | ||
| - name: timeoutInMinutes | ||
| type: number | ||
|
|
||
| stages: | ||
| - stage: PRCheck | ||
| jobs: | ||
| - job: CallControlTowerAPI | ||
| # Must exceed the script's --poll-timeout-seconds (default 7200s = 120m) | ||
| # with enough headroom for setup steps and the final API call. | ||
| timeoutInMinutes: ${{ parameters.timeoutInMinutes }} | ||
| pool: | ||
| type: ${{ parameters.poolType }} | ||
| variables: | ||
| - group: ${{ parameters.variableGroup }} | ||
| - name: ob_outputDirectory | ||
| value: ${{ parameters.outputDirectory }} | ||
| - name: ob_artifactBaseName | ||
| value: ${{ parameters.artifactBaseName }} | ||
| - name: LinuxContainerImage | ||
| value: ${{ parameters.containerImage }} | ||
| steps: | ||
| - task: PipAuthenticate@1 | ||
| displayName: "Authenticate pip" | ||
| inputs: | ||
| artifactFeeds: "azl/ControlTowerFeed" | ||
|
|
||
| - script: | | ||
| set -euo pipefail | ||
|
|
||
| echo "##[group]Mock" | ||
| tdnf install -y mock mock-rpmautospec python3-chardet | ||
| sudo usermod -aG mock "$(whoami)" | ||
|
PawelWMS marked this conversation as resolved.
|
||
| echo "##[endgroup]" | ||
|
|
||
| echo "##[group]Azldev" | ||
| echo "Installing azldev@${AZLDEV_COMMIT}..." | ||
| go install "github.com/microsoft/azure-linux-dev-tools/cmd/azldev@${AZLDEV_COMMIT}" | ||
|
|
||
| go_bin_path="$(go env GOPATH)/bin" | ||
| echo "##vso[task.prependpath]$go_bin_path" | ||
|
|
||
| "$go_bin_path/azldev" --version | ||
| echo "##[endgroup]" | ||
|
|
||
| echo "##[group]Python dependencies" | ||
| pip install -r .github/workflows/scripts/control-tower-prcheck/requirements.txt | ||
| echo "##[endgroup]" | ||
| displayName: "Install dependencies" | ||
| env: | ||
| AZLDEV_COMMIT: $(AzldevCommit) | ||
|
|
||
| - script: | | ||
| set -euo pipefail | ||
|
|
||
| # Workaround for an ADO git config error during spec rendering. | ||
| # The config key may not be present on every agent image, so tolerate its absence. | ||
| git config --unset extensions.worktreeConfig || true | ||
|
|
||
| # Full history is needed for spec rendering to work. | ||
| if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then | ||
| git fetch --unshallow | ||
| fi | ||
|
|
||
| # TODO: Replace with using the TOML config to read the specs dir once available. | ||
| # The '-o "$specs_dir"' should be removed as part of the update. Future command: | ||
| # specs_dir="$(azldev config dump -q -f json | jq -r .project.renderedSpecsDir)" | ||
| # ADO task: 19149 | ||
| specs_dir="specs" | ||
|
|
||
| echo "##[group]Specs rendering" | ||
| azldev component render -q -a -o "$specs_dir" --force --clean-stale | ||
| echo "##[endgroup]" | ||
|
|
||
| # Check for any new or modified files under the specs directory. | ||
| if ! python3 .github/workflows/scripts/check_rendered_specs.py --specs-dir "$specs_dir"; then | ||
| echo "##[group]Git diff" | ||
| git --no-pager diff -- "$specs_dir" | ||
| echo "##[endgroup]" | ||
| echo "##[warning]Specs are not up to date. Ignoring until main branch is updated and stable." | ||
| # TODO: Re-enabled failing once specs in the main branch are updated and stable. | ||
| # ADO task: 19150 | ||
| # exit 1 | ||
| fi | ||
| displayName: "Verify rendered specs are up to date" | ||
|
|
||
| - script: | | ||
| set -euo pipefail | ||
|
|
||
| # For both triggers, Build.SourceVersion is the relevant source commit: | ||
| # - PR trigger: ADO sets it to the GitHub-created merge commit (refs/pull/{n}/merge). | ||
| # - CI/merge-queue trigger: it is the commit that landed on the base branch. | ||
| source_hash="$SOURCE_COMMIT" | ||
|
|
||
| if [[ "$BUILD_REASON" == "PullRequest" ]]; then | ||
| # PR trigger: ADO provides the target branch directly. | ||
| target_hash=$(git ls-remote "$UPSTREAM_REPO_URL" "$PR_TARGET_BRANCH" | cut -f1) | ||
| else | ||
| # CI/merge-queue trigger: extract the base branch from the merge-queue branch name. | ||
| # Branch format: refs/heads/gh-readonly-queue/{base_branch}/pr-{pr_number}-{head_sha} | ||
| # Using 'test/' branches until ready with the merge queue, but the parsing logic is the same. | ||
| if ! base_branch=$(grep -oP '(?<=test/gh-readonly-queue/).+(?=/pr-[^/]+$)' <<< "$SOURCE_BRANCH"); then | ||
| echo "##[error]Unsupported SOURCE_BRANCH '$SOURCE_BRANCH' for non-PullRequest build. Expected 'refs/heads/gh-readonly-queue/<base>/pr-<n>-<sha>'." | ||
| exit 1 | ||
| fi | ||
| target_hash=$(git ls-remote "$UPSTREAM_REPO_URL" "refs/heads/$base_branch" | cut -f1) | ||
| fi | ||
|
|
||
| echo "Source commit: $source_hash" | ||
| echo "Target commit: $target_hash" | ||
|
|
||
| echo "##vso[task.setvariable variable=sourceCommit]$source_hash" | ||
| echo "##vso[task.setvariable variable=targetCommit]$target_hash" | ||
| env: | ||
| BUILD_REASON: $(Build.Reason) | ||
| PR_TARGET_BRANCH: $(System.PullRequest.TargetBranch) | ||
| SOURCE_BRANCH: $(Build.SourceBranch) | ||
| SOURCE_COMMIT: $(Build.SourceVersion) | ||
| UPSTREAM_REPO_URL: $(Build.Repository.Uri) | ||
| displayName: "Determine source and target commit hashes" | ||
|
|
||
| - script: | | ||
| set -euo pipefail | ||
|
|
||
| cat << EOF | ||
| NOTE: It's possible more components changed between the source and target commits than displayed below. | ||
| This workflow only checks for updates in the 'sources' files and ignores all other changes. | ||
| EOF | ||
|
|
||
| components=() | ||
| while IFS= read -r line; do | ||
| components+=("$(basename "$(dirname "$line")")") | ||
| done < <(git diff "$SOURCE_COMMIT" "$TARGET_COMMIT" --name-only | grep '/sources$' | sort -u) | ||
|
dmcilvaney marked this conversation as resolved.
|
||
|
|
||
| components="$(IFS=, ; echo "${components[*]}")" | ||
| echo "##[warning] Debugging with dummy components 'atlas,words'" | ||
| components="atlas,words" | ||
| echo "Affected components: $components" | ||
| echo "##vso[task.setvariable variable=components]$components" | ||
| env: | ||
| SOURCE_COMMIT: $(sourceCommit) | ||
| TARGET_COMMIT: $(targetCommit) | ||
| displayName: "Determine affected components" | ||
|
|
||
| - task: AzureCLI@2 | ||
| displayName: "Call Control Tower 'prcheck' API" | ||
| inputs: | ||
| azureSubscription: ${{ parameters.serviceConnection }} | ||
| scriptType: bash | ||
| scriptLocation: inlineScript | ||
| inlineScript: | | ||
| set -euo pipefail | ||
|
|
||
| python3 .github/workflows/scripts/control-tower-prcheck/run_control_tower_prcheck.py \ | ||
| --api-audience "$API_AUDIENCE" \ | ||
| --api-base-url "$API_BASE_URL" \ | ||
| --build-reason "$BUILD_REASON" \ | ||
| --components "$COMPONENTS" \ | ||
| --source-commit "$SOURCE_COMMIT" \ | ||
| --repo-uri "$UPSTREAM_REPO_URL" | ||
| env: | ||
| API_AUDIENCE: $(ApiAudience) | ||
| API_BASE_URL: $(ApiBaseUrl) | ||
| BUILD_REASON: $(Build.Reason) | ||
| COMPONENTS: $(components) | ||
| SOURCE_COMMIT: $(sourceCommit) | ||
| # TODO: Target commit is not used. Will be needed once we move detection of affected components to CT. | ||
| # ADO task: 18816 | ||
| TARGET_COMMIT: $(targetCommit) | ||
| UPSTREAM_REPO_URL: $(Build.Repository.Uri) | ||
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.