Skip to content
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
51 changes: 26 additions & 25 deletions .github/scripts/prepare-test-outputs-for-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

set -e

echo "Using Java ${1?Pass the Java version as the first argument to this script!}"
CI_JAVA_VERSION=${1?Pass the Java version as the first argument to this script!}
CI_OS=${2?Pass the OS name as the second argument to this script!}

if ! command -v xsltproc > /dev/null 2>&1; then
if [ -z ${CI+_} ]; then
Expand All @@ -36,27 +37,27 @@ fi

echo -e "\e[1;35mUpdating Surefire reports...\e[0m"
surefire_prefix_xslt=$(mktemp --suffix=.xslt)
cat > "${surefire_prefix_xslt}" <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
| XSLT transformation to add a prefix to the start of the 'testcase' names in Surefire reports.
| This allows us to prefix each test with the Java version before we combine them into a single
| test report.
|-->
<xsl:param name="prefix"/>
<xsl:output indent="yes"/>
<xsl:template name="identity" match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template name="prefix-testcase-names" match="testcase/@name">
<xsl:attribute name="name" namespace="{namespace-uri()}">
<xsl:value-of select="concat($prefix, ' ', ../@name)"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
sed 's/^ //g' > "${surefire_prefix_xslt}" <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
| XSLT transformation to add a prefix to the start of the 'testcase' names in Surefire reports.
| This allows us to prefix each test with the Java version before we combine them into a single
| test report.
|-->
<xsl:param name="prefix"/>
<xsl:output indent="yes"/>
<xsl:template name="identity" match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template name="prefix-testcase-names" match="testcase/@name">
<xsl:attribute name="name" namespace="{namespace-uri()}">
<xsl:value-of select="concat($prefix, ' ', ../@name)"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
EOF

