Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KOGITO-7579: Knative Workflow - Specify Kogito version #1114

Merged
merged 26 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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: 2 additions & 2 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ runs:
with:
java-version: 11

- name: "Set up GOLANG 1.16"
- name: "Set up GOLANG 1.17"
uses: actions/setup-go@v2
with:
go-version: "1.16"
go-version: "1.17"

- name: "Fetch Git tags"
shell: bash
Expand Down
37 changes: 19 additions & 18 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1134,20 +1134,10 @@ jobs:
password: "${{ secrets.quay_registry_password }}"

kn_plugin_workflow:
env:
KN_PLUGIN_WORKFLOW__quarkusVersion: "2.9.2.Final"

if: ${{ needs.extract_runners.outputs.kn_plugin_workflow == 'true' }}
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
needs: [extract_runners]
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: "Support longpaths (Windows only)"
if: matrix.os == 'windows-latest'
run: git config --system core.longpaths true

- name: "Checkout"
uses: actions/checkout@v2
with:
Expand All @@ -1163,14 +1153,14 @@ jobs:
- name: "Setup environment"
uses: ./.github/actions/setup-env
with:
os: ${{ matrix.os }}
os: ubuntu-latest

- name: "Build"
shell: bash
run: |
pnpm -F @kie-tools/kn-plugin-workflow... build:prod
- name: "Upload Knative CLI Workflow Plugin for Linux (Ubuntu only)"
if: ${{ matrix.os == 'ubuntu-latest' && !inputs.dry_run }}
- name: "Upload Knative CLI Workflow Plugin for Linux"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
Expand All @@ -1180,8 +1170,8 @@ jobs:
asset_name: kn-workflow-linux-amd64-${{ inputs.tag }}
asset_content_type: application/octet-stream

- name: "Upload Knative CLI Workflow Plugin for macOS (macOS only)"
if: ${{ matrix.os == 'macos-latest' && !inputs.dry_run }}
- name: "Upload Knative CLI Workflow Plugin for macOS"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
Expand All @@ -1191,8 +1181,19 @@ jobs:
asset_name: kn-workflow-darwin-amd64-${{ inputs.tag }}
asset_content_type: application/octet-stream

- name: "Upload Knative CLI Workflow Plugin for Windows (Windows only)"
if: ${{ matrix.os == 'windows-latest' && !inputs.dry_run }}
- name: "Upload Knative CLI Workflow Plugin for macOS M1"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
with:
upload_url: ${{ inputs.upload_asset_url }}
asset_path: ./packages/kn-plugin-workflow/dist/kn-workflow-darwin-arm64
asset_name: kn-workflow-darwin-arm64-${{ inputs.tag }}
asset_content_type: application/octet-stream

- name: "Upload Knative CLI Workflow Plugin for Windows"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/staging_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ jobs:
SERVERLESS_LOGIC_SANDBOX__kieSandboxExtendedServicesDownloadUrlMacOs: "${{ inputs.download_asset_url }}/STAGING__kie_sandbox_extended_services_macos_${{ inputs.tag }}.dmg"
SERVERLESS_LOGIC_SANDBOX__kieSandboxExtendedServicesDownloadUrlWindows: "${{ inputs.download_asset_url }}/STAGING__kie_sandbox_extended_services_windows_${{ inputs.tag }}.exe"
SERVERLESS_LOGIC_SANDBOX__kieSandboxExtendedServicesCompatibleVersion: "${{ inputs.tag }}"
KN_PLUGIN_WORKFLOW_quarkusVersion: "2.10.0.Final"
run: |
pnpm -r build:prod

Expand Down Expand Up @@ -562,8 +561,8 @@ jobs:
username: "${{ env.DASHBUILDER__baseImageAccount }}"
password: "${{ secrets.quay_registry_password }}"

- name: "STAGING: Upload Knative CLI Workflow Plugin for Linux (Ubuntu only)"
if: ${{ matrix.os == 'ubuntu-latest' && !inputs.dry_run }}
- name: "STAGING: Upload Knative CLI Workflow Plugin for Linux"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
Expand All @@ -573,8 +572,8 @@ jobs:
asset_name: STAGING__kn-workflow-linux-amd64-${{ inputs.tag }}
asset_content_type: application/octet-stream

- name: "STAGING: Upload Knative CLI Workflow Plugin for macOS (macOS only)"
if: ${{ matrix.os == 'macos-latest' && !inputs.dry_run }}
- name: "STAGING: Upload Knative CLI Workflow Plugin for macOS"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
Expand All @@ -584,8 +583,19 @@ jobs:
asset_name: STAGING__kn-workflow-darwin-amd64-${{ inputs.tag }}
asset_content_type: application/octet-stream

