Skip to content

Commit

Permalink
Merge pull request #2950 from eclipse/lb-gh-windows
Browse files Browse the repository at this point in the history
Re-enable Windows GitHub Actions and use Maven Wrapper also for Maven plugins ITs
  • Loading branch information
LorenzoBettini committed Mar 6, 2024
2 parents 37af9fa + 83ecc70 commit 462ae28
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 20 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/maven.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.base.repo.clone_url != github.event.pull_request.head.repo.clone_url
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest' ] # 'windows-latest' too flaky
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
fail-fast: false
runs-on: ${{ matrix.os }}

Expand All @@ -35,10 +35,18 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml', '**/*.target') }}
restore-keys: ${{ runner.os }}-m2

- name: Set Maven Home environment variable
run: echo "MAVEN_WRAPPER_HOME=$(./mvnw --version | grep "Maven home:" | cut -c 13-)" >> "$GITHUB_ENV"
if: runner.os != 'Windows'
- name: Set Maven Home environment variable on Windows
run: echo "MAVEN_WRAPPER_HOME=$(./mvnw --version | grep "Maven home:" | cut -c 13-)" | Out-File -FilePath $env:GITHUB_ENV -Append
# In Windows the syntax for setting environment variable is different
if: runner.os == 'Windows'

- name: Build and test
uses: coactions/setup-xvfb@v1
with:
run: ./mvnw clean verify -PuseJenkinsSnapshots -f org.eclipse.xtext.full.releng
run: ./mvnw clean verify "-Dmaven.home=${{ env.MAVEN_WRAPPER_HOME }}" -PuseJenkinsSnapshots -f org.eclipse.xtext.full.releng

build-maven-artifacts:
if: github.event_name != 'pull_request' || github.event.pull_request.base.repo.clone_url != github.event.pull_request.head.repo.clone_url
Expand All @@ -61,5 +69,8 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.target') }}
restore-keys: ${{ runner.os }}-maven

- name: Set Maven Home environment variable
run: echo "MAVEN_WRAPPER_HOME=$(./mvnw --version | grep "Maven home:" | cut -c 13-)" >> "$GITHUB_ENV"

- name: Build Maven artifacts
run: ./mvnw clean verify -PuseJenkinsSnapshots -f org.eclipse.xtext.maven.releng
run: ./mvnw clean verify "-Dmaven.home=${{ env.MAVEN_WRAPPER_HOME }}" -PuseJenkinsSnapshots -f org.eclipse.xtext.maven.releng
1 change: 0 additions & 1 deletion Jenkinsfile
Expand Up @@ -25,7 +25,6 @@ pipeline {
}

tools {
maven "apache-maven-3.9.2"
jdk "temurin-jdk17-latest"
}

Expand Down
2 changes: 2 additions & 0 deletions full-build.sh
Expand Up @@ -44,6 +44,8 @@ done

MVN_ARGS+=(-PuseJenkinsSnapshots)

MVN_ARGS+=("-Dmaven.home=$(./mvnw --version | grep "Maven home:" | cut -c 13-)")

echo ./mvnw -B -f org.eclipse.xtext.full.releng ${MVN_ARGS[@]} $@

#echo "Using target platform '$TARGET_PLATFORM'"
Expand Down
2 changes: 2 additions & 0 deletions full-deploy.sh
Expand Up @@ -44,6 +44,8 @@ done

MVN_ARGS+=(-PuseJenkinsSnapshots)

MVN_ARGS+=("-Dmaven.home=$(./mvnw --version | grep "Maven home:" | cut -c 13-)")

echo ./mvnw -B -f org.eclipse.xtext.full.releng ${MVN_ARGS[@]} $@

./mvnw -B \
Expand Down
1 change: 0 additions & 1 deletion jenkins/milestone-deploy/Jenkinsfile
Expand Up @@ -25,7 +25,6 @@ pipeline {
}

tools {
maven "apache-maven-3.9.2"
jdk "temurin-jdk17-latest"
}

Expand Down
1 change: 0 additions & 1 deletion jenkins/nightly-deploy/Jenkinsfile
Expand Up @@ -13,7 +13,6 @@ pipeline {
}

tools {
maven "apache-maven-3.9.2"
jdk "temurin-jdk17-latest"
}

Expand Down
1 change: 0 additions & 1 deletion jenkins/release-deploy/Jenkinsfile
Expand Up @@ -21,7 +21,6 @@ pipeline {
}

tools {
maven "apache-maven-3.9.2"
jdk "temurin-jdk17-latest"
}

Expand Down
Expand Up @@ -73,7 +73,8 @@ class QuickDebugSourceInstallingCompilationParticipantTest extends AbstractXtend
7:12
4:13,2
*E
'''.toString, debug)
'''.toString.replace("\r", ""),
debug.replace("\r", ""))
debugInfoFound.set(true)
}
super.visitSource(source, debug)
Expand Down
Expand Up @@ -123,7 +123,8 @@ public void visitSource(final String source, final String debug) {
_builder.newLine();
_builder.append("*E");
_builder.newLine();
Assert.assertEquals(_builder.toString(), debug);
Assert.assertEquals(_builder.toString().replace("\r", ""),
debug.replace("\r", ""));
debugInfoFound.set(true);
}
super.visitSource(source, debug);
Expand Down
Expand Up @@ -61,12 +61,13 @@ class MyAnnotationProcessor extends AbstractClassProcessor {
assertTrue(
userCodeFile.toString.endsWith("/filesystemaccess-client/src/main/java/myusercode/UserCode.xtend"))

val userCodeContent =
"package myusercode\n"
+ "\n"
+"@myannotation.MyAnnotation\n"
+"class MyClass {\n"
+"}\n"
val userCodeContent = '''
package myusercode
@myannotation.MyAnnotation
class MyClass {
}
'''

assertEquals(userCodeContent, userCodeFile.contents)
assertEquals(userCodeContent, CharStreams.toString(new InputStreamReader(userCodeFile.contentsAsStream)))
Expand Down
Expand Up @@ -13,6 +13,7 @@

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
import java.util.regex.Pattern;

Expand All @@ -32,10 +33,17 @@ public class XtextGeneratorIT {

private final static boolean debug = Boolean.getBoolean("xtext.it.tests.debug");
private final static boolean fork = !debug;

private static String ROOT = "/it/generate";
private static File testDir;

/**
* As soon as a {@link Verifier} object is created System.out and System.err are
* captured by the verifier; we save the original System.out here so that we can
* print information to the console later.
*/
private static PrintStream systemOut;

