Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.26"
"version": "1.26.1"
},
"ghcr.io/devcontainers/features/docker-in-docker:2.11.0": {
"version": "latest",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "^1.26"
go-version-file: cli/azd/go.mod

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ext-registry-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "^1.26"
go-version-file: cli/azd/go.mod
cache-dependency-path: |
cli/azd/go.sum

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
description: "Path to the Go module directory to lint"
required: true
type: string
go-version:
description: "Go version to use"
go-version-file:
description: "Path to go.mod to read Go version from"
required: false
type: string
default: "^1.26"
default: "cli/azd/go.mod"
golangci-lint-version:
description: "GolangCI-Lint version to use"
required: false
Expand All @@ -29,10 +29,10 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v6
with:
go-version: ${{ inputs.go-version }}
- uses: actions/checkout@v4
go-version-file: ${{ inputs.go-version-file }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
Expand All @@ -43,10 +43,10 @@ jobs:
go-fix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v6
with:
go-version: ${{ inputs.go-version }}
- uses: actions/checkout@v4
go-version-file: ${{ inputs.go-version-file }}
- name: Check for go fix suggestions
working-directory: ${{ inputs.working-directory }}
run: |
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/validate-go-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: validate-go-version

on:
pull_request:
paths:
- "**/go.mod"
- "**/Dockerfile"
- ".devcontainer/devcontainer.json"
- "eng/pipelines/templates/steps/setup-go.yml"
- ".github/workflows/validate-go-version.yml"
branches: [main]

permissions:
contents: read

jobs:
check-go-version-consistency:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Validate Go version consistency
run: |
# Source of truth: cli/azd/go.mod
EXPECTED=$(grep -m1 '^go ' cli/azd/go.mod | awk '{print $2}')
echo "Expected Go version (from cli/azd/go.mod): $EXPECTED"

ERRORS=0

# Check all go.mod files
echo ""
echo "Checking go.mod files..."
for f in $(find cli/azd -name 'go.mod'); do
VERSION=$(grep -m1 '^go ' "$f" | awk '{print $2}')
if [ "$VERSION" != "$EXPECTED" ]; then
echo "::error file=$f::Go version mismatch: found '$VERSION', expected '$EXPECTED'"
ERRORS=$((ERRORS + 1))
else
echo " OK: $f ($VERSION)"
fi
done

# Check ADO pipeline template
echo ""
echo "Checking ADO pipeline template..."
ADO_FILE="eng/pipelines/templates/steps/setup-go.yml"
if [ -f "$ADO_FILE" ]; then
ADO_VERSION=$(grep -m1 'GoVersion:' "$ADO_FILE" | awk '{print $2}')
if [ "$ADO_VERSION" != "$EXPECTED" ]; then
echo "::error file=$ADO_FILE::GoVersion mismatch: found '$ADO_VERSION', expected '$EXPECTED'"
ERRORS=$((ERRORS + 1))
else
echo " OK: $ADO_FILE ($ADO_VERSION)"
fi
fi

# Check Dockerfiles referencing golang:<version> base images
echo ""
echo "Checking Dockerfiles..."
for f in $(find cli/azd -name 'Dockerfile'); do
DOCKER_VERSION=$(grep -oP 'golang:\K[\d.]+' "$f" | head -1)
if [ -n "$DOCKER_VERSION" ] && [ "$DOCKER_VERSION" != "$EXPECTED" ]; then
echo "::error file=$f::Dockerfile golang version mismatch: found '$DOCKER_VERSION', expected '$EXPECTED'"
ERRORS=$((ERRORS + 1))
elif [ -n "$DOCKER_VERSION" ]; then
echo " OK: $f (golang:$DOCKER_VERSION)"
fi
done

# Check devcontainer.json Go feature version
echo ""
echo "Checking devcontainer.json..."
DEVCONTAINER=".devcontainer/devcontainer.json"
if [ -f "$DEVCONTAINER" ]; then
DC_VERSION=$(grep -A1 'devcontainers/features/go' "$DEVCONTAINER" | grep -oP '"version":\s*"\K[\d.]+')
if [ -n "$DC_VERSION" ] && [ "$DC_VERSION" != "$EXPECTED" ]; then
echo "::error file=$DEVCONTAINER::devcontainer Go version mismatch: found '$DC_VERSION', expected '$EXPECTED'"
ERRORS=$((ERRORS + 1))
elif [ -n "$DC_VERSION" ]; then
echo " OK: $DEVCONTAINER ($DC_VERSION)"
fi
fi

echo ""
if [ "$ERRORS" -gt 0 ]; then
echo "::error::$ERRORS Go version mismatch(es) found. Run 'pwsh eng/scripts/Update-GoVersion.ps1 -NewVersion $EXPECTED' to fix."
exit 1
fi
echo "All Go versions are consistent ($EXPECTED)."
2 changes: 1 addition & 1 deletion cli/azd/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In general, to make contributions a smooth and easy experience, we encourage the

Prerequisites:

- [Go](https://go.dev/dl/) 1.26
- [Go](https://go.dev/dl/) 1.26.1

Build:

Expand Down
2 changes: 1 addition & 1 deletion cli/azd/extensions/azure.ai.agents/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module azureaiagent

go 1.26.0
go 1.26.1

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/extensions/azure.ai.finetune/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module azure.ai.finetune

go 1.26.0
go 1.26.1

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/extensions/azure.ai.models/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module azure.ai.models

go 1.26.0
go 1.26.1

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/extensions/azure.appservice/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module azureappservice

go 1.26.0
go 1.26.1

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/extensions/azure.coding-agent/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module azurecodingagent

go 1.26.0
go 1.26.1

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/extensions/microsoft.azd.concurx/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module concurx

go 1.26.0
go 1.26.1

require (
github.com/azure/azure-dev/cli/azd v1.23.13
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/azure/azure-dev/cli/azd

go 1.26.0
go 1.26.1

require (
dario.cat/mergo v1.0.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine AS build
FROM golang:1.26.1-alpine AS build
WORKDIR /app
COPY . .
RUN go build -o /job .
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module containerappjob

go 1.23
go 1.26.1
2 changes: 1 addition & 1 deletion eng/pipelines/templates/steps/setup-go.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
GoVersion: 1.26.0
GoVersion: 1.26.1
Condition: succeeded()

steps:
Expand Down
94 changes: 94 additions & 0 deletions eng/scripts/Update-GoVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
param(
[Parameter(Mandatory = $true)]
[string] $NewVersion
)

Set-StrictMode -Version 4
$ErrorActionPreference = 'Stop'

$repoRoot = Resolve-Path "$PSScriptRoot/../../"

# Canonical source of truth
$coreGoMod = Join-Path $repoRoot 'cli/azd/go.mod'

# All go.mod files that should track the same Go version (including testdata samples).
$goModFiles = Get-ChildItem -Path (Join-Path $repoRoot 'cli/azd') -Recurse -Filter 'go.mod'

# ADO pipeline template that pins the Go toolchain version
$adoSetupGo = Join-Path $repoRoot 'eng/pipelines/templates/steps/setup-go.yml'

$updated = @()
$skipped = @()

# --- Update go.mod files ---
foreach ($file in $goModFiles) {
$content = Get-Content $file.FullName -Raw
if ($content -match '(?m)^go\s+\S+') {
$newContent = $content -replace '(?m)^go\s+\S+', "go $NewVersion"
if ($newContent -ne $content) {
Set-Content -Path $file.FullName -Value $newContent -NoNewline -Encoding utf8NoBOM
$updated += $file.FullName.Substring($repoRoot.Path.Length)
} else {
$skipped += $file.FullName.Substring($repoRoot.Path.Length)
}
}
}

# --- Update ADO pipeline template ---
if (Test-Path $adoSetupGo) {
$content = Get-Content $adoSetupGo -Raw
$newContent = $content -replace '(?m)^(\s+GoVersion:\s+)\S+', "`${1}$NewVersion"
if ($newContent -ne $content) {
Set-Content -Path $adoSetupGo -Value $newContent -NoNewline -Encoding utf8NoBOM
$updated += $adoSetupGo.Substring($repoRoot.Path.Length)
} else {
$skipped += $adoSetupGo.Substring($repoRoot.Path.Length)
}
}

# --- Update Dockerfiles referencing golang:<version> base images ---
$dockerfiles = Get-ChildItem -Path (Join-Path $repoRoot 'cli/azd') -Recurse -Filter 'Dockerfile'
foreach ($file in $dockerfiles) {
$content = Get-Content $file.FullName -Raw
if ($content -match 'golang:\d+\.\d+') {
$newContent = $content -replace 'golang:\d+[\d.]*', "golang:$NewVersion"
if ($newContent -ne $content) {
Set-Content -Path $file.FullName -Value $newContent -NoNewline -Encoding utf8NoBOM
$updated += $file.FullName.Substring($repoRoot.Path.Length)
} else {
$skipped += $file.FullName.Substring($repoRoot.Path.Length)
}
}
}

# --- Update devcontainer.json Go feature version ---
$devcontainer = Join-Path $repoRoot '.devcontainer/devcontainer.json'
if (Test-Path $devcontainer) {
$content = Get-Content $devcontainer -Raw
$newContent = $content -replace '("ghcr\.io/devcontainers/features/go:\d+":\s*\{\s*"version":\s*")[\d.]+(")', "`${1}$NewVersion`${2}"
if ($newContent -ne $content) {
Set-Content -Path $devcontainer -Value $newContent -NoNewline -Encoding utf8NoBOM
$updated += $devcontainer.Substring($repoRoot.Path.Length)
} else {
$skipped += $devcontainer.Substring($repoRoot.Path.Length)
}
}

# --- Report ---
Write-Host ""
if ($updated.Count -gt 0) {
Write-Host "Updated $($updated.Count) file(s) to Go $NewVersion`:" -ForegroundColor Green
$updated | ForEach-Object { Write-Host " $_" }
} else {
Write-Host "No files needed updating." -ForegroundColor Yellow
}

if ($skipped.Count -gt 0) {
Write-Host ""
Write-Host "Already at Go $NewVersion ($($skipped.Count) file(s)):" -ForegroundColor Cyan
$skipped | ForEach-Object { Write-Host " $_" }
}

Write-Host ""
Write-Host "Done. GitHub Actions workflows read the version from cli/azd/go.mod automatically." -ForegroundColor Green
Write-Host "Run 'git diff' to review changes before committing." -ForegroundColor Gray
Loading