- name: "STAGING: Knative CLI Workflow Plugin for Windows (Windows only)"
if: ${{ matrix.os == 'windows-latest' && !inputs.dry_run }}
- name: "STAGING: Upload Knative CLI Workflow Plugin for macOS M1"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
with:
upload_url: ${{ inputs.upload_asset_url }}
asset_path: ${{ github.workspace }}/kie-tools/packages/kn-plugin-workflow/dist/kn-workflow-darwin-arm64
asset_name: STAGING__kn-workflow-darwin-arm64-${{ inputs.tag }}
asset_content_type: application/octet-stream

- name: "STAGING: Knative CLI Workflow Plugin for Windows"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To start building the KIE Tools project, you're going to need:
- pnpm `7.0.0` _(To install, follow these instructions: https://pnpm.io/installation)_
- Maven `3.8.1`
- Java `11`
- Go `1.16`
- Go `1.17`

\*nix users will also need:

Expand Down
50 changes: 48 additions & 2 deletions packages/kn-plugin-workflow/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
all:
GO111MODULE=on GOOS=windows GOARCH=amd64 go build -ldflags "-X 'github.com/kiegroup/kie-tools/kn-plugin-workflow/pkg/common.QUARKUS_VERSION=$(build-env knPluginWorkflow.quarkusVersion)'" -o dist/kn-workflow-windows-amd64.exe cmd/main.go
#
# Copyright 2022 Red Hat, Inc. and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

BIN := kn-workflow
BIN_DARWIN_AMD64 ?= $(BIN)-darwin-amd64
BIN_DARWIN_ARM64 ?= $(BIN)-darwin-arm64
BIN_LINUX ?= $(BIN)-linux-amd64
BIN_WINDOWS ?= $(BIN)-windows-amd64.exe

QUARKUS_VERSION := $(shell pnpm build-env knPluginWorkflow.quarkusVersion)
KOGITO_VERSION := $(shell pnpm build-env knPluginWorkflow.kogitoVersion)
PLUGIN_VERSION := $(shell pnpm build-env knPluginWorkflow.version)

SET_QUARKUS_VERSION := main.quarkusVersion=$(QUARKUS_VERSION)
SET_KOGITO_VERSION := main.kogitoVersion=$(KOGITO_VERSION)
SET_VERSION := main.pluginVersion=$(PLUGIN_VERSION)
LDFLAGS := "-X $(SET_QUARKUS_VERSION) -X $(SET_KOGITO_VERSION) -X $(SET_VERSION)"

build-all: build-linux build-darwin-amd build-darwin-arm build-win32

build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags $(LDFLAGS) -o ./dist/$(BIN_LINUX) cmd/main.go

build-darwin-amd:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags $(LDFLAGS) -o ./dist/$(BIN_DARWIN_AMD64) cmd/main.go

build-darwin-arm:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags $(LDFLAGS) -o ./dist/$(BIN_DARWIN_ARM64) cmd/main.go

build-win32:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags $(LDFLAGS) -o ./dist/$(BIN_WINDOWS) cmd/main.go

clean:
go clean
rm -rf $(BINARY_PATH)
82 changes: 1 addition & 81 deletions packages/kn-plugin-workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,84 +2,4 @@

`kn-plugin-workflow` is a plugin of the Knative Client, to enable users to quickly set up a local Kogito Serverless Workflow project from the command line.

## Getting Started

Note: In order to use the `workflow` plugin, you must install:

- [Java](https://www.java.com/en/download/help/download_options.html) at least version 11
- [Maven](https://maven.apache.org/install.html) at least version 3.8.1
- [Docker](https://docs.docker.com/engine/install/) (Optional)
- [Podman](https://docs.podman.io/en/latest/) (Optional)
- [Kubernetes CLI `kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl).

### Instalation

You can download the latest binaries from the [Releases](https://github.com/kiegroup/kie-tools/releases) page.

There are two ways to run `kn workflow`:

1. You can run it standalone, just put it on your system path and make sure it is executable.
2. You can install it as a plugin of the `kn` client to run:
- Follow the [documentation](https://github.com/knative/client/blob/main/docs/README.md#installing-kn) to install `kn` CLI if you don't have it
- Copy the `kn-workflow` binary to a directory on your `PATH` (for example, `/usr/local/bin`) and make sure its filename is `kn-workflow`
- On macOS give the ownership to the root user: `sudo chown root: /usr/local/bin/kn-workflow`
- Run `kn plugin list` to verify that the `kn-workflow` plugin is installed successfully

After the plugin is installed, you can use `kn workflow` to run its related subcommands.

## Usage

```
Get up and running with a local Knative environment

Usage:
kn workflow [command]

Available Commands:
build Build a Kogito Serverless Workflow project and generate a container image
completion Generate the autocompletion script for the specified shell
create Create a Kogito Serverless Workflow project
deploy Deploy a Kogito Serverless Workflow project
help Help about any command

Flags:
-h, --help help for kn-workflow
-v, --verbose Print verbose logs

Use "kn workflow [command] --help" for more information about a command.
```

### create

This command will scaffold a new Kogito Serverless Workflow project named "my-project":

```bash
kn workflow create --name my-project
```

### build

Builds a Kogito Serverless Workflow project in the current directory and generate a specific image:

```bash
kn workflow build --image quay.io/mysuer/myproject
```

### deploy

Deploys a Kogito Serverless Workflow project in the current directory (build command is required):

```bash
kn workflow deploy
```

## Building from Source

```bash
git clone [email protected]:kiegroup/kie-tools.git
cd kie-tools
yarn bootstrap
cd packages/kn-plugin-workflow
go mod tidy
yarn build
```
[Read the documentation](https://kiegroup.github.io/kogito-docs/serverlessworkflow/main/tooling/kn-plugin-workflow-overview.html)
14 changes: 12 additions & 2 deletions packages/kn-plugin-workflow/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,22 @@ import (
"fmt"
"os"

"github.com/kiegroup/kie-tools/kn-plugin-workflow/pkg/common"
"github.com/kiegroup/kie-tools/kn-plugin-workflow/pkg/root"
)

var quarkusVersion, kogitoVersion, pluginVersion string

func main() {
err := root.NewRootCommand().Execute()
if err != nil {
cfg := root.RootCmdConfig{
DependenciesVersion: common.DependenciesVersion{
QuarkusVersion: quarkusVersion,
KogitoVersion: kogitoVersion,
},
PluginVersion: pluginVersion,
}

if err := root.NewRootCommand(cfg).Execute(); err != nil {
if err.Error() != "subcommand is required" {
fmt.Fprintln(os.Stderr, err)
}
Expand Down
16 changes: 15 additions & 1 deletion packages/kn-plugin-workflow/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,32 @@
*/

const { varsWithName, getOrDefault, composeEnv } = require("@kie-tools/build-env");
const packageJson = require("@kie-tools/kn-plugin-workflow/package.json");

module.exports = composeEnv([require("@kie-tools/build-env/env")], {
vars: varsWithName({
KN_PLUGIN_WORKFLOW__version: {
name: "KN_PLUGIN_WORKFLOW__version",
default: packageJson.version,
description: "Knative Workflow plugin version",
},
KN_PLUGIN_WORKFLOW__quarkusVersion: {
name: "KN_PLUGIN_WORKFLOW__quarkusVersion",
default: "2.10.0.Final",
description: "version to be used when creating the Quarkus workflow project",
description: "Quarkus version to be used when creating the Kogito Serverless Workflow project",
},
KN_PLUGIN_WORKFLOW__kogitoVersion: {
name: "KN_PLUGIN_WORKFLOW__kogitoVersion",
default: "1.24.0.Final",
description: "Kogito version to be used when creating the Kogito Serverless Workflow project",
},
}),
get env() {
return {
knPluginWorkflow: {
version: getOrDefault(this.vars.KN_PLUGIN_WORKFLOW__version),
quarkusVersion: getOrDefault(this.vars.KN_PLUGIN_WORKFLOW__quarkusVersion),
kogitoVersion: getOrDefault(this.vars.KN_PLUGIN_WORKFLOW__kogitoVersion),
},
};
},
Expand Down
1 change: 1 addition & 0 deletions packages/kn-plugin-workflow/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/briandowns/spinner v1.18.1
github.com/ory/viper v1.7.5
github.com/spf13/cobra v1.4.0
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand Down
2 changes: 2 additions & 0 deletions packages/kn-plugin-workflow/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 8 additions & 6 deletions packages/kn-plugin-workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
"url": "https://github.com/kiegroup/kie-tools.git"
},
"scripts": {
"install": "go mod tidy",
"build": "run-script-os",
"build:linux": "GOOS=linux GOARCH=amd64 go build -ldflags \"-X 'github.com/kiegroup/kie-tools/kn-plugin-workflow/pkg/common.QUARKUS_VERSION=$(build-env knPluginWorkflow.quarkusVersion)'\" -o dist/kn-workflow-linux-amd64 cmd/main.go",
"build:darwin": "GO111MODULE=on GOOS=darwin GOARCH=amd64 go build -ldflags \"-X 'github.com/kiegroup/kie-tools/kn-plugin-workflow/pkg/common.QUARKUS_VERSION=$(build-env knPluginWorkflow.quarkusVersion)'\" -o dist/kn-workflow-darwin-amd64 cmd/main.go",
"build:win32": "make",
"build:all": "make build-all",
"build:linux": "make build-linux",
"build:darwin": "make build-darwin-amd",
"build:darwin:arm": "make build-darwin-arm",
"build:win32": "make build-win32",
"build:dev": "rimraf dist && pnpm build",
"build:prod": "rimraf dist && pnpm build"
"build:prod": "rimraf dist && pnpm build:all"
},
"devDependencies": {
"@kie-tools/build-env": "0.0.0",
"@kie-tools-core/run-script-if": "0.0.0"
"@kie-tools/build-env": "0.0.0"
}
}
Loading