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
56 changes: 56 additions & 0 deletions .github/workflows/build-test-create-starter-polyglot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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 Polyglot
# ---------------------------------------------------------------------------
name: CI Test Create Starter PolyGlot

on:
workflow_dispatch:
push:
branches-ignore:
- gh-pages

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false

# 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: 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.24'

- name: Build cohctl
shell: bash
run: make cohctl

- name: Run Create Starter Test Polyglot
shell: bash
run: |
make test-create-starter-polyglot

- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-output-${{ matrix.coherenceVersion }}
path: build/_output/test-logs
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ release/
test/test_utils/certs/

utils/linkcheck/go.sum

# Examples noise
node_modules
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ copyright: getcopyright ## Check copyright headers
-X /Dockerfile \
-X .Dockerfile \
-X go.sum \
-X ./templates/javascript/node_modules \
-X HEADER.txt \
-X .iml \
-X .jar \
Expand Down Expand Up @@ -512,12 +513,19 @@ test-create-cluster: test-clean gotestsum $(BUILD_PROPS) ## Run create cluster t
./scripts/test-create-cluster.sh $(COHERENCE_VERSION)

# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go create starter tests for standalone Coherence
# Executes the 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 create starter tests for Polyglot clients
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-create-starter-polyglot
test-create-starter-polyglot: test-clean $(BUILD_PROPS) ## Run create starter tests
./scripts/test-create-starter-polyglot.sh

# ----------------------------------------------------------------------------------------------------------------------
# Executes the Go monitor cluster tests for standalone Coherence
# ----------------------------------------------------------------------------------------------------------------------
Expand Down
38 changes: 30 additions & 8 deletions pkg/cmd/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package cmd