/**
* This is the local Maven repository (typically ~/.m2/repository) that we
* will pass to the parent POM of IT projects through the property "local-central".
Expand All @@ -47,19 +55,24 @@ public class XtextGeneratorIT {

@BeforeClass
static public void setUpOnce() throws IOException, VerificationException {
systemOut = System.out;
testDir = extractTestRoot();
if (fork) {
systemOut.println("Current maven.home=" + System.getProperty("maven.home"));
File mvnExecutable = new File(new Verifier(testDir.getAbsolutePath()).getExecutable());
if (!mvnExecutable.exists()) {
String mavenHome = findMaven();
if (mavenHome != null) {
System.setProperty("maven.home", mavenHome);
systemOut.println("Detected maven.home=" + System.getProperty("maven.home"));
} else {
Assert.fail("Maven home not found. Tried to call '" + mvnExecutable
+ "'.\nConsider to set the envVar 'M2_HOME' or System property 'maven.home'.\n"
+ "Current settings are: maven.home=" + System.getProperty("maven.home") + " M2_HOME="
+ CommandLineUtils.getSystemEnvVars().getProperty("M2_HOME"));
}
} else {
systemOut.println("Maven executable: " + mvnExecutable);
}
}
verifyErrorFreeLog("" /*root*/, false, "clean", "install");
Expand All @@ -78,8 +91,8 @@ private static File extractTestRoot() throws IOException {
String localCentralRepository = System.getProperty("maven.repo.local",
System.getProperty("user.home") + "/.m2/repository");
localRepoDir = new File( localCentralRepository );
System.out.println("IT projects will be executed from " + testDir);
System.out.println("Local Maven Central Repository " + localRepoDir);
systemOut.println("IT projects will be executed from " + testDir);
systemOut.println("Local Maven Central Repository " + localRepoDir);
testDir = ResourceExtractor.extractResourcePath(XtextGeneratorIT.class, ROOT, tempDir, true);
return testDir;
}
Expand Down Expand Up @@ -279,7 +292,7 @@ private static Verifier verifyErrorFreeLog(String pathToTestProject, boolean upd
verifier.verifyErrorFreeLog();
if (debug) {
List<String> lines = verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false);
System.out.println(Joiner.on('\n').join(lines));
systemOut.println(Joiner.on('\n').join(lines));
}
verifier.resetStreams();
return verifier;
Expand All @@ -294,7 +307,7 @@ private static Verifier newVerifier(String pathToTestProject) throws IOException
String modMvnOpts = (mvnOpts != null ? mvnOpts + " " : "") + "-Xmx1g";
verifier.setEnvironmentVariable("MAVEN_OPTS", modMvnOpts);
if (debug) {
System.out.println("Modified Maven Opts: " + modMvnOpts);
systemOut.println("Modified Maven Opts: " + modMvnOpts);
}
} else {
verifier.setForkJvm(false);
Expand Down

0 comments on commit 462ae28

Please sign in to comment.