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

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Jan 8, 2025

When running xaprepare on Windows, your local git tree ends up dirty due to line ending changes in THIRD-PARTY-NOTICES.txt.

Update xaprepare to always normalize line endings to Environment.NewLine in THIRD-PARTY-NOTICES.txt to prevent this issue.

Additionally, these scenarios where the build unintentionally modifies git tracked files on some platforms are frustrating, so let's prevent them from happening in the first place.

Add a CI check to fail a build if any git tracked files were modified.

Example:

image

Clicking the error will show the modified file(s):

image

Source: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=10799472&view=results

@jpobst jpobst marked this pull request as ready for review January 8, 2025 23:04
@jpobst jpobst requested a review from jonathanpeppers January 8, 2025 23:04
@dellis1972
Copy link
Contributor

can we add the. fail on dirty tree to Java.Interop also? I constantly get modified tracked files when building there, it prevents me doing submodule updates without having to clean it up first 😄

@jonpryor
Copy link
Member

jonpryor commented Jan 9, 2025

@dellis1972 wrote:

can we add the. fail on dirty tree to Java.Interop also? I constantly get modified tracked files when building there

I get that as well, but not because of the build, but because of VSCode! VSCode constantly updates tools/java-source-utils/.project! I guess I should just commit that change, but I have no idea what it's for!

diff --git a/tools/java-source-utils/.classpath b/tools/java-source-utils/.classpath
index 30230c1c..cbded110 100644
--- a/tools/java-source-utils/.classpath
+++ b/tools/java-source-utils/.classpath
@@ -20,6 +20,12 @@
 			<attribute name="test" value="true"/>
 		</attributes>
 	</classpathentry>
+	<classpathentry kind="src" output="bin/main" path="src/main/resources">
+		<attributes>
+			<attribute name="gradle_scope" value="main"/>
+			<attribute name="gradle_used_by_scope" value="main,test"/>
+		</attributes>
+	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
 	<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
 	<classpathentry kind="output" path="bin/default"/>
diff --git a/tools/java-source-utils/.project b/tools/java-source-utils/.project
index 8337a1c5..dd0d1f07 100644
--- a/tools/java-source-utils/.project
+++ b/tools/java-source-utils/.project
@@ -20,4 +20,15 @@
 		<nature>org.eclipse.jdt.core.javanature</nature>
 		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
 	</natures>
+	<filteredResources>
+		<filter>
+			<id>1736435235222</id>
+			<name></name>
+			<type>30</type>
+			<matcher>
+				<id>org.eclipse.core.resources.regexFilterMatcher</id>
+				<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+			</matcher>
+		</filter>
+	</filteredResources>
 </projectDescription>

@jonpryor jonpryor merged commit 208c529 into main Jan 9, 2025
60 checks passed
@jonpryor jonpryor deleted the fail-on-dirty-tree branch January 9, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants