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
112 changes: 112 additions & 0 deletions .github/scripts/regenerate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/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.
# 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.
set -euo pipefail

# Not standalone workflows.
EXCLUDE=(
com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/Ddk.mwe2 # only chains the other workflows
com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/CommonXbase.mwe2 # shared module of the language workflows
com.avaloq.tools.ddk.check.test.runtime/src/com/avaloq/tools/ddk/check/generator/TestLanguageGeneratorMWE.mwe2 # needs targetDir and modelPath
)

# Workflows whose committed output still differs from what they generate, with the issue that fixes each.
KNOWN_DRIFT=(
com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/GenerateExport.mwe2 # #1671
com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/GenerateFormat.mwe2 # #1671
com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/GenerateFormatterTestLanguage.mwe2 # #1671
com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/GenerateCheck.mwe2 # #1671
com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/GenerateCheckCfg.mwe2 # #1671
com.avaloq.tools.ddk.sample.helloworld/src/com/avaloq/tools/ddk/sample/helloworld/GenerateHelloWorld.mwe2 # #1671
com.avaloq.tools.ddk.check.test.runtime/src/com/avaloq/tools/ddk/check/GenerateTestLanguage.mwe2 # #1672
)

root=$(git rev-parse --show-toplevel)
cd "$root"

# <owning bundle>/<workflow path relative to that bundle>, for every tracked workflow not listed above.
skip=" ${EXCLUDE[*]} ${KNOWN_DRIFT[*]-} "
tracked=" $(git ls-files '*.mwe2' | tr '\n' ' ') "
for wf in ${skip}; do
[[ $tracked == *" $wf "* ]] || { echo "regenerate.sh: listed workflow $wf is not tracked" >&2; exit 1; }
done
WORKFLOWS=()
while read -r wf; do
[[ $skip == *" $wf "* ]] || WORKFLOWS+=("$wf")
done < <(git ls-files '*.mwe2')

# Every workflow, drifting or not, needs a tracked Eclipse launch: an MWE2 launch of its owning bundle whose
# argument is the workflow's path in that bundle or its module name.
launches=$(git ls-files -z '*.launch' | xargs -0 grep -l Mwe2LaunchConfigurationType)
missing=()
for wf in "${WORKFLOWS[@]}" ${KNOWN_DRIFT[@]+"${KNOWN_DRIFT[@]}"}; do
b=${wf%%/*}
module=$(sed -n 's/^module \([A-Za-z0-9_.]*\).*/\1/p' "$wf")
found=
while read -r l; do
[[ -n $l ]] && grep -q "PROJECT_ATTR\" value=\"$b\"" "$l" \
&& grep -q -e "PROGRAM_ARGUMENTS\" value=\"${wf#*/}\"" -e "PROGRAM_ARGUMENTS\" value=\"$module\"" "$l" && { found=1; break; }
done <<< "$launches"
[[ -n $found ]] || missing+=("$wf")
done
if (( ${#missing[@]} )); then
printf 'regenerate.sh: no Eclipse launch runs %s\n' "${missing[@]}" >&2
exit 1
fi

bundles=()
for wf in "${WORKFLOWS[@]}"; do
b=${wf%%/*}
[[ " ${bundles[*]-} " == *" $b "* ]] || bundles+=("$b")
done

projects=$(printf ',:%s' "${bundles[@]}")
if [[ ${1-} == --owners ]]; then
echo "${projects:1}"
exit 0
fi
if [[ ${1-} == --list ]]; then
printf '%s\n' "${WORKFLOWS[@]}"
exit 0
fi

# All Maven runs happen before the workflows touch the tree (jgit.dirtyWorkingTree=error in CI).
tycho=$(sed -n 's:.*<tycho.version>\(.*\)</tycho.version>.*:\1:p' ddk-parent/pom.xml)
./mvnw -f ddk-parent/pom.xml --batch-mode -pl "${projects:1}" "$@" \
"org.eclipse.tycho.extras:tycho-dependency-tools-plugin:${tycho}:list-dependencies"

# Classpath: owning bundle, third-party jars, DDK bundles from the reactor's target/classes, ANTLR patch.
for b in "${bundles[@]}"; do
# Not in a command substitution, so set -e stops the script on a missing list or unbuilt bundle.
{
echo "$root/$b/target/classes"
grep -v -e '\.source[-/_]' -e '-sources\.jar$' "$b/target/dependencies-list.txt" | while read -r jar; do
bsn=$(basename "$(dirname "$(dirname "$jar")")")
if [[ $bsn == com.avaloq.tools.ddk* ]]; then
[[ -d "$root/$bsn/target/classes" ]] || { echo "regenerate.sh: $bsn is not built" >&2; exit 1; }
echo "$root/$bsn/target/classes"
else
echo "$jar"
fi
done
echo "$root/com.avaloq.tools.ddk.workflow/antlr-generator-3.2.0-patch.jar"
} | awk '!seen[$0]++' | paste -sd: - > "$b/target/mwe2.cp"
printf -- '-cp "%s"\n' "$(<"$b/target/mwe2.cp")" > "$b/target/mwe2.args"
done

failed=()
for wf in "${WORKFLOWS[@]}"; do
b=${wf%%/*}
echo "::group::${wf##*/}"
# Workflows resolve paths against rootPath = "..", so they run from the owning bundle's directory.
(cd "$root/$b" && "${JAVA_HOME:+$JAVA_HOME/bin/}java" -Xmx3g @target/mwe2.args org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher "${wf#*/}") || failed+=("$wf")
echo "::endgroup::"
done

if (( ${#failed[@]} )); then
printf 'regenerate.sh: workflow failed: %s\n' "${failed[@]}" >&2
exit 1
fi
35 changes: 35 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,38 @@ jobs:
name: tycho-surefire-plugin
path: com.avaloq.tools.ddk.*/target/work/data/.metadata/.log
include-hidden-files: true
generated-sources:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Full history for Tycho's jgit build-qualifier, as in maven-verify.
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: 'temurin'
java-version: '21'
- name: Restore Maven dependency cache
# Path and key must mirror maven-verify and snapshot.yml exactly.
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-publish-${{ hashFiles('**/pom.xml', '**/*.target') }}
restore-keys: ${{ runner.os }}-maven-publish-
- name: Drop cached p2 metadata for the DDK update site
# See maven-verify.
run: rm -rf ~/.m2/repository/.cache/tycho/https/dsldevkit.github.io ~/.m2/repository/.cache/tycho/https/ddk.tools.avaloq.com
- name: Build the bundles owning the workflows
# 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
- name: Fail on generated sources out of sync
run: |
git status --porcelain --untracked-files=all
if [ -n "$(git status --porcelain --untracked-files=all)" ]; then
git diff
echo "::error::Generated sources differ from their generators; run the workflow's .mwe2.launch in Eclipse (or .github/scripts/regenerate.sh) and commit the result."
exit 1
fi
11 changes: 11 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ These directories contain generated code - do not edit manually:
xvfb-run ./mvnw verify -f ./ddk-parent/pom.xml -pl :com.avaloq.tools.ddk.xtext.test
```

### Regenerating Sources
Regenerate in Eclipse: every tracked MWE2 workflow has an MWE2 launch (`git ls-files '*.launch'`); run it from the IDE and commit the result. Eclipse output is the reference: `.github/scripts/regenerate.sh` must reproduce it, and when the two differ, fix the script, not the committed files.

`.github/scripts/regenerate.sh` fails if a workflow has no launch, then runs every tracked workflow without Eclipse, except those in its `EXCLUDE` (not standalone) and `KNOWN_DRIFT` (output not yet in sync, each with its issue) arrays; `--list` prints the ones it runs. The `generated-sources` job in `verify.yml` runs it and fails if the result differs from the committed files. The workflows read grammars and generators from `target/classes`, so build the owning bundles with `install` first, on JDK 21, and again after changing a grammar or generator. `install` writes DDK snapshots to the local Maven repository; add `-Dmaven.repo.local=...` to both commands to keep them out of `~/.m2`. Script arguments are passed to Maven:
```bash
./mvnw install -DskipTests -f ./ddk-parent/pom.xml -pl ":ddk-target,$(.github/scripts/regenerate.sh --owners)" -am -Dtycho.baseline=disable -Dtycho.baseline.replace=none
.github/scripts/regenerate.sh
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.

### 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/checkcfg/GenerateCheckCfg.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.checkcfg.core"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/workflow/GenerateCheckCfg.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx3g"/>
</launchConfiguration>
14 changes: 14 additions & 0 deletions com.avaloq.tools.ddk.workflow/GenerateExport.mwe2.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.avaloq.tools.ddk.workflow"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/workflow/GenerateExport.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx3g"/>
</launchConfiguration>
14 changes: 14 additions & 0 deletions com.avaloq.tools.ddk.workflow/GenerateExpression.mwe2.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.avaloq.tools.ddk.workflow"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/workflow/GenerateExpression.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx3g"/>
</launchConfiguration>
14 changes: 14 additions & 0 deletions com.avaloq.tools.ddk.workflow/GenerateFormat.mwe2.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.avaloq.tools.ddk.workflow"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/workflow/GenerateFormat.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx3g"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.avaloq.tools.ddk.workflow"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/workflow/GenerateFormatterTestLanguage.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx3g"/>
</launchConfiguration>
14 changes: 14 additions & 0 deletions com.avaloq.tools.ddk.workflow/GenerateScope.mwe2.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.avaloq.tools.ddk.workflow"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/workflow/GenerateScope.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx3g"/>
</launchConfiguration>
14 changes: 14 additions & 0 deletions com.avaloq.tools.ddk.workflow/ModelInference.mwe2.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.avaloq.tools.ddk.workflow"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/workflow/ModelInference.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx3g"/>
</launchConfiguration>
14 changes: 14 additions & 0 deletions com.avaloq.tools.ddk.workflow/TypeModel.mwe2.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.avaloq.tools.ddk.workflow"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/com/avaloq/tools/ddk/workflow/TypeModel.mwe2"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.avaloq.tools.ddk.workflow"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx3g"/>
</launchConfiguration>
13 changes: 13 additions & 0 deletions com.avaloq.tools.ddk.workflow/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<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>
<groupId>com.avaloq.tools.ddk</groupId>
<artifactId>com.avaloq.tools.ddk.workflow</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
7 changes: 6 additions & 1 deletion ddk-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<module>../com.avaloq.tools.ddk.sample.helloworld.ui.test</module>
<module>../com.avaloq.tools.ddk.typesystem</module>
<module>../com.avaloq.tools.ddk.typesystem.test</module>
<module>../com.avaloq.tools.ddk.workflow</module>
</modules>

<distributionManagement>
Expand Down Expand Up @@ -238,7 +239,11 @@
<configuration>
<timestampProvider>jgit</timestampProvider>
<jgit.dirtyWorkingTree>${jgit.dirtyWorkingTree}</jgit.dirtyWorkingTree>
<jgit.ignore>.project</jgit.ignore> <!-- not packaged, so it must not change the qualifier -->
<!-- not packaged, so they must not change the qualifier -->
<jgit.ignore>
.project
*.launch
</jgit.ignore>
<format>'v'yyyyMMdd-HHmm</format>
<archive>
<manifestEntries>
Expand Down