-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from zhu733756/master
add main workflow actions
- Loading branch information
Showing
4 changed files
with
141 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Main CI WorkFlow | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'release-*' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- 'master' | ||
- 'release-*' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-18.04 | ||
timeout-minutes: 30 | ||
name: Basic test and verify | ||
env: | ||
GO111MODULE: "on" | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Install kubebuilder-2.3.2 | ||
run: | | ||
curl -L "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_linux_amd64.tar.gz" | tar -xz -C /tmp/ | ||
sudo mv /tmp/kubebuilder_2.3.2_linux_amd64 /usr/local/kubebuilder | ||
- name: Run basic test | ||
run: make test | ||
|
||
- name: Run verify crds test | ||
run: make verify | ||
|
||
build: | ||
runs-on: ubuntu-18.04 | ||
timeout-minutes: 30 | ||
name: Binary build | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- run: make binary | ||
name: Run build all binaries | ||
|
||
docker_build: | ||
runs-on: ubuntu-18.04 | ||
timeout-minutes: 30 | ||
name: Docker image build | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- run: make build-amd64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,15 @@ test: generate fmt vet manifests | |
manager: generate fmt vet | ||
go build -o bin/manager cmd/manager/main.go | ||
|
||
binary: | ||
go build -o bin/manager cmd/manager/main.go | ||
go build -o bin/watcher cmd/fluent-bit-watcher/main.go | ||
|
||
verify: verify-crds | ||
|
||
verify-crds: | ||
sudo chmod a+x ./hack/verify-crds.sh && ./hack/verify-crds.sh | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
run: generate fmt vet manifests | ||
go run cmd/manager/main.go | ||
|
@@ -71,14 +80,14 @@ build-op: test | |
docker buildx build --push --platform linux/amd64,linux/arm64 -f cmd/manager/Dockerfile . -t ${OP_IMG} | ||
|
||
# Build all amd64 docker images | ||
build-amd64: build-op-amd64 | ||
build-amd64: build-op-amd64 build-fb-amd64 | ||
|
||
# Build amd64 Fluent Bit container image | ||
build-fb-amd64: | ||
docker build -f cmd/fluent-bit-watcher/Dockerfile . -t ${FB_IMG}${AMD64} | ||
|
||
# Build amd64 Fluent Bit Operator container image | ||
build-op-amd64: test | ||
build-op-amd64: | ||
docker build -f cmd/manager/Dockerfile . -t ${OP_IMG}${AMD64} | ||
|
||
# Push the amd64 docker image | ||
|
@@ -94,7 +103,7 @@ ifeq (, $(shell which controller-gen)) | |
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$CONTROLLER_GEN_TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
go install -v sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ | ||
} | ||
CONTROLLER_GEN=$(GOBIN)/controller-gen | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. | ||
CRD_OPTIONS="crd:trivialVersions=true" | ||
|
||
DIFFROOT="${SCRIPT_ROOT}/config/crd/bases" | ||
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/config/crd/bases" | ||
_tmp="${SCRIPT_ROOT}/_tmp" | ||
|
||
cleanup() { | ||
rm -rf "${_tmp}" | ||
} | ||
trap "cleanup" EXIT SIGINT | ||
|
||
cleanup | ||
|
||
mkdir -p "${TMP_DIFFROOT}" | ||
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" | ||
|
||
$(which controller-gen) ${CRD_OPTIONS} rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
echo "diffing ${DIFFROOT} against freshly generated crds" | ||
ret=0 | ||
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? | ||
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" | ||
if [[ $ret -eq 0 ]] | ||
then | ||
echo "${DIFFROOT} up to date." | ||
else | ||
echo "${DIFFROOT} is out of date. Please rerun make manifests" | ||
exit 1 | ||
fi | ||
|