Skip to content

Commit

Permalink
Merge pull request #4 from rgdoliveira/sync_main
Browse files Browse the repository at this point in the history
Sync main branch with Apache main branch
  • Loading branch information
rgdoliveira authored Jan 30, 2024
2 parents 96f4cee + 65f1c35 commit 11ab49a
Show file tree
Hide file tree
Showing 146 changed files with 32,990 additions and 2,441 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/check-container-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup golang
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.21
- name: Checkout code
uses: actions/checkout@v2
with:
Expand All @@ -53,18 +53,19 @@ jobs:
cancel-in-progress: true
timeout-minutes: 120
name: Integration tests (${{ matrix.container-engine }})
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Install packages
run: |
sudo apt-get -y install \
sudo apt-get update &&\
sudo apt-get -y install --no-install-recommends \
libgpgme-dev \
libbtrfs-dev \
libdevmapper-dev
- name: Setup golang
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.21
- name: Checkout code
uses: actions/checkout@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- ".ci/jenkins/**"

env:
GO_VERSION: 1.19
GO_VERSION: 1.21

jobs:
unit-tests:
Expand Down Expand Up @@ -87,10 +87,10 @@ jobs:
uses: actions/checkout@v3

# since we now have to download container-builder deps, we need these packages installed before generating our types.
# we should be able to remove this after https://issues.redhat.com/browse/KOGITO-9106
- name: Install packages
run: |
sudo apt-get -y install \
sudo apt-get update &&\
sudo apt-get -y install --no-install-recommends \
btrfs-progs \
libgpgme-dev \
libbtrfs-dev \
Expand Down
80 changes: 30 additions & 50 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ on:
- ".ci/jenkins/**"

env:
GO_VERSION: 1.19
# Kubernetes version should aligned with OCP LTS, aka OCP 4.10 (k8s 1.23) for now
# https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.23.md
# WARNING: kindest/node is not always existing with given version ...
KUBERNETES_VERSION: v1.26.3
DEBUG: true
GO_VERSION: 1.21
KIND_VERSION: v0.20.0

jobs:
e2e:
Expand All @@ -26,7 +22,7 @@ jobs:
cancel-in-progress: true
timeout-minutes: 120
runs-on: ubuntu-latest
name: End-to-end tests (Minikube)
name: End-to-end tests (Kind)
steps:
- name: Install package
run: |
Expand All @@ -48,64 +44,48 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Setup Minikube cluster
# Should be set back with correct version once https://github.com/radtriste/setup-minikube/tree/issue_49 is done
uses: medyagh/[email protected]
with:
addons: registry,metrics-server
kubernetes-version: ${{ env.KUBERNETES_VERSION }}
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
cpus: max
memory: max
insecure-registry: localhost:5000,192.168.0.0/16

- name: Wait for Minikube up and running
- name: Setup Kind cluster
run: |
minikube ssh cat /lib/systemd/system/docker.service
kubectl get pods -A
set -x
MINIKUBE_COMPONENTS=(etcd kube-apiserver kube-controller-manager kube-scheduler)
for component in "${MINIKUBE_COMPONENTS[@]}"
do
echo "Check component '${component}' is in 'Running' state"
COMPONENT_NAME=${component} timeout 60s bash -c 'kubectl get pods -l tier=control-plane -l component=${COMPONENT_NAME} -n kube-system && while [[ "$(kubectl get pods -l tier=control-plane -l component=${COMPONENT_NAME} -n kube-system -o jsonpath={.items[0].status.phase})" != "Running" ]] ; do sleep 2 && kubectl get pods -l tier=control-plane -l component=${COMPONENT_NAME} -n kube-system -o jsonpath={.items[0].status.phase}; done'
done
make KIND_VERSION=${{ env.KIND_VERSION }} create-cluster
- name: Wait for Minikube registry
- name: Set OPERATOR_IMAGE_NAME to point to Kind's local registry
run: |
kubectl get pods -A
timeout 60s bash -c 'kubectl get pods -l kubernetes.io/minikube-addons=registry -l actual-registry=true -n kube-system && while [[ "$(kubectl get pods -l kubernetes.io/minikube-addons=registry -l actual-registry=true -n kube-system -o jsonpath={.items[0].status.phase})" != "Running" ]] ; do sleep 2 && kubectl get pods -l kubernetes.io/minikube-addons=registry -l actual-registry=true -n kube-system -o jsonpath={.items[0].status.phase}; done'
- name: Retrieve Minikube registry
run: |
minikube_registry="$(minikube ip):5000"
echo "MINIKUBE_REGISTRY=${minikube_registry}" >> $GITHUB_ENV
echo "OPERATOR_IMAGE_NAME=${minikube_registry}/kogito-serverless-operator:0.0.1" >> $GITHUB_ENV
- name: Setup Python for cekit
uses: actions/setup-python@v4
with:
python-version: '3.10'
echo "OPERATOR_IMAGE_NAME=127.0.0.1:5001/kogito-serverless-operator:0.0.1" >> $GITHUB_ENV
# TODO: cache this installation
- name: Build operator image
run: |
pip install cekit==4.5.0
pip install odcs podman behave lxml krb5
make container-build BUILDER=podman IMG=${{ env.OPERATOR_IMAGE_NAME }}
make docker-build IMG=${{ env.OPERATOR_IMAGE_NAME }}
- name: Load image in Minikube
- name: Load image in Kind
run: |
podman push --tls-verify=false ${{ env.OPERATOR_IMAGE_NAME }}
kind load docker-image 127.0.0.1:5001/kogito-serverless-operator:0.0.1
- name: Check pods
run: |
kubectl version
kubectl get pods -A
# TODO: install the operator-sdk first, then cache the installation

