Skip to content
Draft
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 .github/scripts/check-surefire-reports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ while IFS= read -r source; do
if grep -qE 'abstract[[:space:]]+class|@interface' "$source"; then
continue
fi
# Runs only from regenerate.sh, as it rewrites committed Check output.
if [[ $source == com.avaloq.tools.ddk.check.regenerate/* ]]; then
continue
fi
expected=$((expected + 1))
module=${source%%/*}
class=${source#*/src/}
Expand Down
11 changes: 9 additions & 2 deletions .github/scripts/regenerate.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
# Checks that every tracked MWE2 workflow has an Eclipse launch, then runs the workflows headless, without Eclipse,
# except those listed below. In Eclipse, run a workflow's launch instead; this script must reproduce its output.
# except those listed below, then the Check builder: a clean build, in an Eclipse workbench started by Maven, of the projects
# with Check settings (com.avaloq.tools.ddk.check.regenerate). In Eclipse, run a workflow's launch, or clean the projects
# in a runtime workbench, instead; this script must reproduce their output. On Linux without a display, use xvfb-run.
# Build first, on JDK 21, and again after changing a grammar or generator:
# ./mvnw install -DskipTests -f ddk-parent/pom.xml -pl ":ddk-target,$(.github/scripts/regenerate.sh --owners)" -am -Dtycho.baseline=disable -Dtycho.baseline.replace=none
# Arguments are passed to Maven, e.g. -Dmaven.repo.local=...; --owners prints the owning bundles as a -pl list, --list the workflows it runs.
Expand Down Expand Up @@ -57,8 +59,9 @@ for wf in "${WORKFLOWS[@]}"; do
done

projects=$(printf ',:%s' "${bundles[@]}")
check_build=com.avaloq.tools.ddk.check.regenerate
if [[ ${1-} == --owners ]]; then
echo "${projects:1}"
echo "${projects:1},:$check_build"
exit 0
fi
if [[ ${1-} == --list ]]; then
Expand Down Expand Up @@ -103,3 +106,7 @@ if (( ${#failed[@]} )); then
printf 'regenerate.sh: workflow failed: %s\n' "${failed[@]}" >&2
exit 1
fi

# Runs after the workflows, as the Check output depends on the grammars, so the tree may already be dirty.
./mvnw -f ddk-parent/pom.xml --batch-mode -pl ":$check_build" "$@" \
-Dcheck.regenerate.skip=false -Djgit.dirtyWorkingTree=warning verify
3 changes: 2 additions & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ jobs:
# Maven must finish before the workflows dirty the tree.
run: ./mvnw install -DskipTests -f ./ddk-parent/pom.xml -pl ":ddk-target,$(bash .github/scripts/regenerate.sh --owners)" -am --batch-mode -T 2 -Dtycho.baseline=disable -Dtycho.baseline.replace=none
- name: Regenerate sources
run: bash .github/scripts/regenerate.sh
# The Check builder runs in an Eclipse workbench, which needs a display.
run: xvfb-run bash .github/scripts/regenerate.sh
- name: Fail on generated sources out of sync
run: |
git status --porcelain --untracked-files=all
Expand Down
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ git status
```
A new workflow is checked automatically, and the job builds its owning bundle from `--owners`. Add to `KNOWN_DRIFT` only with an issue that removes the entry again.

The Check builder writes the output of `.check` catalogs (Java in `dsl-gen/`, `docs/content/`, `META-INF/services/`, `plugin.xml` extensions) when Eclipse builds a project with the Xtext nature. Regenerate it in a runtime workbench (`ddk-configuration/launches/devkit-run.launch`): import the project and clean it. `regenerate.sh` reproduces this after the workflows: the test of `com.avaloq.tools.ddk.check.regenerate` imports every project with `.settings/com.avaloq.tools.ddk.check.Check.prefs` into a workbench at its location in the repository, cleans and builds it, and fails on build errors. It needs a display (`xvfb-run` on Linux) and runs only with `-Dcheck.regenerate.skip=false`, which the script sets. A project with Check catalogs needs the Xtext nature and builder, and the bundles it requires in that module's manifest.

### Bumping Versions
CI fails with "Only qualifier changed" when a published bundle or feature differs from the last release (`p2/releases/latest`) but keeps its version.
1. Changing a published bundle (one included in the features, incl. `test.core`, `test.ui`, `xtext.test.core`): its version on `master` must reflect the strongest change since the last release, so it is bumped at most once per level between releases, not once per PR.
Expand Down
7 changes: 7 additions & 0 deletions com.avaloq.tools.ddk.check.regenerate/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
75 changes: 75 additions & 0 deletions com.avaloq.tools.ddk.check.regenerate/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.avaloq.tools.ddk.check.regenerate</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
<linkedResources>
<link>
<name>.checkstyle</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.checkstyle</locationURI>
</link>
<link>
<name>.fbprefs</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.fbprefs</locationURI>
</link>
<link>
<name>.pmd</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.pmd</locationURI>
</link>
<link>
<name>.settings/edu.umd.cs.findbugs.plugin.eclipse.prefs</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.settings/edu.umd.cs.findbugs.plugin.eclipse.prefs</locationURI>
</link>
<link>
<name>.settings/org.eclipse.core.resources.prefs</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.core.resources.prefs</locationURI>
</link>
<link>
<name>.settings/org.eclipse.core.runtime.prefs</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.core.runtime.prefs</locationURI>
</link>
<link>
<name>.settings/org.eclipse.jdt.core.prefs</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.jdt.core.prefs</locationURI>
</link>
<link>
<name>.settings/org.eclipse.jdt.ui.prefs</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.jdt.ui.prefs</locationURI>
</link>
<link>
<name>.settings/org.eclipse.pde.core.prefs</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ddk-configuration/.settings/org.eclipse.pde.core.prefs</locationURI>
</link>
</linkedResources>
</projectDescription>
Empty file.
31 changes: 31 additions & 0 deletions com.avaloq.tools.ddk.check.regenerate/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.avaloq.tools.ddk.check.regenerate
Bundle-SymbolicName: com.avaloq.tools.ddk.check.regenerate
Bundle-Version: 17.3.1.qualifier
Bundle-Vendor: Avaloq Group AG
Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.jdt.core,
org.eclipse.pde.core,
org.eclipse.xtext.builder,
org.eclipse.xtext.ui.shared,
com.avaloq.tools.ddk.check.ui,
com.avaloq.tools.ddk.check.core,
com.avaloq.tools.ddk.check.lib,
com.avaloq.tools.ddk.check.runtime.core,
com.avaloq.tools.ddk.xtext,
com.avaloq.tools.ddk.xtext.generator,
org.eclipse.xtext.xtext.generator,
org.eclipse.xtext.ide,
org.eclipse.xtext.xbase,
org.eclipse.xtext.common.types,
org.eclipse.emf.codegen.ecore,
org.eclipse.emf.mwe.utils,
org.eclipse.emf.mwe2.launch,
org.antlr.runtime,
junit-jupiter-api
Import-Package: org.apache.log4j,
org.apache.logging.log4j
Automatic-Module-Name: com.avaloq.tools.ddk.check.regenerate
4 changes: 4 additions & 0 deletions com.avaloq.tools.ddk.check.regenerate/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
36 changes: 36 additions & 0 deletions com.avaloq.tools.ddk.check.regenerate/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ddk-parent</artifactId>
<groupId>com.avaloq.tools.ddk</groupId>
<version>18.0.1-SNAPSHOT</version>
<relativePath>../ddk-parent</relativePath>
</parent>
<version>17.3.1-SNAPSHOT</version>

<artifactId>com.avaloq.tools.ddk.check.regenerate</artifactId>
<packaging>eclipse-test-plugin</packaging>

<properties>
<tycho.surefire.useUIHarness>true</tycho.surefire.useUIHarness>
<test.reactorConcurrencyLevel>1</test.reactorConcurrencyLevel>
<!-- Rewrites committed Check output in place; .github/scripts/regenerate.sh sets it to false. -->
<check.regenerate.skip>true</check.regenerate.skip>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<skipTests>${check.regenerate.skip}</skipTests>
<systemProperties>
<ddk.root>${project.basedir}/..</ddk.root>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*******************************************************************************
* Copyright (c) 2026 Avaloq Group AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Avaloq Group AG - initial API and implementation
*******************************************************************************/
package com.avaloq.tools.ddk.check.regenerate;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.jobs.Job;
import org.junit.jupiter.api.Test;


/**
* Regenerates the Check builder's output of the repository's projects in place, as a clean build of them in an Eclipse
* workbench does. Projects with Check settings are imported, cleaned and built; build errors fail the run.
* <p>
* Skipped unless {@code check.regenerate.skip=false}, which {@code .github/scripts/regenerate.sh} sets.
*/
@SuppressWarnings("nls")
public class RegenerateCheckOutputTest {

private static final String CHECK_SETTINGS = ".settings/com.avaloq.tools.ddk.check.Check.prefs";
private static final IPath MAVEN_OUTPUT = IPath.fromOSString("target");
private static final long IDLE_TIMEOUT_MILLIS = 600_000;
private static final long IDLE_POLL_MILLIS = 100;

/**
* Cleans and builds the projects with Check settings.
*
* @throws CoreException
* if a project cannot be imported or built
* @throws IOException
* if the repository cannot be listed
* @throws InterruptedException
* if interrupted while waiting for the build
*/
@Test
public void testRegenerate() throws CoreException, IOException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
List<IProject> projects = importProjects(workspace, Path.of(System.getProperty("ddk.root")));
assertFalse(projects.isEmpty(), "projects with Check settings");
try {
waitUntilIdle();
workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
waitUntilIdle();
workspace.build(IncrementalProjectBuilder.FULL_BUILD, null);
waitUntilIdle();
List<String> errors = new ArrayList<>();
for (IProject project : projects) {
for (IMarker marker : project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)) {
// Maven's copies of the sources under target/ are not the project's sources.
if (marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO) == IMarker.SEVERITY_ERROR
&& !MAVEN_OUTPUT.isPrefixOf(marker.getResource().getProjectRelativePath())) {
errors.add(marker.getResource().getFullPath() + ":" + marker.getAttribute(IMarker.LINE_NUMBER, -1) + ": " + marker.getAttribute(IMarker.MESSAGE, ""));
}
}
}
assertTrue(errors.isEmpty(), "build errors:\n" + String.join("\n", errors));
} finally {
for (IProject project : projects) {
project.delete(false, true, null);
}
}
}

/**
* Imports the repository's projects with Check settings into the workspace, at their location in the repository.
*
* @param workspace
* the workspace
* @param root
* the repository root
* @return the imported projects
* @throws CoreException
* if a project cannot be imported
* @throws IOException
* if the repository cannot be listed
*/
private static List<IProject> importProjects(final IWorkspace workspace, final Path root) throws CoreException, IOException {
List<IProject> projects = new ArrayList<>();
try (Stream<Path> children = Files.list(root)) {
for (Path dir : children.filter(d -> Files.isRegularFile(d.resolve(CHECK_SETTINGS))).sorted().toList()) {
IProjectDescription description = workspace.loadProjectDescription(IPath.fromPath(dir.resolve(".project")));
IProject project = workspace.getRoot().getProject(description.getName());
project.create(description, null);
project.open(null);
projects.add(project);
}
}
return projects;
}

/**
* Waits until no jobs run, so that classpath containers are resolved and builds are finished.
*
* @throws InterruptedException
* if interrupted while waiting
*/
private static void waitUntilIdle() throws InterruptedException {
long deadline = System.currentTimeMillis() + IDLE_TIMEOUT_MILLIS;
while (!Job.getJobManager().isIdle()) {
assertTrue(System.currentTimeMillis() < deadline, "jobs still running after " + IDLE_TIMEOUT_MILLIS + " ms");
Thread.sleep(IDLE_POLL_MILLIS);
}
}
}
Loading