Skip to content

Commit

Permalink
Verify pull requests on windows with github actions
Browse files Browse the repository at this point in the history
Signed-off-by: Jessica He <[email protected]>
  • Loading branch information
JessicaJHee committed Oct 26, 2022
1 parent 8ddf246 commit 24ff745
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 16 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/pr-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: pr-verify

on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
cache: 'maven'
- name: Run Tests on Windows
if: runner.os == 'Windows'
run: ./mvnw.cmd -B '-Dlemminx.cacheInRepoDir' clean verify
- name: Run Tests on Linux
if: runner.os == 'Linux'
run: ./mvnw -B clean verify
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ pipeline{
}
stages{
stage("Maven Build"){
when {
branch 'main'
}
steps {
withMaven {
sh './mvnw clean verify -B -Pci,generate-p2 -Dcbi.jarsigner.skip=false'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private static String getHttpResponseCode(URLConnection conn) {
if (conn != null && conn instanceof HttpURLConnection) {
try {
HttpURLConnection httpConn = (HttpURLConnection) conn;
return (String.valueOf(httpConn.getResponseCode()))+ " " + httpConn.getResponseMessage();
return (String.valueOf(httpConn.getResponseCode())) + " " + httpConn.getResponseMessage();
} catch (IOException e) {
// connection refused and no code could be retrived, do nothing
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.UUID;

import org.eclipse.lemminx.utils.FilesUtils;
import org.eclipse.lemminx.utils.StringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -37,7 +39,13 @@ public abstract class AbstractCacheBasedTest {

static {
try {
parentDir = Files.createTempDirectory("lemminx");
String cacheInRepoDir = System.getProperty("lemminx.cacheInRepoDir");
if (StringUtils.isEmpty(cacheInRepoDir)) {
parentDir = Files.createTempDirectory("lemminx");
} else {
parentDir = Paths.get(System.getProperty("user.home"), "lemminx_test");
Files.createDirectories(parentDir);
}
} catch (IOException e) {
parentDir = null;
}
Expand All @@ -56,7 +64,7 @@ public final void setupCache() throws Exception {
@AfterEach
public final void clearCache() throws IOException {
if (testWorkDirectory != null && Files.exists(testWorkDirectory)) {
MoreFiles.deleteDirectoryContents(testWorkDirectory,RecursiveDeleteOption.ALLOW_INSECURE);
MoreFiles.deleteDirectoryContents(testWorkDirectory, RecursiveDeleteOption.ALLOW_INSECURE);
Files.delete(testWorkDirectory);
}
System.clearProperty(FilesUtils.LEMMINX_WORKDIR_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,10 +886,10 @@ public void sequence() throws BadLocationException {
}

@Test
public void xsAny() throws IOException, BadLocationException {
Path dir = Paths.get("target/xsd/");
public void xsAnyStrict() throws IOException, BadLocationException {
Path dir = getTempDirPath().resolve("target/xsd/");
if (!Files.isDirectory(dir)) {
Files.createDirectory(dir);
Files.createDirectories(dir);
}
Files.deleteIfExists(Paths.get(dir.toString(), "any.xsd"));
XMLLanguageService xmlLanguageService = new XMLLanguageService();
Expand All @@ -907,14 +907,15 @@ public void xsAny() throws IOException, BadLocationException {
" </xs:complexType>\r\n" + //
" </xs:element>\r\n" + //
"</xs:schema>";
Files.write(Paths.get("target/xsd/any.xsd"), schema.getBytes());
Files.write(getTempDirPath().resolve("target/xsd/any.xsd"), schema.getBytes());

String xml = "<ui:page xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ui=\"http://ui\" xsi:schemaLocation=\"http://ui xsd/any.xsd\" >\r\n"
+ //
" | \r\n" + //
" <a/>" + //
"</ui:page>";
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null, "target/any.xml", 4 + 1, true,
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null,
getTempDirPath().resolve("target/any.xml").toUri().toString(), 4 + 1, true,
c("title", "<title></title>"));

// xs:any completion with strict -> only XML Schema global element declaration
Expand All @@ -925,7 +926,8 @@ public void xsAny() throws IOException, BadLocationException {
" | \r\n" + //
" <a/>" + //
"</ui:page>";
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null, "target/any.xml", 4 + 2, true,
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null,
getTempDirPath().resolve("target/any.xml").toUri().toString(), 4 + 2, true,
c("ui:page", "<ui:page></ui:page>"), c("ui:textbox", "<ui:textbox></ui:textbox>"));

// no completion
Expand All @@ -936,10 +938,21 @@ public void xsAny() throws IOException, BadLocationException {
" | \r\n" + //
" <a/>" + //
"</ui:page>";
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null, "target/any.xml", 4, true);
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null,
getTempDirPath().resolve("target/any.xml").toUri().toString(), 4, true);
}

@Test
public void xsAnyLax() throws IOException, BadLocationException {
Path dir = getTempDirPath().resolve("target/xsd/");
if (!Files.isDirectory(dir)) {
Files.createDirectories(dir);
}
Files.deleteIfExists(Paths.get(dir.toString(), "any.xsd"));
XMLLanguageService xmlLanguageService = new XMLLanguageService();

// Test completion with xs:any processContents="lax" (or processContents="skip")
schema = "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" + //
String schema = "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" + //
" targetNamespace=\"http://ui\">\r\n" + //
" <xs:element name=\"textbox\"></xs:element>\r\n" + //
" <xs:element name=\"page\">\r\n" + //
Expand All @@ -952,14 +965,15 @@ public void xsAny() throws IOException, BadLocationException {
" </xs:element>\r\n" + //
"</xs:schema>";

Files.write(Paths.get("target/xsd/any.xsd"), schema.getBytes());
Files.write(getTempDirPath().resolve("target/xsd/any.xsd"), schema.getBytes());

xml = "<ui:page xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ui=\"http://ui\" xsi:schemaLocation=\"http://ui xsd/any.xsd\" >\r\n"
String xml = "<ui:page xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ui=\"http://ui\" xsi:schemaLocation=\"http://ui xsd/any.xsd\" >\r\n"
+ //
" | \r\n" + //
" <a/>" + //
"</ui:page>";
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null, "target/any.xml", 4 + 1, true,
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null,
getTempDirPath().resolve("target/any.xml").toUri().toString(), 4 + 1, true,
c("title", "<title></title>"));

// xs:any completion with strict -> all XML Schema element declaration
Expand All @@ -970,7 +984,8 @@ public void xsAny() throws IOException, BadLocationException {
" | \r\n" + //
" <a/>" + //
"</ui:page>";
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null, "target/any.xml", 4 + 4, true,
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null,
getTempDirPath().resolve("target/any.xml").toUri().toString(), 4 + 4, true,
c("title", "<title></title>"), c("a", "<a/>"), c("ui:page", "<ui:page></ui:page>"),
c("ui:textbox", "<ui:textbox></ui:textbox>"));

Expand All @@ -982,7 +997,8 @@ public void xsAny() throws IOException, BadLocationException {
" | \r\n" + //
" <a/>" + //
"</ui:page>";
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null, "target/any.xml", 4, true);
XMLAssert.testCompletionFor(xmlLanguageService, xml, null, null,
getTempDirPath().resolve("target/any.xml").toUri().toString(), 4, true);
}

@Test
Expand Down

0 comments on commit 24ff745

Please sign in to comment.