Skip to content

Commit

Permalink
merged with main
Browse files Browse the repository at this point in the history
Signed-off-by: MenD32 <[email protected]>
  • Loading branch information
MenD32 committed Sep 23, 2024
2 parents c34c4f5 + e3ce354 commit 11b1f37
Show file tree
Hide file tree
Showing 20 changed files with 9,200 additions and 715 deletions.
50 changes: 17 additions & 33 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- name: Restore go build cache
uses: actions/cache@v4
with:
Expand All @@ -31,28 +31,6 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install protoc
run: |
set -eux -o pipefail
PROTOC_VERSION=3.19.4
PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
sudo chmod +x /usr/local/bin/protoc
sudo find /usr/local/include -type f | xargs sudo chmod a+r
sudo find /usr/local/include -type d | xargs sudo chmod a+rx
rm -f $PROTOC_ZIP
ls /usr/local/include/google/protobuf/
- name: Install pandoc
run: |
set -eux -o pipefail
PANDOC_VERSION=2.17.1
PANDOC_ZIP=pandoc-$PANDOC_VERSION-linux-amd64.tar.gz
curl -OL https://github.com/jgm/pandoc/releases/download/$PANDOC_VERSION/$PANDOC_ZIP
sudo tar xvzf $PANDOC_ZIP --strip-components 1 -C /usr/local
rm -f $PANDOC_ZIP
echo /usr/local/pandoc-$PANDOC_VERSION/bin >> $GITHUB_PATH
- name: Get dependencies
run: go mod download
- name: Make codegen
Expand All @@ -70,7 +48,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- name: Restore go build cache
uses: actions/cache@v4
with:
Expand All @@ -97,7 +75,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- name: Restore go build cache
uses: actions/cache@v4
with:
Expand All @@ -123,14 +101,14 @@ jobs:
include:
- driver: stan
- driver: jetstream
- driver: kafka
#- driver: kafka
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- name: Restore go build cache
uses: actions/cache@v4
with:
Expand All @@ -142,12 +120,18 @@ jobs:
${{ runner.os }}-go-
- name: Install k3d
run: curl -sfL https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash &
- name: Create k3d registry and cluster
- name: Create k3d cluster
run: |
k3d cluster create e2e
mkdir -p ~/.kube
k3d kubeconfig get e2e > ~/.kube/argo-events-e2e-config
- name: Install Argo Events
env:
GOPATH: /home/runner/go
run: |
k3d registry create e2e-registry --port 5111
k3d cluster create e2e -i rancher/k3s:v1.21.7-k3s1 --registry-use k3d-e2e-registry:5111
echo '127.0.0.1 k3d-e2e-registry' | sudo tee -a /etc/hosts
KUBECONFIG=~/.kube/argo-events-e2e-config VERSION=${{ github.sha }} make start
- name: Run tests
env:
GOPATH: /home/runner/go
run: |
IMAGE_NAMESPACE=k3d-e2e-registry:5111 VERSION=${{ github.sha }} DOCKER_PUSH=true make start
EventBusDriver=${{ matrix.driver }} make test-functional
KUBECONFIG=~/.kube/argo-events-e2e-config EventBusDriver=${{ matrix.driver }} make test-functional
7 changes: 3 additions & 4 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'
- name: build
run: |
pip install mkdocs==1.3.0 mkdocs_material==8.2.9
mkdocs build
run: make docs
- name: deploy
uses: peaceiris/actions-gh-pages@v4
if: github.repository == 'argoproj/argo-events' && github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"

- name: Build binaries
run: |
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
fi
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- uses: actions/checkout@v4
- run: go install sigs.k8s.io/bom/cmd/[email protected]
- run: go install github.com/spdx/spdx-sbom-generator/cmd/[email protected]
Expand Down
60 changes: 45 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL:=/bin/bash

PACKAGE=github.com/argoproj/argo-events
CURRENT_DIR=$(shell pwd)
DIST_DIR=${CURRENT_DIR}/dist
Expand All @@ -9,8 +11,8 @@ BINARY_NAME:=argo-events
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_BRANCH=$(shell git rev-parse --symbolic-full-name --verify --quiet --abbrev-ref HEAD)
GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi)
GIT_TREE_STATE=$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)
GIT_TAG=$(shell if [[ -z "`git status --porcelain`" ]]; then git describe --exact-match --tags HEAD 2>/dev/null; fi)
GIT_TREE_STATE=$(shell if [[ -z "`git status --porcelain`" ]]; then echo "clean" ; else echo "dirty"; fi)
EXECUTABLES = curl docker gzip go

# docker image publishing options
Expand All @@ -37,7 +39,28 @@ VERSION=$(GIT_TAG)
override LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
endif

K3D ?= $(shell [ "`command -v kubectl`" != '' ] && [ "`command -v k3d`" != '' ] && [[ "`kubectl config current-context`" =~ k3d-* ]] && echo true || echo false)
# Check Python
PYTHON:=$(shell command -v python 2> /dev/null)
ifndef PYTHON
PYTHON:=$(shell command -v python3 2> /dev/null)
endif
ifndef PYTHON
$(error "Python is not available, please install.")
endif

CURRENT_CONTEXT:=$(shell [[ "`command -v kubectl`" != '' ]] && kubectl config current-context 2> /dev/null || echo "unset")
IMAGE_IMPORT_CMD:=$(shell [[ "`command -v k3d`" != '' ]] && [[ "$(CURRENT_CONTEXT)" =~ k3d-* ]] && echo "k3d image import -c `echo $(CURRENT_CONTEXT) | cut -c 5-`")
ifndef IMAGE_IMPORT_CMD
IMAGE_IMPORT_CMD:=$(shell [[ "`command -v minikube`" != '' ]] && [[ "$(CURRENT_CONTEXT)" =~ minikube* ]] && echo "minikube image load")
endif
ifndef IMAGE_IMPORT_CMD
IMAGE_IMPORT_CMD:=$(shell [[ "`command -v kind`" != '' ]] && [[ "$(CURRENT_CONTEXT)" =~ kind-* ]] && echo "kind load docker-image")
endif

