From 2f9c5c9fdda7e9fb7a11cf0aec685a624be833b0 Mon Sep 17 00:00:00 2001 From: YadavAkhileshh Date: Fri, 20 Feb 2026 01:24:27 +0530 Subject: [PATCH 1/2] feat(ci): add Docker-based Java code generation testing --- .github/docker/codegen-tests/java/Dockerfile | 13 +++++++ .../docker/codegen-tests/java/test-java.sh | 39 +++++++++++++++++++ .github/workflows/test-java-codegen.yml | 35 +++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 .github/docker/codegen-tests/java/Dockerfile create mode 100644 .github/docker/codegen-tests/java/test-java.sh create mode 100644 .github/workflows/test-java-codegen.yml diff --git a/.github/docker/codegen-tests/java/Dockerfile b/.github/docker/codegen-tests/java/Dockerfile new file mode 100644 index 0000000..00f30cb --- /dev/null +++ b/.github/docker/codegen-tests/java/Dockerfile @@ -0,0 +1,13 @@ +FROM eclipse-temurin:11-jdk-jammy + +WORKDIR /test + +RUN apt-get update && apt-get install -y curl && \ + curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN echo '#!/bin/bash\nset -e\necho "Testing Java codegen..."\njavac -version\nnode --version\necho "✅ Environment ready!"' > /test/run.sh && chmod +x /test/run.sh + +CMD ["/test/run.sh"] \ No newline at end of file diff --git a/.github/docker/codegen-tests/java/test-java.sh b/.github/docker/codegen-tests/java/test-java.sh new file mode 100644 index 0000000..1a74b93 --- /dev/null +++ b/.github/docker/codegen-tests/java/test-java.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +echo "Testing Java code generation..." + +mkdir -p /test/output +cd /test/output + +cat > test.cto << 'EOF' +namespace test@1.0.0 + +concept Person { + o String name + o Integer age +} +EOF + +echo "Generated test CTO file:" +cat test.cto + +cd /test +npm install + +echo "Generating Java code..." +node -e " +const { CodeGen } = require('@accordproject/concerto-codegen'); +const fs = require('fs'); +const cto = fs.readFileSync('/test/output/test.cto', 'utf8'); +const codeGen = new CodeGen(cto); +const javaCode = codeGen.generate('Java'); +fs.writeFileSync('/test/output/Person.java', javaCode); +" + +echo "Compiling generated Java code..." +cd /test/output +javac *.java + +echo "Java code generation and compilation successful!" +ls -la *.class \ No newline at end of file diff --git a/.github/workflows/test-java-codegen.yml b/.github/workflows/test-java-codegen.yml new file mode 100644 index 0000000..c579adb --- /dev/null +++ b/.github/workflows/test-java-codegen.yml @@ -0,0 +1,35 @@ +name: Test Java Code Generation + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test-java-codegen: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: npm run build + + - name: Build Docker image for Java testing + run: | + docker build -t concerto-java-test -f .github/docker/codegen-tests/java/Dockerfile . + + - name: Test Java code generation in Docker + run: | + docker run --rm \ + -v "$(pwd):/test" \ + concerto-java-test \ No newline at end of file From 1adff6c7348d532894ef8475717a3b471d5342ba Mon Sep 17 00:00:00 2001 From: YadavAkhileshh Date: Fri, 20 Feb 2026 01:34:06 +0530 Subject: [PATCH 2/2] fix(ci): fix Docker CMD to not rely on external script file --- .github/docker/codegen-tests/java/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/docker/codegen-tests/java/Dockerfile b/.github/docker/codegen-tests/java/Dockerfile index 00f30cb..dec6dba 100644 --- a/.github/docker/codegen-tests/java/Dockerfile +++ b/.github/docker/codegen-tests/java/Dockerfile @@ -8,6 +8,4 @@ RUN apt-get update && apt-get install -y curl && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN echo '#!/bin/bash\nset -e\necho "Testing Java codegen..."\njavac -version\nnode --version\necho "✅ Environment ready!"' > /test/run.sh && chmod +x /test/run.sh - -CMD ["/test/run.sh"] \ No newline at end of file +CMD ["bash", "-c", "echo 'Testing environment...' && javac -version && node --version && echo '✅ Java + Node.js ready!'"] \ No newline at end of file