Skip to content
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

[ci] Fail build if any git tracked files were modified. #9661

Merged
merged 1 commit into from
Jan 9, 2025
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
4 changes: 4 additions & 0 deletions build-tools/automation/yaml-templates/build-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,8 @@ stages:
includeBuildResults: true
use1ESTemplate: ${{ parameters.use1ESTemplate }}

- template: /build-tools/automation/yaml-templates/fail-on-dirty-tree.yaml
parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android

- template: /build-tools/automation/yaml-templates/fail-on-issue.yaml
4 changes: 4 additions & 0 deletions build-tools/automation/yaml-templates/build-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ stages:
artifactName: ${{ parameters.buildResultArtifactName }}
includeBuildResults: true
use1ESTemplate: ${{ parameters.use1ESTemplate }}

- template: /build-tools/automation/yaml-templates/fail-on-dirty-tree.yaml
parameters:
xaSourcePath: ${{ parameters.xaSourcePath }}
2 changes: 2 additions & 0 deletions build-tools/automation/yaml-templates/build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,6 @@ stages:
artifactName: ${{ parameters.buildResultArtifactName }}
includeBuildResults: true

- template: /build-tools/automation/yaml-templates/fail-on-dirty-tree.yaml

- template: /build-tools/automation/yaml-templates/fail-on-issue.yaml
22 changes: 22 additions & 0 deletions build-tools/automation/yaml-templates/fail-on-dirty-tree.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Ensure the build did not produce any modified checked in files

parameters:
condition: succeeded()
xaSourcePath:

steps:
- powershell: |
# Run this to log the output for the user
git status

# Run this to error the build if untracked files
$process= git status --porcelain --untracked-files=no

if ($process)
{
Write-Host "##vso[task.logissue type=error]git tree has modified tracked files."
Write-Host "##vso[task.complete result=Failed;]"
}
displayName: Ensure no modified committed files
workingDirectory: ${{ parameters.xaSourcePath }}
condition: ${{ parameters.condition }}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ string FetchTPNLicense (string relativeFilePath)
if (!File.Exists (path))
throw new InvalidOperationException ($"License file {path} does not exist");

return File.ReadAllText (path);
return File.ReadAllText (path).ReplaceLineEndings ();
}

void EnsureValidTPNType (Type type)
Expand Down
Loading