Skip to content

Commit

Permalink
feat: update example apps with latest modules
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-hm19 committed Jun 11, 2024
1 parent 56f70a6 commit 63f45fe
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 144 deletions.
192 changes: 96 additions & 96 deletions .github/workflows/apply.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
name: Apply
on:
push:
branches:
- "main"

jobs:
get-changed-project-stack:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install Pytest Html
run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

- name: Git Diff
id: git-diff
uses: technote-space/get-diff-action@v6

- name: Get Changed Projects and Stacks
id: get-changed-projects-and-stacks
env:
CHANGED_PATHS: ${{ steps.git-diff.outputs.diff }}
run: |
export CHANGED_PATHS="${{ steps.git-diff.outputs.diff }}"
python3 hack/get_changed_projects_and_stacks.py
- name: Print Changed Projects and Stacks
run: |
echo "Changed projects: ${{ steps.get-changed-projects-and-stacks.outputs.changed_projects }}"
echo "Changed stacks: ${{ steps.get-changed-projects-and-stacks.outputs.changed_stacks }}"
outputs:
changed_projects: ${{ steps.get-changed-projects-and-stacks.outputs.changed_projects }}
changed_stacks: ${{ steps.get-changed-projects-and-stacks.outputs.changed_stacks }}

apply:
needs: [ get-changed-project-stack ]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Kusion
run: curl https://www.kusionstack.io/scripts/install.sh | sh -s 0.12.0-rc.1

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install Pytest Html
run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

- name: Setup K3d&K3s
uses: nolar/setup-k3d-k3s@v1

- name: Apply
id: apply
env:
CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
OSS_ACCESS_KEY_ID: '${{ secrets.OSS_ACCESS_KEY_ID }}'
OSS_ACCESS_KEY_SECRET: '${{ secrets.OSS_ACCESS_KEY_SECRET }}'
WORKSPACE_FILE_DIR: workspaces
run: |
# manually source kusion env file
source "$HOME/.kusion/.env"
# setup remote backend for kusion cli
kusion config set backends.oss_test '{"type":"oss","configs":{"bucket":"kusion-test","endpoint":"oss-cn-shanghai.aliyuncs.com"}}'
kusion config set backends.current oss_test
# execute python script for applying
python3 hack/apply_changed_stacks.py
- name: Upload Report
id: upload-report
if: ${{ steps.apply.outputs.apply_success == 'true' }}
uses: actions/upload-artifact@v4
with:
name: apply-report
path: hack/report/apply-result.zip

- name: Echo URL
if: ${{ steps.apply.outputs.apply_success == 'true' }}
run: |
echo "Please check the apply result at: ${{ steps.upload-report.outputs.artifact-url }}"
# name: Apply
# on:
# push:
# branches:
# - "main"

# jobs:
# get-changed-project-stack:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: Install Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.9

# - name: Install Pytest Html
# run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

# - name: Git Diff
# id: git-diff
# uses: technote-space/get-diff-action@v6

# - name: Get Changed Projects and Stacks
# id: get-changed-projects-and-stacks
# env:
# CHANGED_PATHS: ${{ steps.git-diff.outputs.diff }}
# run: |
# export CHANGED_PATHS="${{ steps.git-diff.outputs.diff }}"
# python3 hack/get_changed_projects_and_stacks.py

# - name: Print Changed Projects and Stacks
# run: |
# echo "Changed projects: ${{ steps.get-changed-projects-and-stacks.outputs.changed_projects }}"
# echo "Changed stacks: ${{ steps.get-changed-projects-and-stacks.outputs.changed_stacks }}"
# outputs:
# changed_projects: ${{ steps.get-changed-projects-and-stacks.outputs.changed_projects }}
# changed_stacks: ${{ steps.get-changed-projects-and-stacks.outputs.changed_stacks }}

# apply:
# needs: [ get-changed-project-stack ]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: Install Kusion
# run: curl https://www.kusionstack.io/scripts/install.sh | sh -s 0.12.0-rc.1

# - name: Install Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.9

# - name: Install Pytest Html
# run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

# - name: Setup K3d&K3s
# uses: nolar/setup-k3d-k3s@v1

# - name: Apply
# id: apply
# env:
# CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }}
# OSS_ACCESS_KEY_ID: '${{ secrets.OSS_ACCESS_KEY_ID }}'
# OSS_ACCESS_KEY_SECRET: '${{ secrets.OSS_ACCESS_KEY_SECRET }}'
# WORKSPACE_FILE_DIR: workspaces
# run: |
# # manually source kusion env file
# source "$HOME/.kusion/.env"

# # setup remote backend for kusion cli
# kusion config set backends.oss_test '{"type":"oss","configs":{"bucket":"kusion-test","endpoint":"oss-cn-shanghai.aliyuncs.com"}}'
# kusion config set backends.current oss_test

# # execute python script for applying
# python3 hack/apply_changed_stacks.py

# - name: Upload Report
# id: upload-report
# if: ${{ steps.apply.outputs.apply_success == 'true' }}
# uses: actions/upload-artifact@v4
# with:
# name: apply-report
# path: hack/report/apply-result.zip

# - name: Echo URL
# if: ${{ steps.apply.outputs.apply_success == 'true' }}
# run: |
# echo "Please check the apply result at: ${{ steps.upload-report.outputs.artifact-url }}"
4 changes: 3 additions & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
fetch-depth: 0

- name: Install Kusion
run: curl https://www.kusionstack.io/scripts/install.sh | sh -s 0.12.0-rc.1
run: curl https://www.kusionstack.io/scripts/install.sh | sh -s 0.12.0-rc.2

