Skip to content

Commit 82c7610

Browse files
matejvasekjrangelramosknative-automationShashankft9
authored
[release-1.11] backports for release-1.11.1 (#1998)
* chore: use tkn tasks from PR branch in CI (#1914) Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: released binaries refer correct task yamls (#1916) Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: refer correct tkn yaml in prow test (#1918) Without this change prow test will refer tkn yamls from the main branch not from the PR head branch. Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: update release generation (#1924) * Minimize release binary size. * Release latest version of buildpack tekton task. Signed-off-by: Matej Vasek <mvasek@redhat.com> * test: update github ref used on e2e oncluster tests (#1917) * test: Split of GH oncluster tests by builder. Added FUNC_BUILDER env var for e2e oncluter tests (#1963) * Use our own s2i image (#1971) Our image is much more recent and it is multiarch. Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: update buildah image ref (#1960) Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: update CA certs (#1944) Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: update Quarkus platform version to 3.4.1 (#1989) Co-authored-by: Knative Automation <automation@knative.team> Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: update mvn wrapper in Quarkus template (#1987) Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: use ./mvnw not mvn in tests (#1988) Signed-off-by: Matej Vasek <mvasek@redhat.com> * chore: update Springboot platform version Signed-off-by: Matej Vasek <mvasek@redhat.com> * fix: docker registry/repository parsing (#1929) * fix: docker registry/repository parsing Use go-containerregistry to do parsing. Signed-off-by: Matej Vasek <mvasek@redhat.com> * fix: use kebab-case instead of camelCase Signed-off-by: Matej Vasek <mvasek@redhat.com> * fix: use kebab-case instead of camelCase Signed-off-by: Matej Vasek <mvasek@redhat.com> --------- Signed-off-by: Matej Vasek <mvasek@redhat.com> * Fix failing concurrent test on Windows (#1890) * src: better debugging Signed-off-by: Matej Vasek <mvasek@redhat.com> * fix: wait for both builds Signed-off-by: Matej Vasek <mvasek@redhat.com> * fixup Signed-off-by: Matej Vasek <mvasek@redhat.com> * fixup Signed-off-by: Matej Vasek <mvasek@redhat.com> * fixup Signed-off-by: Matej Vasek <mvasek@redhat.com> * fix: detection of process liveness on Windows Signed-off-by: Matej Vasek <mvasek@redhat.com> * fix: make symlink relative Signed-off-by: Matej Vasek <mvasek@redhat.com> * fixup: cleanup Signed-off-by: Matej Vasek <mvasek@redhat.com> --------- Signed-off-by: Matej Vasek <mvasek@redhat.com> * allowing on cluster build for go runtime (#1445) * allowing on cluster build for go runtime * warning message added for go and rust builder * gofmt * fixups Signed-off-by: Matej Vasek <mvasek@redhat.com> --------- Signed-off-by: Matej Vasek <mvasek@redhat.com> Co-authored-by: Matej Vasek <mvasek@redhat.com> * Use custom jammy paketo builder (#1911) * chore: use custom jammy paketo builder Use our own modified jammy builder with additional buildpacks for GoFunc and Rust. This enables on cluster build for Go and Rust functions. Where possible (Go, Java) we use "tiny" variant, other runtimes use "base" variant. The updated task is new file instead of modifying existing task this is done for sake of keeping compatiblility. Signed-off-by: Matej Vasek <mvasek@redhat.com> * fixup: remove unnecessary code per review request Signed-off-by: Matej Vasek <mvasek@redhat.com> * fixup Signed-off-by: Matej Vasek <mvasek@redhat.com> * fixup: podman test refers correct tkn task yamls Signed-off-by: Matej Vasek <mvasek@redhat.com> --------- Signed-off-by: Matej Vasek <mvasek@redhat.com> * doc: Go and Rust on cluster build is supported (#1923) * doc: Go and Rust on cluster build is supported Signed-off-by: Matej Vasek <mvasek@redhat.com> * doc: build envvars Signed-off-by: Matej Vasek <mvasek@redhat.com> --------- Signed-off-by: Matej Vasek <mvasek@redhat.com> * fix: direct upload ppc64le, x390x (#1958) Signed-off-by: Matej Vasek <mvasek@redhat.com> * fix: report correct error when task doesn't exist (#1915) Signed-off-by: Matej Vasek <mvasek@redhat.com> * feat: tekton task urls in the env sub-cmd output (#1925) Signed-off-by: Matej Vasek <mvasek@redhat.com> --------- Signed-off-by: Matej Vasek <mvasek@redhat.com> Co-authored-by: Jefferson Ramos <jeramos@redhat.com> Co-authored-by: Knative Automation <automation@knative.team> Co-authored-by: Shashank Sharma <48708039+Shashankft9@users.noreply.github.com>
1 parent 0d6e210 commit 82c7610

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+13535
-13072
lines changed

.github/workflows/test-e2e-oncluster-runtime.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
matrix:
1010
go: [1.20.2]
1111
os: ["ubuntu-latest"]
12+
func_builder: ["pack", "s2i"]
1213
runs-on: ${{ matrix.os }}
1314
steps:
1415
- uses: actions/checkout@v3
@@ -29,6 +30,9 @@ jobs:
2930
- name: E2E On Cluster Test (Runtimes)
3031
env:
3132
TEST_TAGS: runtime
33+
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
34+
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
35+
FUNC_BUILDER: ${{ matrix.func_builder }}
3236
run: make test-e2e-on-cluster
3337
- uses: codecov/codecov-action@v3
3438
with:

.github/workflows/test-e2e-oncluster.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
- name: E2E On Cluster Test
3030
env:
3131
E2E_RUNTIMES: ""
32+
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
33+
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
3234
run: make test-e2e-on-cluster
3335
- uses: codecov/codecov-action@v3
3436
with:

.github/workflows/test-e2e-runtime.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: E2E Test
1212
strategy:
1313
matrix:
14-
runtime: ["node", "go", "python", "quarkus", "springboot", "typescript"]
14+
runtime: ["node", "go", "python", "quarkus", "springboot", "typescript", "rust"]
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v3

.github/workflows/test-integration.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
- name: Patch Hosts
4343
run: ./hack/patch-hosts.sh
4444
- name: Integration Test
45+
env:
46+
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
47+
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
4548
run: make test-integration
4649
- name: Dump Cluster Logs
4750
if: always()

.github/workflows/test-podman.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@ jobs:
3737
- name: Local Registry
3838
run: ./hack/registry.sh
3939
- name: Integration Test Podman
40+
env:
41+
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
42+
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
4043
run: ./hack/test-integration-podman.sh
4144

.github/workflows/test-unit.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
java-version: ${{ matrix.java }}
3434
- name: Core Unit Tests
3535
run: make test
36+
env:
37+
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
38+
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
3639
- name: Template Unit Tests
3740
run: make test-templates
3841
- uses: codecov/codecov-action@v3

Makefile

+24-16
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ VTAG := $(shell git tag --points-at HEAD | head -1)
2727
VTAG := $(shell [ -z $(VTAG) ] && echo $(ETAG) || echo $(VTAG))
2828
VERS ?= $(shell git describe --tags --match 'v*')
2929
KVER ?= $(shell git describe --tags --match 'knative-*')
30-
LDFLAGS := "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.kver=$(KVER) -X main.hash=$(HASH)"
30+
31+
LDFLAGS := -X main.date=$(DATE) -X main.vers=$(VERS) -X main.kver=$(KVER) -X main.hash=$(HASH)
32+
ifneq ($(FUNC_REPO_REF),)
33+
LDFLAGS += -X knative.dev/func/pkg/pipelines/tekton.FuncRepoRef=$(FUNC_REPO_REF)
34+
endif
35+
ifneq ($(FUNC_REPO_BRANCH_REF),)
36+
LDFLAGS += -X knative.dev/func/pkg/pipelines/tekton.FuncRepoBranchRef=$(FUNC_REPO_BRANCH_REF)
37+
endif
38+
3139
MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
3240

3341
# All Code prerequisites, including generated files, etc.
@@ -59,10 +67,10 @@ help:
5967
build: $(BIN) ## (default) Build binary for current OS
6068

6169
$(BIN): $(CODE)
62-
env CGO_ENABLED=0 go build -ldflags $(LDFLAGS) ./cmd/$(BIN)
70+
env CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" ./cmd/$(BIN)
6371

6472
test: $(CODE) ## Run core unit tests
65-
go test -race -cover -coverprofile=coverage.txt ./...
73+
go test -ldflags "$(LDFLAGS)" -race -cover -coverprofile=coverage.txt ./...
6674

6775
.PHONY: check
6876
check: $(BIN_GOLANGCI_LINT) ## Check code quality (lint)
@@ -152,12 +160,12 @@ test-python: ## Test Python templates
152160
cd templates/python/http && python3 test_func.py && rm -rf __pycache__
153161

154162
test-quarkus: ## Test Quarkus templates
155-
cd templates/quarkus/cloudevents && mvn -q test && mvn clean
156-
cd templates/quarkus/http && mvn -q test && mvn clean
163+
cd templates/quarkus/cloudevents && ./mvnw -q test && ./mvnw clean
164+
cd templates/quarkus/http && ./mvnw -q test && ./mvnw clean
157165

158166
test-springboot: ## Test Spring Boot templates
159-
cd templates/springboot/cloudevents && mvn -q test && mvn clean
160-
cd templates/springboot/http && mvn -q test && mvn clean
167+
cd templates/springboot/cloudevents && ./mvnw -q test && ./mvnw clean
168+
cd templates/springboot/http && ./mvnw -q test && ./mvnw clean
161169

162170
test-rust: ## Test Rust templates
163171
cd templates/rust/cloudevents && cargo -q test && cargo clean
@@ -193,12 +201,12 @@ templates/certs/ca-certificates.crt:
193201
###################
194202

195203
test-integration: ## Run integration tests using an available cluster.
196-
go test -tags integration -timeout 30m --coverprofile=coverage.txt ./... -v
204+
go test -ldflags "$(LDFLAGS)" -tags integration -timeout 30m --coverprofile=coverage.txt ./... -v
197205

198206
.PHONY: func-instrumented
199207

200208
func-instrumented: ## Func binary that is instrumented for e2e tests
201-
env CGO_ENABLED=1 go build -ldflags $(LDFLAGS) -cover -o func ./cmd/func
209+
env CGO_ENABLED=1 go build -ldflags "$(LDFLAGS)" -cover -o func ./cmd/func
202210

203211
test-e2e: func-instrumented ## Run end-to-end tests using an available cluster.
204212
./test/e2e_extended_tests.sh
@@ -218,37 +226,37 @@ cross-platform: darwin-arm64 darwin-amd64 linux-amd64 linux-arm64 linux-ppc64le
218226
darwin-arm64: $(BIN_DARWIN_ARM64) ## Build for mac M1
219227

220228
$(BIN_DARWIN_ARM64): generate/zz_filesystem_generated.go
221-
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $(BIN_DARWIN_ARM64) -ldflags $(LDFLAGS) ./cmd/$(BIN)
229+
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $(BIN_DARWIN_ARM64) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN)
222230

223231
darwin-amd64: $(BIN_DARWIN_AMD64) ## Build for Darwin (macOS)
224232

225233
$(BIN_DARWIN_AMD64): generate/zz_filesystem_generated.go
226-
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $(BIN_DARWIN_AMD64) -ldflags $(LDFLAGS) ./cmd/$(BIN)
234+
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $(BIN_DARWIN_AMD64) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN)
227235