function find-all-surefire-reports() {
Expand All @@ -73,8 +74,8 @@ function find-all-jacoco-reports() {

for surefire_report in $(find-all-surefire-reports); do
echo -e "\e[1;34mAdding Java version to test case names in ${surefire_report}...\e[0m"
new_surefire_report=${surefire_report/.xml/-java-${CI_JAVA_VERSION}.xml}
xsltproc --stringparam prefix "[Java-${CI_JAVA_VERSION}]" \
new_surefire_report=${surefire_report/.xml/-java-${CI_JAVA_VERSION}-${CI_OS}.xml}
xsltproc --stringparam prefix "[Java-${CI_JAVA_VERSION}-${CI_OS}]" \
"${surefire_prefix_xslt}" "${surefire_report}" > "${new_surefire_report}"
echo -e "\e[1;34mReplacing ${surefire_report} with ${new_surefire_report}\e[0m"
rm "${surefire_report}"
Expand All @@ -84,7 +85,7 @@ rm "${surefire_prefix_xslt}"

echo -e "\e[1;35mUpdating Jacoco reports...\e[0m"
for jacoco_report in $(find-all-jacoco-reports); do
new_jacoco_report="${jacoco_report/.xml/-java-${CI_JAVA_VERSION}.xml}"
new_jacoco_report="${jacoco_report/.xml/-java-${CI_JAVA_VERSION}-${CI_OS}.xml}"
echo -e "\e[1;34mRenaming ${jacoco_report} to ${new_jacoco_report}\e[0m"
mv "${jacoco_report}" "${new_jacoco_report}"
done
Expand Down
86 changes: 53 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,56 @@ jobs:
uses: github/codeql-action/analyze@v1

test:
name: Build and test (Java ${{ matrix.java-version }})
runs-on: ubuntu-latest
name: Build (Java ${{ matrix.java-version }} | ${{ matrix.os }})
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest ]
build-script: [ ./mvnw ]
java-version: [ 11, 12, 13, 14, 15, 16, 17, 18 ]
experimental: [ false ]
include:
- os: windows-latest
build-script: './mvnw.cmd'
java-version: 17
experimental: true

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize Java ${{ matrix.java-version }}
- name: Initialize JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '${{ matrix.java-version }}'

- name: Build with Java ${{ matrix.java-version }}
run: |-
concurrency=$(($(nproc) * 10))
./mvnw -B -U -T${concurrency}C clean package \
--no-transfer-progress \
-Dcheckstyle.skip=true \
-Dstyle.color=always \
-Dmaven.artifact.threads=${concurrency}

- name: Mark test and coverage reports as being for this Java version
run: ".github/scripts/prepare-test-outputs-for-merge.sh ${{ matrix.java-version }}"
- name: Compile and run tests
continue-on-error: ${{ matrix.experimental }}
run: >-
${{ matrix.build-script }}
-B
-U
-T8C
--no-transfer-progress
'-Dcheckstyle.skip=true'
'-Dstyle.color=always'
'-Dmaven.artifact.threads=100'
clean package

- name: Annotate test reports
if: always()
run: >-
.github/scripts/prepare-test-outputs-for-merge.sh
${{ matrix.java-version }}
${{ matrix.os }}

- name: Archive Surefire reports
uses: actions/upload-artifact@v2
if: always()
with:
name: tests-java-${{ matrix.java-version }}
name: tests-java-${{ matrix.java-version }}-${{ matrix.os }}
path: "**/target/surefire-reports/TEST-*.xml"
retention-days: 5

Expand All @@ -85,7 +101,6 @@ jobs:
needs: [ test ]
runs-on: ubuntu-latest
if: always()

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -108,8 +123,7 @@ jobs:
- name: Publish code coverage
continue-on-error: true
if: always()
run: >-
bash <(curl -s https://codecov.io/bash)
run: bash <(curl -s https://codecov.io/bash)

checkstyle:
name: Run Checkstyle
Expand All @@ -125,13 +139,16 @@ jobs:
java-version: '17'

- name: Run Checkstyle
run: |-
concurrency=$(($(nproc) * 10))
./mvnw -B -U -T${concurrency}C clean package \
--no-transfer-progress \
-DskipTests=true \
-Dstyle.color=always \
-Dmaven.artifact.threads=${concurrency}
run: >-
./mvnw
-B
-U
-T8C
--no-transfer-progress
-DskipTests=true
-Dstyle.color=always
-Dmaven.artifact.threads=100
clean package

javadoc:
name: Generate JavaDocs
Expand All @@ -151,14 +168,17 @@ jobs:
java-version: '17'

- name: Generate JavaDoc documentation
run: |-
concurrency=$(($(nproc) * 10))
./mvnw -B -U -T${concurrency}C clean compile javadoc:jar \
--no-transfer-progress \
-Dmaven.test.skip=true \
-Dcheckstyle.skip=true \
-Dstyle.color=always \
-Dmaven.artifact.threads=${concurrency}
run: >-
./mvnw
-B
-U
-T8C
--no-transfer-progress
-Dmaven.test.skip=true
-Dcheckstyle.skip=true
-Dstyle.color=always
-Dmaven.artifact.threads=100
clean compile javadoc:jar

- name: Archive JavaDoc artifacts
uses: actions/upload-artifact@v2
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Maven Wrapper
/.mvn/wrapper/maven-wrapper.jar

# Build output
build/
out/
Expand Down
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</encoder>
</appender>

<root level="DEBUG">
<root level="TRACE">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</encoder>
</appender>

<root level="DEBUG">
<root level="TRACE">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
49 changes: 4 additions & 45 deletions java-compiler-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand All @@ -92,45 +86,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<!-- Skip default-test so we can run unit and integration suites separately -->
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>

<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>com.github.ascopes.jct.testing.UnitTestSuite</include>
</includes>
</configuration>
</execution>

<execution>
<id>integration-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>com.github.ascopes.jct.testing.IntegrationTestSuite</include>
</includes>
</configuration>
</execution>
</executions>

<configuration>
<failIfNoTests>true</failIfNoTests>
</configuration>
</plugin>

<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void appendPossibleUnderline(StringBuilder builder, int startOfLine, int
builder
.append(PADDING)
.append(" ".repeat(lineNumberWidth))
.append(" · ");
.append(" + ");

for (int i = startOfLine; i < endOfLine; ++i) {
builder.append(startOffset <= i && i <= endOffset ? '^' : ' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public ModuleLocation getModuleLocationFor(String moduleName) {
* @return the module location if known, or an empty optional otherwise.
*/
public Optional<ModuleLocation> getModuleLocationFor(FileObject fileObject) {
var path = Path.of(fileObject.toUri());
// TODO(ascopes): can we get non-path file objects here?
var path = ((PathJavaFileObject) fileObject).getPath();

return getRoots()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ public void addRamPaths(Collection<? extends RamPath> paths) {
*/
public boolean contains(FileObject fileObject) {
// TODO(ascopes): can we get non-path file objects here?

var path = ((PathJavaFileObject) fileObject).getPath();

// While we could just return `Files.isRegularFile` from the start,
Expand All @@ -254,12 +253,6 @@ public boolean contains(FileObject fileObject) {
* @throws IllegalArgumentException if an absolute-style path is provided.
*/
public Optional<? extends Path> findFile(String path) {
var relativePath = Path.of(path);

if (relativePath.isAbsolute()) {
throw new IllegalArgumentException("Cannot use absolute paths here");
}

for (var root : roots) {
var fullPath = root.resolve(path);

Expand Down
Loading