Skip to content

Commit

Permalink
Merge pull request #152 from zhu733756/master
Browse files Browse the repository at this point in the history
add main workflow actions
  • Loading branch information
Benjamin Huo authored Oct 13, 2021
2 parents 66ea659 + cd08ad3 commit 14ef40b
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 4 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/main.yaml
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
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -o pipefail
SCRIPT_ROOT=$(git rev-parse --show-toplevel)

# Grab code-generator version from go.sum.
CODEGEN_VERSION="v0.18.2"
CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | head -1)
CODEGEN_PKG=$(echo `go env GOPATH`"/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}")

# code-generator does work with go.mod but makes assumptions about
Expand Down
36 changes: 36 additions & 0 deletions hack/verify-crds.sh
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

0 comments on commit 14ef40b

Please sign in to comment.