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
67 changes: 67 additions & 0 deletions .github/actions/env-setup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Kubevela Test Environment Setup Action

A GitHub Actions composite action that sets up a complete testing environment for Kubevela projects with Go, Kubernetes tools, and the Ginkgo testing framework.

## Features

- 🛠️ **System Dependencies**: Installs essential build tools (make, gcc, jq, curl, etc.)
- ☸️ **Kubernetes Tools**: Sets up kubectl and Helm for cluster operations
- 🐹 **Go Environment**: Configurable Go version with module caching
- 📦 **Dependency Management**: Downloads and verifies Go module dependencies
- 🧪 **Testing Framework**: Installs Ginkgo v2 for BDD-style testing

## Usage

```yaml
- name: Setup Kubevela Test Environment
uses: ./path/to/this/action
with:
go-version: '1.23.8' # Optional: Go version (default: 1.23.8)
```

### Example Workflow

```yaml
name: Kubevela Tests
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Test Environment
uses: ./path/to/this/action
with:
go-version: '1.21'

- name: Run Tests
run: |
ginkgo -r ./tests/e2e/
```

## Inputs

| Input | Description | Required | Default | Usage |
|-------|-------------|----------|---------|-------|
| `go-version` | Go version to install and use | No | `1.23.8` | Specify Go version for your project |

## What This Action Installs

### System Tools
- **make**: Build automation tool
- **gcc**: GNU Compiler Collection
- **jq**: JSON processor for shell scripts
- **ca-certificates**: SSL/TLS certificates
- **curl**: HTTP client for downloads
- **gnupg**: GNU Privacy Guard for security

### Kubernetes Ecosystem
- **kubectl**: Kubernetes command-line tool (latest stable)
- **helm**: Kubernetes package manager (latest stable)

### Go Development
- **Go Runtime**: Specified version with module caching enabled
- **Go Modules**: Downloaded and verified dependencies
- **Ginkgo v2.14.0**: BDD testing framework for Go
72 changes: 72 additions & 0 deletions .github/actions/env-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: 'Kubevela Test Environment Setup'
description: 'Sets up complete testing environment for Kubevela with Go, Kubernetes tools, and Ginkgo framework for E2E testing.'

inputs:
go-version:
description: 'Go version to use for testing'
required: false
default: '1.23.8'


runs:
using: 'composite'
steps:
# ========================================================================
# Environment Setup
# ========================================================================
- name: Install system dependencies
shell: bash
run: |
# Update package manager and install essential tools
sudo apt-get update
sudo apt-get install -y \
make \
gcc \
jq \
ca-certificates \
curl \
gnupg

- name: Install kubectl and helm
shell: bash
run: |
# Detect architecture
ARCH=$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')

# Install kubectl
echo "Installing kubectl for architecture: $ARCH"
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${ARCH}/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

# Install helm using the official script (more reliable)
echo "Installing Helm using official script..."
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
rm get_helm.sh

# Verify installations
echo "Verifying installations..."
kubectl version --client
helm version


- name: Setup Go environment
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ inputs.go-version }}
cache: true

- name: Download Go dependencies
shell: bash
run: |
# Download and cache Go module dependencies
go mod download
go mod verify

- name: Install Ginkgo testing framework
shell: bash
run: |
echo "Installing Ginkgo testing framework..."
go install github.com/onsi/ginkgo/v2/ginkgo@v2.14.0
48 changes: 48 additions & 0 deletions .github/workflows/clean-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Clean Branch Check

on:
push:
branches:
- main
- release-*
workflow_dispatch: {}
pull_request:
branches:
- main
- release-*

permissions:
contents: read

jobs:
detect-noop:
runs-on: ubuntu-22.04
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
permissions:
actions: write
steps:
- name: Detect No-op Changes
id: noop
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
paths_ignore: '["**.md", "**.mdx", "**.png", "**.jpg"]'
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
continue-on-error: true

check-diff:
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
submodules: true

