Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #10456

Closed
wants to merge 2 commits into from
Closed

test #10456

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Label PR by Kind

on:
pull_request:
types: [opened, edited, reopened, synchronize]

permissions:
issues: write

jobs:
kind-label:
runs-on: ubuntu-latest
steps:
- name: enhancement
if: contains(github.event.pull_request.description, '/kind enhancement')
uses: christianvuerings/add-labels@v1
with:
labels: |
kind/enhancement
74 changes: 74 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release
on:
workflow_dispatch:
push:
tags:
- 'v*'
pull_request:
branches:
- main

env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}

permissions:
contents: write
id-token: write
packages: write

jobs:
goreleaser:
name: goreleaser
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true

# TODO(tim): Manage tools in this repo better so we can cache them.
# - uses: actions/cache@v4
# with:
# path: hack/tools
# key: ${{ runner.os }}-go-tools${{ hashFiles('hack/tools/go.sum') }}
# restore-keys: |
# ${{ runner.os }}-go-tools-

- name: Log into ghcr.io
uses: docker/login-action@v3
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set the release related variables
id: set_vars
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
# Release tags.
VERSION="${GITHUB_REF#refs/tags/}"
echo GORELEASER_ARGS="--clean"
elif [[ $GITHUB_REF == refs/heads/main ]]; then
# 'main' branch build.
VERSION="$(echo "${GITHUB_REF#refs/heads/}" | sed -r 's|/+|-|g')"
echo GORELEASER_ARGS="--clean --skip=validate" >> $GITHUB_ENV
elif [[ $GITHUB_REF == refs/pull/* ]]; then
# PR build.
VERSION="pr-$(echo "${GITHUB_REF}" | sed -E 's|refs/pull/([^/]+)/?.*|\1|')"
else
VERSION="$(git describe --tags --always)"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV

- name: Run goreleaser
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ env.VERSION }}
IMAGE_REGISTRY: ${{ env.IMAGE_REGISTRY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ istio-*/*

# Bin directory created by e2e test
.bin/
# Added by goreleaser init:
dist/
58 changes: 58 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: 2
before:
hooks:
- go mod tidy
- go mod download
builds:
- id: controller
main: ./projects/gloo/cmd/
binary: gloo-linux-{{ .Arch }}
gcflags: "{{ .Env.GCFLAGS }}"
ldflags: "{{ .Env.LDFLAGS }}"
env:
- CGO_ENABLED=0
- GO111MODULE=on
- GOARCH={{ .Arch }}
- GOOS={{ .Os }}
mod_timestamp: "{{ .CommitTimestamp }}"
goos:
- linux
goarch:
- amd64
- arm64
dockers:
- image_templates:
- &arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.IMAGE_REPO }}:{{ .Env.VERSION }}-arm64"
use: buildx
dockerfile: &dockerfile projects/gloo/cmd/Dockerfile
goos: linux
goarch: arm64
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
- "--build-arg=GOARCH=arm64"
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_GLOO_IMAGE }}"
- image_templates:
- &amd_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.IMAGE_REPO }}:{{ .Env.VERSION }}-amd64"
use: buildx
dockerfile: *dockerfile
goos: linux
goarch: amd64
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- "--build-arg=GOARCH=amd64"
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_GLOO_IMAGE }}"
docker_manifests:
- name_template: "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.IMAGE_REPO }}:{{ .Env.VERSION }}"
image_templates:
- *amd_image
- *arm_image
changelog:
use: "github-native"
sort: "asc"
disable: false
release:
draft: false
prerelease: "auto"
mode: "replace"
37 changes: 22 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# https://www.gnu.org/software/make/manual/html_node/Special-Variables.html#Special-Variables
.DEFAULT_GOAL := help


#----------------------------------------------------------------------------------
# Help
#----------------------------------------------------------------------------------
Expand All @@ -18,10 +17,9 @@
.PHONY: help
help: NAME_COLUMN_WIDTH=35
help: LINE_COLUMN_WIDTH=5
help: ## Output the self-documenting make targets
help: ## Output the self-documenting make targets ASDF
@grep -hnE '^[%a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = "[:]|(## )"}; {printf "\033[36mL%-$(LINE_COLUMN_WIDTH)s%-$(NAME_COLUMN_WIDTH)s\033[0m %s\n", $$1, $$2, $$4}'


#----------------------------------------------------------------------------------
# Base
#----------------------------------------------------------------------------------
Expand All @@ -33,7 +31,8 @@ OUTPUT_DIR ?= $(ROOTDIR)/_output
# To use quay images, set the IMAGE_REGISTRY to "quay.io/solo-io" (or leave unset)
# To use dockerhub images, set the IMAGE_REGISTRY to "soloio"
# To use gcr images, set the IMAGE_REGISTRY to "gcr.io/$PROJECT_NAME"
IMAGE_REGISTRY ?= quay.io/solo-io
export IMAGE_REGISTRY ?= ghcr.io/kgateway
export IMAGE_REPO ?= kgateway

