diff --git a/.github/workflows/build-test-create-starter.yaml b/.github/workflows/build-test-create-starter.yaml new file mode 100644 index 0000000..3e6efdc --- /dev/null +++ b/.github/workflows/build-test-create-starter.yaml @@ -0,0 +1,66 @@ +# Copyright 2025 Oracle Corporation and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at +# https://oss.oracle.com/licenses/upl. + +# --------------------------------------------------------------------------- +# Coherence CLI GitHub Actions CI build - Test Create Starter +# --------------------------------------------------------------------------- +name: CI Test Create Starter + +on: + workflow_dispatch: + push: + branches-ignore: + - gh-pages + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + javaVersion: + - 21 + - 22 + +# Checkout the source, we need a depth of zero to fetch all of the history otherwise +# the copyright check cannot work out the date of the files from Git. + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.javaVersion }} + distribution: 'zulu' + + - name: Cache Go Modules + uses: actions/cache@v4 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-mods- + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: Build cohctl + shell: bash + run: make cohctl + + - name: Run Create Starter Test + shell: bash + run: | + make test-create-starter + + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: test-output-${{ matrix.coherenceVersion }} + path: build/_output/test-logs diff --git a/Makefile b/Makefile index 9f14084..ccd3718 100644 --- a/Makefile +++ b/Makefile @@ -510,6 +510,13 @@ test-discovery: test-clean gotestsum $(BUILD_PROPS) ## Run Discovery tests with test-create-cluster: test-clean gotestsum $(BUILD_PROPS) ## Run create cluster tests ./scripts/test-create-cluster.sh $(COHERENCE_VERSION) +# ---------------------------------------------------------------------------------------------------------------------- +# Executes the Go create starter tests for standalone Coherence +# ---------------------------------------------------------------------------------------------------------------------- +.PHONY: test-create-starter +test-create-starter: test-clean $(BUILD_PROPS) ## Run create starter tests + ./scripts/test-create-starter.sh + # ---------------------------------------------------------------------------------------------------------------------- # Executes the Go monitor cluster tests for standalone Coherence # ---------------------------------------------------------------------------------------------------------------------- diff --git a/pkg/cmd/starter.go b/pkg/cmd/starter.go index 1e46f34..5a5598f 100644 --- a/pkg/cmd/starter.go +++ b/pkg/cmd/starter.go @@ -18,7 +18,7 @@ import ( const ( framework = "framework" frameworkURL = "https://raw.githubusercontent.com/oracle/coherence-cli/refs/heads/main/templates" - frameworkTypesURL = "https://raw.githubusercontent.com/oracle/coherence-cli/refs/heads/main/templates/templates.yaml" + frameworkTypesURL = frameworkURL + "/templates.yaml" ) // FrameworkTemplate contains the contents read from the coherence-cli repository. diff --git a/scripts/test-create-starter.sh b/scripts/test-create-starter.sh new file mode 100755 index 0000000..eb0926c --- /dev/null +++ b/scripts/test-create-starter.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# +# Copyright (c) 2025 Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at +# https://oss.oracle.com/licenses/upl. +# + +# Test various command related to creating starter projects +# environment variables COM and COHERENCE_VERSION accepted + +pwd + + +CONFIG_DIR=/tmp/$$.create.starter +DIR=`pwd` +OUTPUT=/tmp/$$.output +STARTER_DIR=`mktemp -d` +LOGS_DIR=$DIR/build/_output/test-logs + +mkdir -p ${CONFIG_DIR} ${STARTER_DIR} ${LOGS_DIR} +trap "cp ${CONFIG_DIR}/cohctl.log /tmp && rm -rf ${CONFIG_DIR} $OUTPUT" 0 1 2 3 + +echo +echo "Config Dir: ${CONFIG_DIR}" +echo "Starter Dir: ${STARTER_DIR}" +echo "Logs Dir: ${LOGS_DIR}" +echo + +# Default command +COHCTL="$DIR/bin/cohctl --config-dir ${CONFIG_DIR}" + +function runCommand() { + echo "=========================================================" + echo "Running command: cohctl $*" + $COHCTL $* > $OUTPUT 2>&1 + ret=$? + cat $OUTPUT + if [ $ret -ne 0 ] ; then + echo "Command failed" + # copy the log files + save_logs + exit 1 + fi +} + +runCommand version + +cd ${STARTER_DIR} + +function run_test() { + curl -X POST -H "Content-Type: application/json" -d '{"id": 1, "name": "Tim", "balance": 1000}' http://localhost:8080/api/customers + curl -s http://localhost:8080/api/customers/1 + curl -s http://localhost:8080/api/customers + curl -X DELETE http://localhost:8080/api/customers/1 +} + +echo "Testing Helidon Starter" +runCommand create starter helidon-starter -y -f helidon +cd helidon-starter +mvn clean install +java -jar target/helidon.jar > ${LOGS_DIR}/helidon.log 2>&1 & +PID=$! +echo "Sleeping for 30..." +sleep 30 +run_test +kill -9 $PID +cd .. + +echo "Testing Spring Boot Starter" +runCommand create starter springboot-starter -y -f springboot +cd springboot-starter +mvn clean install +java -jar target/springboot-1.0-SNAPSHOT.jar > ${LOGS_DIR}/springboot.log 2>&1 & +PID=$! +echo "Sleeping for 30..." +sleep 30 +run_test +kill -9 $PID +cd .. + +echo "Testing Micronaut Starter" +runCommand create starter micronaut-starter -y -f micronaut +cd micronaut-starter +mvn clean install +java -jar target/micronaut-1.0-SNAPSHOT-shaded.jar > ${LOGS_DIR}/micronaut.log 2>&1 & +PID=$! +echo "Sleeping for 30..." +sleep 30 +run_test +kill -9 $PID +cd .. diff --git a/templates/helidon/src/main/java/com/oracle/coherence/demo/frameworks/helidon/CustomerResource.java b/templates/helidon/src/main/java/com/oracle/coherence/demo/frameworks/helidon/CustomerResource.java index 90f996a..2188d7d 100644 --- a/templates/helidon/src/main/java/com/oracle/coherence/demo/frameworks/helidon/CustomerResource.java +++ b/templates/helidon/src/main/java/com/oracle/coherence/demo/frameworks/helidon/CustomerResource.java @@ -30,7 +30,6 @@ public class CustomerResource { @Inject - @Name("tasks") private NamedMap customers; @POST