Skip to content

Commit

Permalink
Ensure modules are current and tidy in CI (#22546)
Browse files Browse the repository at this point in the history
* Ensure modules are current and tidy in CI

Fails the build if go.mod or go.sum isn't current.

* only fail on diff
  • Loading branch information
jhendrixMSFT authored Mar 7, 2024
1 parent 60a4087 commit 3c22771
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions eng/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#reference https://github.com/golangci/golangci-lint#config-file for more options
run:
# ensure that go.mod files are current
modules-download-mode: readonly
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
Expand Down
15 changes: 15 additions & 0 deletions eng/pipelines/templates/steps/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ steps:
failOnStderr: false
workingDirectory: $(System.DefaultWorkingDirectory)
- pwsh: |
$modDirs = ./eng/scripts/get_module_dirs.ps1 '${{ parameters.ServiceDirectory }}'
foreach ($md in $modDirs) {
pushd $md
Write-Host "##[command]Executing go mod tidy in $md"
go mod tidy
$diff = (git diff -w .)
Write-Host ($diff -join "`n")
if ($diff.Length -gt 0) {
exit 1
}
}
displayName: 'go mod tidy'
workingDirectory: $(System.DefaultWorkingDirectory)
- pwsh: |
$modDirs = ./eng/scripts/get_module_dirs.ps1 '${{ parameters.ServiceDirectory }}'
foreach ($md in $modDirs) {
Expand Down

0 comments on commit 3c22771

Please sign in to comment.