228236
linux-amd64: $(BIN_LINUX_AMD64) ## Build for Linux amd64
229237

230238
$(BIN_LINUX_AMD64): generate/zz_filesystem_generated.go
231-
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BIN_LINUX_AMD64) -ldflags $(LDFLAGS) ./cmd/$(BIN)
239+
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BIN_LINUX_AMD64) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN)
232240

233241
linux-arm64: $(BIN_LINUX_ARM64) ## Build for Linux arm64
234242

235243
$(BIN_LINUX_ARM64): generate/zz_filesystem_generated.go
236-
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(BIN_LINUX_ARM64) -ldflags $(LDFLAGS) ./cmd/$(BIN)
244+
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(BIN_LINUX_ARM64) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN)
237245

238246
linux-ppc64le: $(BIN_LINUX_PPC64LE) ## Build for Linux ppc64le
239247

240248
$(BIN_LINUX_PPC64LE): generate/zz_filesystem_generated.go
241-
env CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -o $(BIN_LINUX_PPC64LE) -ldflags $(LDFLAGS) ./cmd/$(BIN)
249+
env CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -o $(BIN_LINUX_PPC64LE) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN)
242250

243251
linux-s390x: $(BIN_LINUX_S390X) ## Build for Linux s390x
244252

245253
$(BIN_LINUX_S390X): generate/zz_filesystem_generated.go
246-
env CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -o $(BIN_LINUX_S390X) -ldflags $(LDFLAGS) ./cmd/$(BIN)
254+
env CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -o $(BIN_LINUX_S390X) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN)
247255