- name: Install Python
uses: actions/setup-python@v4
Expand All @@ -72,6 +72,8 @@ jobs:
OSS_ACCESS_KEY_ID: '${{ secrets.OSS_ACCESS_KEY_ID }}'
OSS_ACCESS_KEY_SECRET: '${{ secrets.OSS_ACCESS_KEY_SECRET }}'
WORKSPACE_FILE_DIR: workspaces
ALICLOUD_REGION: cn-shanghai
AWS_REGION: us-east-1
run: |
# manually source kusion env file
source "$HOME/.kusion/.env"
Expand Down
6 changes: 3 additions & 3 deletions example/nginx/dev/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name = "nginx"
version = "0.1.0"

[dependencies]
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.2.0" }
service = { oci = "oci://ghcr.io/kusionstack/service", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.2.0" }

[profile]
entries = ["main.k"]

7 changes: 3 additions & 4 deletions example/nginx/dev/main.k
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import service
import service.container as c
import network as n

nginx: ac.AppConfiguration {
workload: wl.Service {
workload: service.Service {
containers: {
wordpress: c.Container {
image = "nginx:1.25.2"
Expand All @@ -22,7 +22,6 @@ nginx: ac.AppConfiguration {
n.Port {
port: 80
protocol: "TCP"
public: True
}
]
}
Expand Down
2 changes: 0 additions & 2 deletions example/nginx/project.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# The project basic info
name: nginx
generator:
type: AppConfiguration
6 changes: 3 additions & 3 deletions example/service-multi-stack/base/base.k
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import service
import service.container as c
import network as n

echoserver: ac.AppConfiguration {
workload: wl.Service {
workload: service.Service {
containers: {
"server": c.Container {
image = "<no value>"
Expand Down
5 changes: 3 additions & 2 deletions example/service-multi-stack/dev/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ name = "service-multi-stack-dev"
version = "0.1.0"

[dependencies]
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.2.0" }
service = { oci = "oci://ghcr.io/kusionstack/service", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.2.0" }

[profile]
entries = ["../base/base.k", "main.k"]
Expand Down
5 changes: 3 additions & 2 deletions example/service-multi-stack/prod/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ name = "service-multi-stack-prod"
version = "0.1.0"

[dependencies]
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.2.0" }
service = { oci = "oci://ghcr.io/kusionstack/service", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.2.0" }

[profile]
entries = ["../base/base.k", "main.k"]
Expand Down
2 changes: 0 additions & 2 deletions example/service-multi-stack/project.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# The project basic info
name: service-multi-stack
generator:
type: AppConfiguration
3 changes: 2 additions & 1 deletion example/simple-job/dev/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "simple-job"
version = "0.1.0"

[dependencies]
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.2.0" }
job = { oci = "oci://ghcr.io/kusionstack/job", tag = "0.1.0" }

[profile]
entries = ["main.k"]
Expand Down
6 changes: 3 additions & 3 deletions example/simple-job/dev/main.k
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import job
import job.container as c

helloworld: ac.AppConfiguration {
workload: wl.Job {
workload: job.Job {
containers: {
"busybox": c.Container {
# The target image
Expand Down
2 changes: 0 additions & 2 deletions example/simple-job/project.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# The project basic info
name: simple-job
generator:
type: AppConfiguration
9 changes: 5 additions & 4 deletions example/simple-service/dev/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ name = "simple-service"
version = "0.1.0"

[dependencies]
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }
opsrule = { oci = "oci://ghcr.io/kusionstack/opsrule", tag = "0.1.0" }
monitoring = { oci = "oci://ghcr.io/kusionstack/monitoring", tag = "0.1.0" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.2.0" }
service = { oci = "oci://ghcr.io/kusionstack/service", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.2.0" }
opsrule = { oci = "oci://ghcr.io/kusionstack/opsrule", tag = "0.2.0" }
monitoring = { oci = "oci://ghcr.io/kusionstack/monitoring", tag = "0.2.0" }

[profile]
entries = ["main.k"]
Expand Down
8 changes: 4 additions & 4 deletions example/simple-service/dev/main.k
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import kam.v1.workload.container.probe as p
import service
import service.container as c
import service.container.probe as p
import monitoring as m
import opsrule as o
import network as n

helloworld: ac.AppConfiguration {
workload: wl.Service {
workload: service.Service {
containers: {
"helloworld": c.Container {
image: "gcr.io/google-samples/gb-frontend:v4"
Expand Down
7 changes: 4 additions & 3 deletions example/wordpress-cloud-rds/prod/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ name = "wordpress-cloud-rds"
version = "0.1.0"

[dependencies]
mysql = { oci = "oci://ghcr.io/kusionstack/mysql", tag = "0.1.0" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.1.0" }
kam = { git = "https://github.com/KusionStack/kam.git", tag = "0.2.0" }
service = { oci = "oci://ghcr.io/kusionstack/service", tag = "0.1.0" }
network = { oci = "oci://ghcr.io/kusionstack/network", tag = "0.2.0" }
mysql = { oci = "oci://ghcr.io/kusionstack/mysql", tag = "0.2.0" }

[profile]
entries = ["main.k"]
Expand Down
6 changes: 3 additions & 3 deletions example/wordpress-cloud-rds/prod/main.k
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import kam.v1.app_configuration as ac
import kam.v1.workload as wl
import kam.v1.workload.container as c
import service
import service.container as c
import network as n
import mysql as m

# main.k declares customized configurations for prod stacks.
wordpress: ac.AppConfiguration {
workload: wl.Service {
workload: service.Service {
containers: {
wordpress: c.Container {
image: "wordpress:6.3"
Expand Down
4 changes: 1 addition & 3 deletions example/wordpress-cloud-rds/project.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# The project basic info
name: wordpress-cloud-rds
generator:
type: AppConfiguration
name: wordpress-cloud-rds
Loading

0 comments on commit 63f45fe

Please sign in to comment.