Skip to content

Commit

Permalink
feat: setup kclvm in github action
Browse files Browse the repository at this point in the history
  • Loading branch information
chai2010 committed May 17, 2022
1 parent d28475b commit 111341e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ jobs:
files: |
./_build/bundles/kusion-linux.tgz
./_build/bundles/kusion-darwin.tgz
./_build/bundles/kusion-darwin-arm64.tgz
./_build/bundles/kusion-linux.tgz.md5.txt
./_build/bundles/kusion-darwin.tgz.md5.txt
./_build/bundles/kusion-darwin-arm64.tgz.md5.txt
# todo:
# ./_build/bundles/kusion-darwin-arm64.tgz
# ./_build/bundles/kusion-darwin-arm64.tgz.md5.txt

# <--- End --->
9 changes: 7 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
push:
branches:
- main

jobs:
Test:
name: Unit tests with coverage
Expand All @@ -22,6 +21,12 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.17

- run: make build-local-linux-all
- run: echo "${PWD}/_build/bundles/kusion-linux/kclvm/bin" >> $GITHUB_PATH
- run: which kclvm
- run: go run ./cmd/kcl-go kcl

- name: Running go tests with coverage
env:
GO111MODULE: on
Expand Down Expand Up @@ -50,4 +55,4 @@ jobs:
env:
GO111MODULE: on
GOPATH: /home/runner/work/
run: GOLINTER=./golangci-lint-1.41.0-linux-amd64/golangci-lint make lint
run: GOLINTER=./golangci-lint-1.41.0-linux-amd64/golangci-lint make lint
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COVER_FILE ?= coverage.out
SOURCE_PATHS ?= ./pkg/...

# TODO: fix mirrors
KCLVM_URL_BASE_MIRRORS:=http://127.0.0.1:8000/downloads
KCLVM_URL_BASE_MIRRORS:=

.DEFAULT_GOAL := help

Expand Down Expand Up @@ -63,7 +63,8 @@ clean: ## Clean build bundles
-rm -f ./pkg/version/z_update_version.go
-rm -rf ./_build/bundles

build-all: build-local-darwin-all build-local-darwin-arm64-all build-local-linux-all ## build-local-windows-all ## Build all platforms (darwin, linux, windows)
# todo: fix macOS-arm64 and windows build
build-all: build-local-darwin-all build-local-linux-all ## build-local-darwin-arm64-all build-local-windows-all ## Build all platforms (darwin, linux, windows)

build-local-kusion-darwin: ## Build kusionctl only for macOS
# Delete old artifacts
Expand Down Expand Up @@ -104,7 +105,7 @@ build-local-darwin: ## Build kusion tool chain for macOS
build-local-darwin-all: build-local-darwin ## Build kusion & kcl tool chain for macOS
# Install kclvm darwin
go run ./scripts/install-kclvm \
--triple=kclvm-Darwin \
--triple=Darwin \
--mirrors=${KCLVM_URL_BASE_MIRRORS} \
--outdir=./_build/bundles/kusion-darwin/kclvm

Expand Down Expand Up @@ -160,7 +161,7 @@ build-local-darwin-arm64: ## Build kusion tool chain for macOS arm64
build-local-darwin-arm64-all: build-local-darwin-arm64 ## Build kusion & kcl tool chain for macOS arm64
# Install kclvm darwin
go run ./scripts/install-kclvm \
--triple=kclvm-Darwin-arm64 \
--triple=Darwin-arm64 \
--mirrors=${KCLVM_URL_BASE_MIRRORS} \
--outdir=./_build/bundles/kusion-darwin-arm64/kclvm

Expand Down Expand Up @@ -222,7 +223,7 @@ build-local-linux: ## Build kusion tool chain for linux
build-local-linux-all: build-local-linux ## Build kusion & kcl tool chain for linux
# Install kclvm linux
go run ./scripts/install-kclvm \
--triple=kclvm-ubuntu \
--triple=ubuntu \
--mirrors=${KCLVM_URL_BASE_MIRRORS} \
--outdir=./_build/bundles/kusion-linux/kclvm

Expand Down Expand Up @@ -278,7 +279,7 @@ build-local-windows: ## Build kusion tool chain for windows
build-local-windows-all: build-local-windows ## Build kusion & kcl tool chain for windows
# Install kclvm windows
go run ./scripts/install-kclvm \
--triple=kclvm-windows \
--triple=windows \
--mirrors=${KCLVM_URL_BASE_MIRRORS} \
--outdir=./_build/bundles/kusion-windows/kclvm

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ require (
k8s.io/component-base v0.21.2
k8s.io/kubectl v0.21.2
kusionstack.io/kcl-plugin v0.4.1-alpha2
kusionstack.io/kclvm-go v0.4.1-alpha9
kusionstack.io/kclvm-go v0.4.2-alpha1
sigs.k8s.io/kustomize/api v0.8.11
sigs.k8s.io/kustomize/kustomize/v4 v4.1.2
sigs.k8s.io/kustomize/kyaml v0.11.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,8 @@ kusionstack.io/kcl-plugin v0.4.1-alpha2 h1:m43JJhpJSjl/Q3FqghJf5dRIwdXsrJeKxrHhg
kusionstack.io/kcl-plugin v0.4.1-alpha2/go.mod h1:VgB7qXVbDGWFOh/qb/yXf75+UrliP5EPXOQUDqBCdAQ=
kusionstack.io/kclvm-go v0.4.1-alpha9 h1:aR9VU1Qnnbu3F5StnOgHB/MJvQwMjT+d9QCZy+oTgyQ=
kusionstack.io/kclvm-go v0.4.1-alpha9/go.mod h1:cxsYIWWMiDk7mwWJMm6H9kzNNtoIpOQHgzJBZvHThzo=
kusionstack.io/kclvm-go v0.4.2-alpha1 h1:jB3xL1NjQh3djzkVOgAAiMqDRV51cil4xK+KlsSnTlU=
kusionstack.io/kclvm-go v0.4.2-alpha1/go.mod h1:cxsYIWWMiDk7mwWJMm6H9kzNNtoIpOQHgzJBZvHThzo=
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
Expand Down
15 changes: 14 additions & 1 deletion scripts/install-kclvm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ func main() {
flag.Usage()
os.Exit(1)
}
if !isValidTriple(*flagTriple) {
fmt.Println("Invalid triple: %q (%v)", *flagTriple, scripts.KclvmTripleList)
os.Exit(1)
}

scripts.DefaultKclvmTriple = *flagTriple
scripts.DefaultKclvmTriple = scripts.KclvmTripleType(*flagTriple)
if s := *flagMirrors; s != "" {
for _, s := range strings.Split(s, ",") {
s := strings.TrimSpace(s)
Expand All @@ -39,3 +43,12 @@ func main() {
os.Exit(1)
}
}

func isValidTriple(triple string) bool {
for _, s := range scripts.KclvmTripleList {
if s == scripts.KclvmTripleType(triple) {
return true
}
}
return false
}

0 comments on commit 111341e

Please sign in to comment.