DOCKER:=$(shell command -v docker 2> /dev/null)
ifndef DOCKER
DOCKER:=$(shell command -v podman 2> /dev/null)
endif

# Check that the needed executables are available, else exit before the build
K := $(foreach exec,$(EXECUTABLES), $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
Expand All @@ -49,7 +72,7 @@ K := $(foreach exec,$(EXECUTABLES), $(if $(shell which $(exec)),some string,$(er
build: dist/$(BINARY_NAME)-linux-amd64.gz dist/$(BINARY_NAME)-linux-arm64.gz dist/$(BINARY_NAME)-linux-arm.gz dist/$(BINARY_NAME)-linux-ppc64le.gz dist/$(BINARY_NAME)-linux-s390x.gz

dist/$(BINARY_NAME)-%.gz: dist/$(BINARY_NAME)-%
@[ -e dist/$(BINARY_NAME)-$*.gz ] || gzip -k dist/$(BINARY_NAME)-$*
@[[ -e dist/$(BINARY_NAME)-$*.gz ]] || gzip -k dist/$(BINARY_NAME)-$*

dist/$(BINARY_NAME): GOARGS = GOOS= GOARCH=
dist/$(BINARY_NAME)-linux-amd64: GOARGS = GOOS=linux GOARCH=amd64
Expand All @@ -70,30 +93,30 @@ ifeq ($(shell uname -m),arm64)
BUILD_DIST = dist/$(BINARY_NAME)-linux-arm64
endif
image: clean $(BUILD_DIST)
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi
ifeq ($(K3D),true)
k3d image import $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)
DOCKER_BUILDKIT=1 $(DOCKER) build -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [[ "$(DOCKER_PUSH)" = "true" ]]; then $(DOCKER) push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi
ifdef IMAGE_IMPORT_CMD
$(IMAGE_IMPORT_CMD) $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)
endif

image-linux-%: dist/$(BINARY_NAME)-linux-%
DOCKER_BUILDKIT=1 docker build --build-arg "ARCH=$*" -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$* --platform "linux/$*" --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$*; fi
DOCKER_BUILDKIT=1 $(DOCKER) build --build-arg "ARCH=$*" -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$* --platform "linux/$*" --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [[ "$(DOCKER_PUSH)" = "true" ]]; then $(DOCKER) push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$*; fi

image-multi: set-qemu dist/$(BINARY_NAME)-linux-arm64.gz dist/$(BINARY_NAME)-linux-amd64.gz
docker buildx build --sbom=false --provenance=false --tag $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) --platform linux/amd64,linux/arm64 --file ./Dockerfile ${PUSH_OPTION} .
$(DOCKER) buildx build --sbom=false --provenance=false --tag $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) --platform linux/amd64,linux/arm64 --file ./Dockerfile ${PUSH_OPTION} .

set-qemu:
docker pull tonistiigi/binfmt:latest
docker run --rm --privileged tonistiigi/binfmt:latest --install amd64,arm64
$(DOCKER) pull tonistiigi/binfmt:latest
$(DOCKER) run --rm --privileged tonistiigi/binfmt:latest --install amd64,arm64

test:
go test $(shell go list ./... | grep -v /vendor/ | grep -v /test/e2e/) -race -short -v

test-functional:
ifeq ($(EventBusDriver),kafka)
kubectl -n argo-events apply -k test/manifests/kafka
kubectl -n argo-events wait -l statefulset.kubernetes.io/pod-name=kafka-0 --for=condition=ready pod --timeout=60s
kubectl -n argo-events wait -l statefulset.kubernetes.io/pod-name=kafka-broker-0 --for=condition=ready pod --timeout=60s
endif
go test -v -timeout 20m -count 1 --tags functional -p 1 ./test/e2e
ifeq ($(EventBusDriver),kafka)
Expand Down Expand Up @@ -162,6 +185,13 @@ lint: $(GOPATH)/bin/golangci-lint
go mod tidy
golangci-lint run --fix --verbose --concurrency 4 --timeout 5m --enable goimports

/usr/local/bin/mkdocs:
$(PYTHON) -m pip install mkdocs==1.3.0 mkdocs_material==8.3.9 mkdocs-embed-external-markdown==2.3.0

.PHONY: docs
docs: /usr/local/bin/mkdocs
mkdocs build

# release - targets only available on release branch
ifneq ($(findstring release,$(GIT_BRANCH)),)

Expand All @@ -183,7 +213,7 @@ endif

.PHONY: check-version-warning
check-version-warning:
@if [[ ! "$(VERSION)" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then echo -n "It looks like you're not using a version format like 'v1.2.3', or 'v1.2.3-rc2', that version format is required for our releases. Do you wish to continue anyway? [y/N]" && read ans && [ $${ans:-N} = y ]; fi
@if [[ ! "$(VERSION)" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then echo -n "It looks like you're not using a version format like 'v1.2.3', or 'v1.2.3-rc2', that version format is required for our releases. Do you wish to continue anyway? [y/N]" && read ans && [[ $${ans:-N} = y ]]; fi

.PHONY: update-manifests-version
update-manifests-version:
Expand Down
Loading

0 comments on commit 11b1f37

Please sign in to comment.