# Kind of a hack to make sure _output exists
z := $(shell mkdir -p $(OUTPUT_DIR))
Expand All @@ -49,9 +48,9 @@ SOURCES := $(shell find . -name "*.go" | grep -v test.go)
# for more information, see https://github.com/solo-io/gloo/pull/9633
# and
# https://soloio.slab.com/posts/extended-http-methods-design-doc-40j7pjeu
ENVOY_GLOO_IMAGE ?= quay.io/solo-io/envoy-gloo:1.31.2-patch3
LDFLAGS := "-X github.com/solo-io/gloo/pkg/version.Version=$(VERSION)"
GCFLAGS ?=
export ENVOY_GLOO_IMAGE ?= quay.io/solo-io/envoy-gloo:1.31.2-patch3
export LDFLAGS := -X github.com/solo-io/gloo/pkg/version.Version=$(VERSION)
export GCFLAGS ?=

UNAME_M := $(shell uname -m)
# if `GO_ARCH` is set, then it will keep its value. Else, it will be changed based off the machine's host architecture.
Expand Down Expand Up @@ -126,7 +125,6 @@ ALPINE_BASE_IMAGE ?= alpine:3.17.6
# in the tree rooted at that directory that match the given criteria.
get_sources = $(shell find $(1) -name "*.go" | grep -v test | grep -v generated.go | grep -v mock_)


#----------------------------------------------------------------------------------
# Imports
#----------------------------------------------------------------------------------
Expand Down Expand Up @@ -172,18 +170,27 @@ check-format:
check-spelling:
./ci/spell.sh check

#----------------------------------------------------------------------------------
# Release
#----------------------------------------------------------------------------------

GORELEASER_ARGS ?= --snapshot --clean
GORELEASER ?= go run github.com/goreleaser/goreleaser/[email protected]
.PHONY: release
release:
$(GORELEASER) release $(GORELEASER_ARGS)

#----------------------------------------------------------------------------
# Analyze
#----------------------------------------------------------------------------
LINTER_VERSION := $(shell cat .github/workflows/static-analysis.yaml | yq '.jobs.static-analysis.steps.[] | select( .uses == "*golangci/golangci-lint-action*") | .with.version ')

# The analyze target runs a suite of static analysis tools against the codebase.
# The options are defined in .golangci.yaml, and can be overridden by setting the ANALYZE_OPTIONS variable.
# The options are defined in .golangci.yaml, and can be overridden by setting the ANALYZE_ARGS variable.
.PHONY: analyze
ANALYZE_OPTIONS ?= --fast --verbose
ANALYZE_ARGS ?= --fast --verbose
analyze:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(LINTER_VERSION) run $(ANALYZE_OPTIONS) ./...

go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(LINTER_VERSION) run $(ANALYZE_ARGS) ./...

#----------------------------------------------------------------------------------
# Ginkgo Tests
Expand Down Expand Up @@ -237,7 +244,7 @@ run-kube-e2e-tests: test
#----------------------------------------------------------------------------------
# Go Tests
#----------------------------------------------------------------------------------
GO_TEST_ENV ?=
GO_TEST_ENV ?=
# Testings flags: https://pkg.go.dev/cmd/go#hdr-Testing_flags
# The default timeout for a suite is 10 minutes, but this can be overridden by setting the -timeout flag. Currently set
# to 25 minutes based on the time it takes to run the longest test setup (k8s_gw_test).
Expand Down Expand Up @@ -378,7 +385,6 @@ generated-code-cleanup: getter-check mod-tidy update-licenses fmt ## Executes th
generate-changelog: ## Generate a changelog entry
@./devel/tools/changelog.sh


#----------------------------------------------------------------------------------
# Generate CRD Reference Documentation
#
Expand Down Expand Up @@ -521,7 +527,6 @@ discovery-distroless-docker: $(DISCOVERY_OUTPUT_DIR)/discovery-linux-$(GOARCH) $
--build-arg BASE_IMAGE=$(GLOO_DISTROLESS_BASE_IMAGE) \
-t $(IMAGE_REGISTRY)/discovery:$(VERSION)-distroless $(QUAY_EXPIRATION_LABEL)


#----------------------------------------------------------------------------------
# Gloo
#----------------------------------------------------------------------------------
Expand Down Expand Up @@ -804,6 +809,8 @@ VERSION := $(shell echo $(TAGGED_VERSION) | cut -c 2-)
LDFLAGS := "-X github.com/solo-io/gloo/pkg/version.Version=$(VERSION)"
endif

export VERSION

# controller variable for the "Publish Artifacts" section. Defines which targets exist. Possible Values: NONE, RELEASE, PULL_REQUEST
PUBLISH_CONTEXT ?= NONE
# specify which bucket to upload helm chart to
Expand Down
22 changes: 22 additions & 0 deletions hack/changelog/changelog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package changelog

import (
"fmt"
"os"

"github.com/go-git/go-git/v5"
)

func main() {
if err := generate(); err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
}
}

func generate() error {
r, err := git.PlainOpen(".")

Check failure on line 18 in hack/changelog/changelog.go

View workflow job for this annotation

GitHub Actions / Lint Checks

declared and not used: r
if err != nil {
return err
}
}

Check failure on line 22 in hack/changelog/changelog.go

View workflow job for this annotation

GitHub Actions / Lint Checks

missing return (typecheck)
Loading