248256
windows: $(BIN_WINDOWS) ## Build for Windows
249257

250258
$(BIN_WINDOWS): generate/zz_filesystem_generated.go
251-
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o $(BIN_WINDOWS) -ldflags $(LDFLAGS) ./cmd/$(BIN)
259+
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o $(BIN_WINDOWS) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN)
252260

253261
######################
254262
##@ Schemas

cmd/deploy_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ func testRegistryLoads(cmdFn commandConstructor, t *testing.T) {
11981198

11991199
f := fn.Function{
12001200
Root: root,
1201-
Name: "myFunc",
1201+
Name: "my-func",
12021202
Runtime: "go",
12031203
Registry: "example.com/alice",
12041204
}
@@ -1219,7 +1219,7 @@ func testRegistryLoads(cmdFn commandConstructor, t *testing.T) {
12191219
t.Fatal(err)
12201220
}
12211221

1222-
expected := "example.com/alice/myFunc:latest"
1222+
expected := "example.com/alice/my-func:latest"
12231223
if f.Image != expected {
12241224
t.Fatalf("expected image name '%v'. got %v", expected, f.Image)
12251225
}

cmd/environment.go

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"knative.dev/func/pkg/config"
1616
"knative.dev/func/pkg/functions"
1717
"knative.dev/func/pkg/k8s"
18+
"knative.dev/func/pkg/pipelines/tekton"
1819
)
1920