import (
"errors"
"fmt"
"github.com/oracle/coherence-cli/pkg/utils"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -37,6 +38,9 @@ var (
frameworkTypeParam string
validFrameworks = []string{"helidon", "springboot", "micronaut"}

languageTypeParam string
validLanguages = []string{"python", "javascript", "go"}

commonInstructions = `
Add customers:
curl -X POST -H "Content-Type: application/json" -d '{"id": 1, "name": "Tim", "balance": 1000}' http://localhost:8080/api/customers
Expand All @@ -59,12 +63,13 @@ Note: you will see log messages shown for registered event listeners for insert,
var createStarterCmd = &cobra.Command{
Use: "starter project-name",
Short: "creates a starter project for Coherence",
Long: `The 'create starter' command creates a starter Maven project to use Coherence
with various frameworks including Helidon, Spring Boot and Micronaut. A directory
Long: `The 'create starter' command creates a starter project to use Coherence
with various frameworks or languages. You can choose frameworks including: Helidon, Spring Boot and Micronaut,
or languages including python, javascript or go. A directory
will be created off the current directory with the same name as the project name.
NOTE: This is an experimental feature only and the projects created are not fully
completed applications. They are a demo/example of how to do basic integration with
each of the frameworks.`,
each of the frameworks or languages`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide a project name")
Expand All @@ -82,11 +87,21 @@ each of the frameworks.`,
return fmt.Errorf("invalid project name: %s", projectName)
}

if (frameworkTypeParam == "" && languageTypeParam == "") ||
(frameworkTypeParam != "" && languageTypeParam != "") {
return errors.New("you must provide either a framework type or a framework language")
}

// validate the framework
if !utils.SliceContains(validFrameworks, frameworkTypeParam) {
if frameworkTypeParam != "" && !utils.SliceContains(validFrameworks, frameworkTypeParam) {
return fmt.Errorf("framework must be one of %v", validFrameworks)
}

// validate the language
if languageTypeParam != "" && !utils.SliceContains(validLanguages, languageTypeParam) {
return fmt.Errorf("languages must be one of %v", validLanguages)
}

// check the directory does not exist
if utils.DirectoryExists(projectName) {
return fmt.Errorf("the directory %s already exists", projectName)
Expand All @@ -100,11 +115,18 @@ each of the frameworks.`,
return err
}

selectedValue := frameworkTypeParam
typeDescription := "framework"
if languageTypeParam != "" {
typeDescription = "language"
selectedValue = languageTypeParam
}

// get the template for the framework
template := getTemplate(templates, frameworkTypeParam)
template := getTemplate(templates, selectedValue)

if template == nil {
return fmt.Errorf("unable to find files for framework %s", frameworkTypeParam)
return fmt.Errorf("unable to find files for %s %s", typeDescription, selectedValue)
}

absolutePath, err := filepath.Abs(projectName)
Expand All @@ -114,7 +136,7 @@ each of the frameworks.`,

cmd.Println("\nCreate Starter Project")
cmd.Printf("Project Name: %s\n", projectName)
cmd.Printf("Framework Type: %s\n", frameworkTypeParam)
cmd.Printf("Type: %s\n", selectedValue)
cmd.Printf("Framework Versions: %s\n", template.FrameworkVersion)
cmd.Printf("Project Path %s\n\n", absolutePath)

Expand Down Expand Up @@ -216,6 +238,6 @@ func writeContentToFile(baseDir, fileName, content string) error {

func init() {
createStarterCmd.Flags().StringVarP(&frameworkTypeParam, framework, "f", "", "the framework to create for: helidon, springboot or micronaut")
_ = createStarterCmd.MarkFlagRequired(framework)
createStarterCmd.Flags().StringVarP(&languageTypeParam, "language", "l", "", "the language to create for: python, javascript or go")
createStarterCmd.Flags().BoolVarP(&automaticallyConfirm, "yes", "y", false, confirmOptionMessage)
}
97 changes: 97 additions & 0 deletions scripts/test-create-starter-polyglot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/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 using Polyglot clients

pwd

# Use WORKSPACE directory if running under Jenkins
TEMP_DIR=/tmp
[ ! -z "$WORKSPACE" ] && TEMP_DIR=$WORKSPACE

CONFIG_DIR=${TEMP_DIR}/$$.create.starter
DIR=`pwd`
OUTPUT=${TEMP_DIR}/$$.output
STARTER_DIR=${TEMP_DIR}/$$.starter
LOGS_DIR=$DIR/build/_output/test-logs

mkdir -p ${CONFIG_DIR} ${STARTER_DIR} ${LOGS_DIR}
trap "rm -rf $CONFIG_DIR $OUTPUT $STARTER_DIR" EXIT SIGINT

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"
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 "Start Docker Image"
docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:25.03.1
echo "Sleeping 30..."
sleep 30

echo "Testing Python Starter"
runCommand create starter python-starter -y -l python
cd python-starter
pip install -r requiements.txt
python main.py > ${LOGS_DIR}/python.log 2>&1 &
PID=$!
echo "Sleeping for 30..."
sleep 30
run_test
kill -9 $PID
cd ..

echo "Testing JavaScript Starter"
runCommand create starter javascript-starter -y -l javascript
cd javascript-starter
npm install
node main.js > ${LOGS_DIR}/javascript.log 2>&1 &
PID=$!
echo "Sleeping for 30..."
sleep 30
run_test
kill -9 $PID
cd ..

echo "Testing Go Starter"
runCommand create starter go-starter -y -l go
cd go-starter
go mod tidy
go run main.go > ${LOGS_DIR}/go.log 2>&1 &
PID=$!
echo "Sleeping for 30..."
sleep 30
run_test
kill -9 $PID
cd ..
2 changes: 0 additions & 2 deletions scripts/test-create-starter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ function runCommand() {
cat $OUTPUT
if [ $ret -ne 0 ] ; then
echo "Command failed"
# copy the log files
save_logs
exit 1
fi
}
Expand Down
21 changes: 21 additions & 0 deletions templates/go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// 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.
//

module main.go

go 1.24.4

require github.com/oracle/coherence-go-client/v2 v2.3.1

require (
github.com/google/uuid v1.6.0 // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.26.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
google.golang.org/grpc v1.73.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
)
36 changes: 36 additions & 0 deletions templates/go/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/oracle/coherence-go-client/v2 v2.3.1 h1:DhyWDw7vNeWcbI990E22FLc093Y2ZOhcmv646sFEl9o=
github.com/oracle/coherence-go-client/v2 v2.3.1/go.mod h1:1qVtUmN87JU5D1JduoD0KRzOmhqZ2gJaxsPvmJ+5mEA=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a h1:v2PbRU4K3llS09c7zodFpNePeamkAwG3mPrAery9VeE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok=
google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
Loading
Loading