- name: Setup Env
uses: ./.github/actions/env-setup

- name: Check Diff
run: make check-diff
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include makefiles/const.mk
include makefiles/dependency.mk

LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
Expand All @@ -19,7 +22,7 @@ tidy:
unit-test: envtest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -v -coverpkg=./... -coverprofile=coverage.txt ./...

lint:
lint: golangci
golangci-lint run ./...

reviewable: generate fmt vet tidy lint
Expand All @@ -28,3 +31,9 @@ reviewable: generate fmt vet tidy lint
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

# check-diff: Execute auto-gen code commands and ensure branch is clean.
check-diff: reviewable
git --no-pager diff
git diff --quiet || ($(ERR) please run 'make reviewable' to include all changes && false)
@$(OK) branch is clean
79 changes: 75 additions & 4 deletions apis/oam/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

workflowv1alpha1 "github.com/kubevela/workflow/api/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
)

// +kubebuilder:object:root=true
Expand All @@ -17,8 +16,8 @@ type Workflow struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Mode *workflowv1alpha1.WorkflowExecuteMode `json:"mode,omitempty"`
workflowv1alpha1.WorkflowSpec `json:",inline"`
Mode *WorkflowExecuteMode `json:"mode,omitempty"`
WorkflowSpec `json:",inline"`
}

// +kubebuilder:object:root=true
Expand All @@ -30,3 +29,75 @@ type WorkflowList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []Workflow `json:"items"`
}

// InputItem defines an input variable of WorkflowStep
type InputItem struct {
ParameterKey string `json:"parameterKey,omitempty"`
From string `json:"from"`
}

// OutputItem defines an output variable of WorkflowStep
type OutputItem struct {
ValueFrom string `json:"valueFrom"`
Name string `json:"name"`
}

// StepOutputs defines output variable of WorkflowStep
type StepOutputs []OutputItem

// StepInputs defines variable input of WorkflowStep
type StepInputs []InputItem

// WorkflowStepMeta contains the meta data of a workflow step
type WorkflowStepMeta struct {
Alias string `json:"alias,omitempty"`
}

// WorkflowStepBase defines the workflow step base
type WorkflowStepBase struct {
// Name is the unique name of the workflow step.
Name string `json:"name,omitempty"`
// Type is the type of the workflow step.
Type string `json:"type"`
// Meta is the meta data of the workflow step.
Meta *WorkflowStepMeta `json:"meta,omitempty"`
// If is the if condition of the step
If string `json:"if,omitempty"`
// Timeout is the timeout of the step
Timeout string `json:"timeout,omitempty"`
// DependsOn is the dependency of the step
DependsOn []string `json:"dependsOn,omitempty"`
// Inputs is the inputs of the step
Inputs StepInputs `json:"inputs,omitempty"`
// Outputs is the outputs of the step
Outputs StepOutputs `json:"outputs,omitempty"`

// Properties is the properties of the step
// +kubebuilder:pruning:PreserveUnknownFields
Properties *runtime.RawExtension `json:"properties,omitempty"`
}

// WorkflowStep defines how to execute a workflow step.
type WorkflowStep struct {
WorkflowStepBase `json:",inline"`
// Mode is only valid for sub steps, it defines the mode of the sub steps
// +nullable
Mode WorkflowMode `json:"mode,omitempty"`
SubSteps []WorkflowStepBase `json:"subSteps,omitempty"`
}

// WorkflowSpec defines workflow steps and other attributes
type WorkflowSpec struct {
Steps []WorkflowStep `json:"steps,omitempty"`
}

// WorkflowMode describes the mode of workflow
type WorkflowMode string

// WorkflowExecuteMode defines the mode of workflow execution
type WorkflowExecuteMode struct {
// Steps is the mode of workflow steps execution
Steps WorkflowMode `json:"steps,omitempty"`
// SubSteps is the mode of workflow sub steps execution
SubSteps WorkflowMode `json:"subSteps,omitempty"`
}
Loading
Loading