2021
var format string = "json"
@@ -64,6 +65,7 @@ type Environment struct {
6465
Templates map[string][]string
6566
Environment []string
6667
Cluster string
68+
TektonTasks map[string]string
6769
Defaults config.Global
6870
}
6971

@@ -131,6 +133,11 @@ func runEnvironment(cmd *cobra.Command, newClient ClientFactory, v *Version) (er
131133
Environment: envs,
132134
Cluster: host,
133135
Defaults: defaults,
136+
TektonTasks: map[string]string{
137+
"func-buildpack": tekton.BuildpackTaskURL,
138+
"func-s2i": tekton.S2ITaskURL,
139+
"func-deploy": tekton.DeployTaskURL,
140+
},
134141
}
135142

136143
var s []byte

docs/CONTRIBUTING.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ To build the core project, run `make` from the repository root. This will resul
88

99
To remove built artifacts, use `make clean`.
1010

11+
### Build affecting environment variables
12+
* `FUNC_REPO_REF` affects which github repo will be used to fetch tekton tasks for on cluster build. Default: `knative/func`.
13+
* `FUNC_REPO_BRANCH_REF` affects which github branch will be used to fetch tekton tasks for on cluster build. Default: `main`.
14+
1115
## Testing
1216

1317
To run core unit tests, use `make test`.

docs/building-functions/on_cluster_build.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
This guide describes how you can build a Function on Cluster with Tekton Pipelines. The on cluster build is enabled by fetching Function source code from a remote Git repository. Buildpacks or S2I builder strategy can be used to build the Function image.
44

5-
> **Note**
6-
> Not all runtimes support on cluster builds. **Go** and **Rust** are not currently supported.
7-
85
## Prerequisite
96
1. Install Tekton Pipelines on the cluster. Please refer to [Tekton Pipelines documentation](https://github.com/tektoncd/pipeline/blob/main/docs/install.md) or run the following command:
107
```bash
@@ -34,12 +31,14 @@ git remote add origin git@github.com:my-repo/my-function.git
3431
```
3532
4. Update the Function configuration in `func.yaml` to enable on cluster builds for the Git repository:
3633
```yaml
37-
build: git # required, specify `git` build type
38-
git:
39-
url: https://github.com/my-repo/my-function.git # required, git repository with the function source code
40-
revision: main # optional, git revision to be used (branch, tag, commit)
41-
# contextDir: myfunction # optional, needed only if the function is not located
42-
# in the repository root folder
34+
build:
35+
git:
36+
url: https://github.com/my-repo/my-function.git # required, git repository with the function source code
37+
revision: main # optional, git revision to be used (branch, tag, commit)
38+
# contextDir: myfunction # optional, needed only if the function is not located in the repository root folder
39+
buildpacks: []
40+
builder: ""
41+
buildEnvs: []
4342
```
4443
5. Implement the business logic of your Function, then commit and push changes
4544
```bash

0 commit comments

Comments
 (0)