-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add Azure Pipelines integration for setup-vp #108
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
tonoizer
wants to merge
7
commits into
voidzero-dev:main
Choose a base branch
from
tonoizer:feat/azure-pipelines-integration
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
7 commits
Select commit
Hold shift + click to select a range
3f9605d
feat: add Azure Pipelines integration for setup-vp
tonoizer f38e153
fix: make Azure runtime reusable across steps
kevinbeier-enbw 751948a
fix: parse Azure boolean env values case-insensitively
kevinbeier-enbw 7807f4c
fix: serialize Azure boolean env values explicitly
kevinbeier-enbw f84c28d
fix: select Azure shell at runtime
tonoizer 9f5b303
fix: address setup-vp PR review feedback
tonoizer 6b7c663
fix: pass Azure registry auth tokens to finalize
tonoizer 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
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
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,40 @@ | ||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| # Azure step templates expand YAML from an external repository but do not check | ||
| # out bootstrap/runtime files onto the agent. Download the compiled runtime and | ||
| # execute its prepare phase, which installs Vite+ and emits cache metadata. | ||
|
|
||
| function Setup-VpDownload { | ||
| param( | ||
| [string]$Url, | ||
| [string]$OutFile | ||
| ) | ||
|
|
||
| Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec 60 | ||
| } | ||
|
|
||
| $setupRef = if ($env:SETUP_VP_SETUP_REF) { $env:SETUP_VP_SETUP_REF } else { 'v1' } | ||
| $runtimeOut = if ($env:SETUP_VP_RUNTIME_OUT) { | ||
| $env:SETUP_VP_RUNTIME_OUT | ||
| } else { | ||
| Join-Path $env:AGENT_TEMPDIRECTORY 'setup-vp-azure/dist/azure/index.mjs' | ||
| } | ||
|
|
||
| $runtimeDir = Split-Path -Parent $runtimeOut | ||
| $chunkDir = Split-Path -Parent $runtimeDir | ||
| New-Item -ItemType Directory -Path $runtimeDir -Force | Out-Null | ||
| New-Item -ItemType Directory -Path $chunkDir -Force | Out-Null | ||
|
|
||
| $runtimeUrl = "https://raw.githubusercontent.com/voidzero-dev/setup-vp/$setupRef/dist/azure/index.mjs" | ||
| Setup-VpDownload -Url $runtimeUrl -OutFile $runtimeOut | ||
|
|
||
| $runtimeText = Get-Content -LiteralPath $runtimeOut -Raw | ||
| $chunkMatches = [regex]::Matches($runtimeText, '[''"]\.\./([^''"]+\.mjs)[''"]') | ||
| $chunkNames = @($chunkMatches | ForEach-Object { $_.Groups[1].Value } | Sort-Object -Unique) | ||
| foreach ($chunkName in $chunkNames) { | ||
| $chunkUrl = "https://raw.githubusercontent.com/voidzero-dev/setup-vp/$setupRef/dist/$chunkName" | ||
| $chunkOut = Join-Path $chunkDir $chunkName | ||
| Setup-VpDownload -Url $chunkUrl -OutFile $chunkOut | ||
| } | ||
|
|
||
| & node $runtimeOut prepare |
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,39 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Azure step templates expand YAML from an external repository but do not check | ||
| # out bootstrap/runtime files onto the agent. Download the compiled runtime and | ||
| # execute its prepare phase, which installs Vite+ and emits cache metadata. | ||
|
|
||
| setup_vp_download() { | ||
| setup_vp_url="$1" | ||
| setup_vp_out="$2" | ||
|
|
||
| if command -v curl >/dev/null 2>&1; then | ||
| curl -fsSL --connect-timeout 5 --max-time 60 "$setup_vp_url" -o "$setup_vp_out" | ||
| elif command -v wget >/dev/null 2>&1; then | ||
| wget -q -T 60 -t 2 -O "$setup_vp_out" "$setup_vp_url" | ||
| else | ||
| echo "setup-vp: curl or wget is required to download files." >&2 | ||
| return 127 | ||
| fi | ||
| } | ||
|
|
||
| SETUP_VP_SETUP_REF="${SETUP_VP_SETUP_REF:-v1}" | ||
| SETUP_VP_RUNTIME_OUT="${SETUP_VP_RUNTIME_OUT:-${TMPDIR:-/tmp}/setup-vp-azure/dist/azure/index.mjs}" | ||
| setup_vp_runtime_dir="$(dirname "$SETUP_VP_RUNTIME_OUT")" | ||
| setup_vp_chunk_dir="$(dirname "$setup_vp_runtime_dir")" | ||
| mkdir -p "$setup_vp_runtime_dir" "$setup_vp_chunk_dir" | ||
| chmod 600 "$SETUP_VP_RUNTIME_OUT" 2>/dev/null || true | ||
|
|
||
| setup_vp_runtime_url="https://raw.githubusercontent.com/voidzero-dev/setup-vp/${SETUP_VP_SETUP_REF}/dist/azure/index.mjs" | ||
| setup_vp_download "$setup_vp_runtime_url" "$SETUP_VP_RUNTIME_OUT" | ||
|
|
||
| while IFS= read -r setup_vp_chunk; do | ||
| setup_vp_chunk_name="${setup_vp_chunk#../}" | ||
| setup_vp_download \ | ||
| "https://raw.githubusercontent.com/voidzero-dev/setup-vp/${SETUP_VP_SETUP_REF}/dist/${setup_vp_chunk_name}" \ | ||
| "$setup_vp_chunk_dir/${setup_vp_chunk_name}" | ||
| done < <(grep -Eo "['\"]\.\./[^'\"]+\.mjs['\"]" "$SETUP_VP_RUNTIME_OUT" | tr -d "'\"" | sort -u) | ||
|
|
||
| node "$SETUP_VP_RUNTIME_OUT" prepare |
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,123 @@ | ||
| parameters: | ||
| - name: version | ||
| type: string | ||
| default: latest | ||
| - name: workingDirectory | ||
| type: string | ||
| default: . | ||
| - name: runInstall | ||
| type: object | ||
| default: true | ||
| - name: sfw | ||
| type: boolean | ||
| default: false | ||
| - name: registryUrl | ||
| type: string | ||
| default: "" | ||
| - name: scope | ||
| type: string | ||
| default: "" | ||
| - name: setupRef | ||
| type: string | ||
| default: v1 | ||
| - name: nodeVersion | ||
| type: string | ||
| default: 24.x | ||
| - name: cache | ||
| type: boolean | ||
| default: false | ||
| - name: cacheDependencyPath | ||
| type: string | ||
| default: "" | ||
|
|
||
| steps: | ||
| - ${{ if ne(parameters.nodeVersion, '') }}: | ||
| - task: UseNode@1 | ||
| displayName: Use Node.js | ||
| inputs: | ||
| version: ${{ parameters.nodeVersion }} | ||
|
|
||
| - powershell: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $bootstrap = Join-Path $env:AGENT_TEMPDIRECTORY 'setup-vp-azure-bootstrap.ps1' | ||
| $base = "https://raw.githubusercontent.com/voidzero-dev/setup-vp/${{ parameters.setupRef }}/azure" | ||
| Invoke-WebRequest -Uri "$base/bootstrap.ps1" -OutFile $bootstrap -TimeoutSec 60 | ||
| & $bootstrap | ||
| condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) | ||
| displayName: setup-vp prepare (Windows) | ||
| env: | ||
| SETUP_VP_VERSION: ${{ parameters.version }} | ||
| SETUP_VP_WORKING_DIRECTORY: ${{ parameters.workingDirectory }} | ||
| SETUP_VP_RUN_INSTALL: ${{ convertToJson(parameters.runInstall) }} | ||
| SETUP_VP_SFW: ${{ iif(eq(parameters.sfw, true), 'true', 'false') }} | ||
| SETUP_VP_REGISTRY_URL: ${{ parameters.registryUrl }} | ||
| SETUP_VP_SCOPE: ${{ parameters.scope }} | ||
| SETUP_VP_SETUP_REF: ${{ parameters.setupRef }} | ||
| SETUP_VP_CACHE: ${{ iif(eq(parameters.cache, true), 'true', 'false') }} | ||
| SETUP_VP_CACHE_DEPENDENCY_PATH: ${{ parameters.cacheDependencyPath }} | ||
| SETUP_VP_RUNTIME_OUT: $(Agent.TempDirectory)\setup-vp-azure\dist\azure\index.mjs | ||
|
|
||
| - bash: | | ||
| set -euo pipefail | ||
| bootstrap="$(Agent.TempDirectory)/setup-vp-azure-bootstrap.sh" | ||
| base="https://raw.githubusercontent.com/voidzero-dev/setup-vp/${{ parameters.setupRef }}/azure" | ||
| curl -fsSL --connect-timeout 5 --max-time 60 "$base/bootstrap.sh" -o "$bootstrap" | ||
| chmod +x "$bootstrap" | ||
| bash "$bootstrap" | ||
| condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) | ||
| displayName: setup-vp prepare (Unix) | ||
| env: | ||
| SETUP_VP_VERSION: ${{ parameters.version }} | ||
| SETUP_VP_WORKING_DIRECTORY: ${{ parameters.workingDirectory }} | ||
| SETUP_VP_RUN_INSTALL: ${{ convertToJson(parameters.runInstall) }} | ||
| SETUP_VP_SFW: ${{ iif(eq(parameters.sfw, true), 'true', 'false') }} | ||
| SETUP_VP_REGISTRY_URL: ${{ parameters.registryUrl }} | ||
| SETUP_VP_SCOPE: ${{ parameters.scope }} | ||
| SETUP_VP_SETUP_REF: ${{ parameters.setupRef }} | ||
| SETUP_VP_CACHE: ${{ iif(eq(parameters.cache, true), 'true', 'false') }} | ||
| SETUP_VP_CACHE_DEPENDENCY_PATH: ${{ parameters.cacheDependencyPath }} | ||
| SETUP_VP_RUNTIME_OUT: $(Agent.TempDirectory)/setup-vp-azure/dist/azure/index.mjs | ||
|
|
||
| - ${{ if eq(parameters.cache, true) }}: | ||
| - task: Cache@2 | ||
| displayName: Cache Vite+ package-manager data | ||
| condition: and(succeeded(), eq(variables['SETUP_VP_CACHE_READY'], 'true')) | ||
| inputs: | ||
| key: '"vite-plus" | "$(Agent.OS)" | "$(Agent.OSArchitecture)" | "$(SETUP_VP_LOCK_TYPE)" | $(SETUP_VP_LOCK_FILE)' | ||
| restoreKeys: | | ||
| "vite-plus" | "$(Agent.OS)" | "$(Agent.OSArchitecture)" | "$(SETUP_VP_LOCK_TYPE)" | ||
| "vite-plus" | "$(Agent.OS)" | "$(Agent.OSArchitecture)" | ||
| path: $(SETUP_VP_CACHE_PATH) | ||
| cacheHitVar: SETUP_VP_CACHE_HIT | ||
|
|
||
| - powershell: | | ||
| $ErrorActionPreference = 'Stop' | ||
| node "$(Agent.TempDirectory)\setup-vp-azure\dist\azure\index.mjs" finalize | ||
| condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) | ||
| displayName: setup-vp finalize (Windows) | ||
| env: | ||
| SETUP_VP_VERSION: ${{ parameters.version }} | ||
| SETUP_VP_WORKING_DIRECTORY: ${{ parameters.workingDirectory }} | ||
| SETUP_VP_RUN_INSTALL: ${{ convertToJson(parameters.runInstall) }} | ||
| SETUP_VP_SFW: ${{ iif(eq(parameters.sfw, true), 'true', 'false') }} | ||
| SETUP_VP_REGISTRY_URL: ${{ parameters.registryUrl }} | ||
| SETUP_VP_SCOPE: ${{ parameters.scope }} | ||
| NODE_AUTH_TOKEN: $(NODE_AUTH_TOKEN) | ||
| SETUP_VP_CACHE: ${{ iif(eq(parameters.cache, true), 'true', 'false') }} | ||
| SETUP_VP_CACHE_DEPENDENCY_PATH: ${{ parameters.cacheDependencyPath }} | ||
|
|
||
| - bash: | | ||
| set -euo pipefail | ||
| node "$(Agent.TempDirectory)/setup-vp-azure/dist/azure/index.mjs" finalize | ||
| condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) | ||
| displayName: setup-vp finalize (Unix) | ||
| env: | ||
| SETUP_VP_VERSION: ${{ parameters.version }} | ||
| SETUP_VP_WORKING_DIRECTORY: ${{ parameters.workingDirectory }} | ||
| SETUP_VP_RUN_INSTALL: ${{ convertToJson(parameters.runInstall) }} | ||
| SETUP_VP_SFW: ${{ iif(eq(parameters.sfw, true), 'true', 'false') }} | ||
| SETUP_VP_REGISTRY_URL: ${{ parameters.registryUrl }} | ||
| SETUP_VP_SCOPE: ${{ parameters.scope }} | ||
| NODE_AUTH_TOKEN: $(NODE_AUTH_TOKEN) | ||
| SETUP_VP_CACHE: ${{ iif(eq(parameters.cache, true), 'true', 'false') }} | ||
| SETUP_VP_CACHE_DEPENDENCY_PATH: ${{ parameters.cacheDependencyPath }} | ||
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.