- name: Deploy operator
run: |
make deploy IMG=${{ env.OPERATOR_IMAGE_NAME }}
kubectl wait pod -A -l control-plane=controller-manager --for condition=Ready
- name: Run tests
run: |
make test-e2e
- name: Export kind logs
if: always()
run: |
mkdir -p /tmp/kind/logs
kind export logs --loglevel=debug /tmp/kind/logs
- name: Upload kind logs
if: always()
uses: actions/upload-artifact@v3
with:
name: kind-logs-${{ env.JOB_NAME }}-${{ github.run_id }}
path: /tmp/kind/logs
retention-days: 1
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
# under the License.

# Build the manager binary
FROM docker.io/library/golang:1.19.9 as builder
FROM docker.io/library/golang:1.21.6 as builder

ARG SOURCE_DATE_EPOCH

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -40,12 +42,18 @@ COPY version/ version/
COPY log/ log/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags=-buildid= -a -o manager main.go

FROM registry.access.redhat.com/ubi9/ubi-micro:9.3-9

ARG SOURCE_DATE_EPOCH

FROM registry.access.redhat.com/ubi8/ubi-micro:latest
WORKDIR /usr/local/bin

COPY --from=builder /workspace/manager /usr/local/bin/manager
# We force a timestamp to the output to guarantee a reproducible build, once we have BuildKit 0.12, this won't be needed anymore.
# The workaround to force the date format is because docker cli is expecting an int from this parameter (the timestamp).
RUN touch -d $(date '+%FT%H:%M:%S' -d @${SOURCE_DATE_EPOCH}) /usr/local/bin/manager

USER 65532:65532

Expand Down
32 changes: 23 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ test-workflowproj:

.PHONY: build
build: generate ## Build manager binary.
go build -o bin/manager main.go
CGO_ENABLED=0 go build -trimpath -ldflags=-buildid= -o bin/manager main.go

.PHONY: build-4-debug
build-4-debug: generate ## Build manager binary with debug options.
Expand All @@ -161,12 +161,12 @@ debug: build-4-debug ## Run a controller from your host from binary
./bin/manager -v=2

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .
docker-build: generate ## Build docker image with the manager.
docker build --build-arg SOURCE_DATE_EPOCH="$(shell git log -1 --pretty=%ct)" -t ${IMG} .

.PHONY: podman-build
podman-build: test ## Build container image with the manager.
podman build -t ${IMG} .
podman-build: generate ## Build container image with the manager.
podman build --build-arg SOURCE_DATE_EPOCH="$(shell git log -1 --pretty=%ct)" -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
Expand All @@ -181,12 +181,12 @@ docker-push: ## Push docker image with the manager.
# To properly provided solutions that supports more than one platform you should use this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
docker-buildx: generate ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
- docker buildx build --build-arg SOURCE_DATE_EPOCH=$(shell git log -1 --pretty=%ct) --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
- docker buildx rm project-v3-builder
rm Dockerfile.cross

Expand Down Expand Up @@ -248,6 +248,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
## Tool Versions
KUSTOMIZE_VERSION ?= v4.5.2
CONTROLLER_TOOLS_VERSION ?= v0.9.2
KIND_VERSION ?= v0.20.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down Expand Up @@ -346,7 +347,20 @@ generate-all: generate generate-deploy bundle addheaders vet fmt

.PHONY: test-e2e # You will need to have a Minikube/Kind cluster up in running to run this target, and run container-builder before the test
test-e2e: install-operator-sdk
go test ./test/e2e/* -v -ginkgo.v
go test ./test/e2e/* -v -ginkgo.v -timeout 30m

.PHONY: before-pr
before-pr: test generate-all
before-pr: test generate-all


.PHONY: install-kind
install-kind:
command -v kind >/dev/null || go install sigs.k8s.io/kind@$(KIND_VERSION)

.PHONY: create-cluster
create-cluster: install-kind
kind get clusters | grep kind >/dev/null || ./hack/ci/create-kind-cluster-with-registry.sh

.PHONY: delete-cluster
delete-cluster: install-kind
kind delete cluster && docker rm -f kind-registry
4 changes: 3 additions & 1 deletion api/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const (
BuildFailedReason = "BuildFailedReason"
WaitingForBuildReason = "WaitingForBuild"
BuildIsRunningReason = "BuildIsRunning"
BuildSkipped = "BuildSkipped"
BuildSkippedReason = "BuildSkipped"
BuildSuccessfulReason = "BuildSuccessful"
BuildMarkedToRestartReason = "BuildMarkedToRestart"
)

// Condition describes the common structure for conditions in our types
Expand Down
Loading

0 comments on commit 11ab49a

Please sign in to comment.