Skip to content

Commit

Permalink
[release-1.11] backports for release-1.11.1 (#1998)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people committed Oct 2, 2023
1 parent 0d6e210 commit 82c7610
Show file tree
Hide file tree
Showing 46 changed files with 13,535 additions and 13,072 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test-e2e-oncluster-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
matrix:
go: [1.20.2]
os: ["ubuntu-latest"]
func_builder: ["pack", "s2i"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -29,6 +30,9 @@ jobs:
- name: E2E On Cluster Test (Runtimes)
env:
TEST_TAGS: runtime
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
FUNC_BUILDER: ${{ matrix.func_builder }}
run: make test-e2e-on-cluster
- uses: codecov/codecov-action@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-e2e-oncluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
- name: E2E On Cluster Test
env:
E2E_RUNTIMES: ""
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
run: make test-e2e-on-cluster
- uses: codecov/codecov-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: E2E Test
strategy:
matrix:
runtime: ["node", "go", "python", "quarkus", "springboot", "typescript"]
runtime: ["node", "go", "python", "quarkus", "springboot", "typescript", "rust"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- name: Patch Hosts
run: ./hack/patch-hosts.sh
- name: Integration Test
env:
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
run: make test-integration
- name: Dump Cluster Logs
if: always()
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-podman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ jobs:
- name: Local Registry
run: ./hack/registry.sh
- name: Integration Test Podman
env:
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
run: ./hack/test-integration-podman.sh

3 changes: 3 additions & 0 deletions .github/workflows/test-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
java-version: ${{ matrix.java }}
- name: Core Unit Tests
run: make test
env:
FUNC_REPO_REF: ${{ github.event.pull_request.head.repo.full_name }}
FUNC_REPO_BRANCH_REF: ${{ github.head_ref }}
- name: Template Unit Tests
run: make test-templates
- uses: codecov/codecov-action@v3
Expand Down
40 changes: 24 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ VTAG := $(shell git tag --points-at HEAD | head -1)
VTAG := $(shell [ -z $(VTAG) ] && echo $(ETAG) || echo $(VTAG))
VERS ?= $(shell git describe --tags --match 'v*')
KVER ?= $(shell git describe --tags --match 'knative-*')
LDFLAGS := "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.kver=$(KVER) -X main.hash=$(HASH)"

LDFLAGS := -X main.date=$(DATE) -X main.vers=$(VERS) -X main.kver=$(KVER) -X main.hash=$(HASH)
ifneq ($(FUNC_REPO_REF),)
LDFLAGS += -X knative.dev/func/pkg/pipelines/tekton.FuncRepoRef=$(FUNC_REPO_REF)
endif
ifneq ($(FUNC_REPO_BRANCH_REF),)
LDFLAGS += -X knative.dev/func/pkg/pipelines/tekton.FuncRepoBranchRef=$(FUNC_REPO_BRANCH_REF)
endif

MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

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

$(BIN): $(CODE)
env CGO_ENABLED=0 go build -ldflags $(LDFLAGS) ./cmd/$(BIN)
env CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" ./cmd/$(BIN)

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

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

test-quarkus: ## Test Quarkus templates
cd templates/quarkus/cloudevents && mvn -q test && mvn clean
cd templates/quarkus/http && mvn -q test && mvn clean
cd templates/quarkus/cloudevents && ./mvnw -q test && ./mvnw clean
cd templates/quarkus/http && ./mvnw -q test && ./mvnw clean

test-springboot: ## Test Spring Boot templates
cd templates/springboot/cloudevents && mvn -q test && mvn clean
cd templates/springboot/http && mvn -q test && mvn clean
cd templates/springboot/cloudevents && ./mvnw -q test && ./mvnw clean
cd templates/springboot/http && ./mvnw -q test && ./mvnw clean

test-rust: ## Test Rust templates
cd templates/rust/cloudevents && cargo -q test && cargo clean
Expand Down Expand Up @@ -193,12 +201,12 @@ templates/certs/ca-certificates.crt:
###################

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

.PHONY: func-instrumented

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

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

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

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

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

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

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

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

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

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

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

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

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

windows: $(BIN_WINDOWS) ## Build for Windows

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

######################
##@ Schemas
Expand Down
4 changes: 2 additions & 2 deletions cmd/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ func testRegistryLoads(cmdFn commandConstructor, t *testing.T) {

f := fn.Function{
Root: root,
Name: "myFunc",
Name: "my-func",
Runtime: "go",
Registry: "example.com/alice",
}
Expand All @@ -1219,7 +1219,7 @@ func testRegistryLoads(cmdFn commandConstructor, t *testing.T) {
t.Fatal(err)
}

expected := "example.com/alice/myFunc:latest"
expected := "example.com/alice/my-func:latest"
if f.Image != expected {
t.Fatalf("expected image name '%v'. got %v", expected, f.Image)
}
Expand Down
7 changes: 7 additions & 0 deletions cmd/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"knative.dev/func/pkg/config"
"knative.dev/func/pkg/functions"
"knative.dev/func/pkg/k8s"
"knative.dev/func/pkg/pipelines/tekton"
)

var format string = "json"
Expand Down Expand Up @@ -64,6 +65,7 @@ type Environment struct {
Templates map[string][]string
Environment []string
Cluster string
TektonTasks map[string]string
Defaults config.Global
}

Expand Down Expand Up @@ -131,6 +133,11 @@ func runEnvironment(cmd *cobra.Command, newClient ClientFactory, v *Version) (er
Environment: envs,
Cluster: host,
Defaults: defaults,
TektonTasks: map[string]string{
"func-buildpack": tekton.BuildpackTaskURL,
"func-s2i": tekton.S2ITaskURL,
"func-deploy": tekton.DeployTaskURL,
},
}

var s []byte
Expand Down
4 changes: 4 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ To build the core project, run `make` from the repository root. This will resul

To remove built artifacts, use `make clean`.

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

## Testing

To run core unit tests, use `make test`.
Expand Down
17 changes: 8 additions & 9 deletions docs/building-functions/on_cluster_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

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.

> **Note**
> Not all runtimes support on cluster builds. **Go** and **Rust** are not currently supported.
## Prerequisite
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:
```bash
Expand Down Expand Up @@ -34,12 +31,14 @@ git remote add origin git@github.com:my-repo/my-function.git
```
4. Update the Function configuration in `func.yaml` to enable on cluster builds for the Git repository:
```yaml
build: git # required, specify `git` build type
git:
url: https://github.com/my-repo/my-function.git # required, git repository with the function source code
revision: main # optional, git revision to be used (branch, tag, commit)
# contextDir: myfunction # optional, needed only if the function is not located
# in the repository root folder
build:
git:
url: https://github.com/my-repo/my-function.git # required, git repository with the function source code
revision: main # optional, git revision to be used (branch, tag, commit)
# contextDir: myfunction # optional, needed only if the function is not located in the repository root folder
buildpacks: []
builder: ""
buildEnvs: []
```
5. Implement the business logic of your Function, then commit and push changes
```bash
Expand Down

0 comments on commit 82c7610

Please sign in to comment.