mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
205 lines
5.9 KiB
YAML
205 lines
5.9 KiB
YAML
name: Go
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- release-*
|
|
workflow_dispatch: {}
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
- release-*
|
|
|
|
permissions: # added using https://github.com/step-security/secure-workflows
|
|
contents: read
|
|
|
|
env:
|
|
# Common versions
|
|
GO_VERSION: '1.19'
|
|
GOLANGCI_VERSION: 'v1.49'
|
|
|
|
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@12aca0a884f6137d619d6a8a09fcc3406ced5281
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
paths_ignore: '["**.md", "**.mdx", "**.png", "**.jpg"]'
|
|
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
|
|
continue-on-error: true
|
|
|
|
staticcheck:
|
|
runs-on: ubuntu-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
|
|
steps:
|
|
- name: Setup Go
|
|
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Static Check
|
|
run: make staticcheck
|
|
|
|
- name: License Header Check
|
|
run: make check-license-header
|
|
|
|
lint:
|
|
runs-on: ubuntu-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
permissions:
|
|
contents: read # for actions/checkout to fetch code
|
|
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
|
|
|
|
steps:
|
|
- name: Setup Go
|
|
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
with:
|
|
submodules: true
|
|
|
|
# This action uses its own setup-go, which always seems to use the latest
|
|
# stable version of Go. We could run 'make lint' to ensure our desired Go
|
|
# version, but we prefer this action because it leaves 'annotations' (i.e.
|
|
# it comments on PRs to point out linter violations).
|
|
- name: Lint
|
|
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
|
|
with:
|
|
version: ${{ env.GOLANGCI_VERSION }}
|
|
|
|
check-diff:
|
|
runs-on: ubuntu-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Setup node
|
|
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
|
|
with:
|
|
node-version: '14'
|
|
|
|
- name: Cache Go Dependencies
|
|
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
|
|
with:
|
|
path: .work/pkg
|
|
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-pkg-
|
|
|
|
- name: Setup KinD
|
|
run: |
|
|
go install sigs.k8s.io/kind@v0.19.0
|
|
kind delete cluster --name kind || true
|
|
kind create cluster --name kind --image=kindest/node:v1.26.4 --kubeconfig ~/.kube/config
|
|
|
|
- name: Run cross-build
|
|
run: make cross-build
|
|
|
|
- name: Check Diff
|
|
run: |
|
|
export PATH=$(pwd)/bin/:$PATH
|
|
make check-diff
|
|
|
|
- name: Cleanup binary
|
|
run: make build-cleanup
|
|
|
|
check-windows:
|
|
runs-on: windows-latest
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: Cache Go Dependencies
|
|
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
|
|
with:
|
|
path: .work/pkg
|
|
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-pkg-
|
|
|
|
- name: Run Build CLI
|
|
run: make vela-cli
|
|
|
|
- name: Run CLI for version
|
|
shell: cmd
|
|
run: |
|
|
move .\bin\vela .\bin\vela.exe
|
|
.\bin\vela.exe version
|
|
|
|
check-core-image-build:
|
|
runs-on: ubuntu-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
with:
|
|
submodules: true
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0
|
|
- name: Build Test for vela core
|
|
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
check-cli-image-build:
|
|
runs-on: ubuntu-22.04
|
|
needs: detect-noop
|
|
if: needs.detect-noop.outputs.noop != 'true'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
with:
|
|
submodules: true
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0
|
|
- name: Build Test for CLI
|
|
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile.cli
|