From 1bf43a2b986ee274db610c22be79236dda79c3db Mon Sep 17 00:00:00 2001 From: David Simansky Date: Tue, 29 Mar 2022 12:19:51 +0200 Subject: [PATCH] Add openshift specific files. --- Makefile | 71 +++++ OWNERS | 9 +- OWNERS_ALIASES | 219 +-------------- openshift-serverless-clients.spec | 148 ++++++++++ openshift/ci-operator/build-image/Dockerfile | 26 ++ .../ci-operator/build-image/kubernetes.repo | 7 + openshift/ci-operator/generate-ci-config.sh | 104 +++++++ .../knative-images/client/Dockerfile | 5 + .../client/Dockerfile.cliartifacts | 17 ++ .../knative-test-images/grpc-ping/Dockerfile | 6 + .../knative-test-images/helloworld/Dockerfile | 6 + .../servingcontainer/Dockerfile | 6 + .../sidecarcontainer/Dockerfile | 6 + openshift/e2e-common.sh | 259 ++++++++++++++++++ openshift/e2e-tests-local.sh | 13 + openshift/e2e-tests-openshift.sh | 31 +++ openshift/release/README.md | 35 +++ openshift/release/common.sh | 81 ++++++ openshift/release/create-release-branch.sh | 48 ++++ openshift/release/plugin_register.go | 23 ++ openshift/release/update-faas.sh | 12 + openshift/release/update-to-head.sh | 62 +++++ openshift/serverless/operator-install.yaml | 34 +++ package_cliartifacts.sh | 52 ++++ 24 files changed, 1062 insertions(+), 218 deletions(-) create mode 100644 Makefile create mode 100644 openshift-serverless-clients.spec create mode 100644 openshift/ci-operator/build-image/Dockerfile create mode 100644 openshift/ci-operator/build-image/kubernetes.repo create mode 100755 openshift/ci-operator/generate-ci-config.sh create mode 100644 openshift/ci-operator/knative-images/client/Dockerfile create mode 100644 openshift/ci-operator/knative-images/client/Dockerfile.cliartifacts create mode 100644 openshift/ci-operator/knative-test-images/grpc-ping/Dockerfile create mode 100644 openshift/ci-operator/knative-test-images/helloworld/Dockerfile create mode 100644 openshift/ci-operator/knative-test-images/servingcontainer/Dockerfile create mode 100644 openshift/ci-operator/knative-test-images/sidecarcontainer/Dockerfile create mode 100755 openshift/e2e-common.sh create mode 100755 openshift/e2e-tests-local.sh create mode 100755 openshift/e2e-tests-openshift.sh create mode 100644 openshift/release/README.md create mode 100755 openshift/release/common.sh create mode 100755 openshift/release/create-release-branch.sh create mode 100644 openshift/release/plugin_register.go create mode 100644 openshift/release/update-faas.sh create mode 100755 openshift/release/update-to-head.sh create mode 100644 openshift/serverless/operator-install.yaml create mode 100755 package_cliartifacts.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..b90993ca09 --- /dev/null +++ b/Makefile @@ -0,0 +1,71 @@ +#This makefile is used by ci-operator + +# Copyright 2019 The OpenShift Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +CGO_ENABLED=0 +GOOS=linux +TEST_IMAGES=$(shell find -L ./test/test_images ./vendor/knative.dev/serving/test/test_images/grpc-ping ./vendor/knative.dev/serving/test/test_images/multicontainer -mindepth 1 -maxdepth 2 -type f -name "*.go" -exec dirname {} \;) +TEST= +DOCKER_REPO_OVERRIDE= + +install: build + cp ./kn $(GOPATH)/bin +.PHONY: install + +build: + ./hack/build.sh -f +.PHONY: build + +build-cross: + ./hack/build.sh -x +.PHONY: build-cross + +build-cross-package: build-cross + ./package_cliartifacts.sh +.PHONY: build-cross-package + +test-install: + go install $(TEST_IMAGES) +.PHONY: test-install + +test-images: + for img in $(TEST_IMAGES); do \ + KO_DOCKER_REPO=$(DOCKER_REPO_OVERRIDE) ko resolve --tags=latest -RBf $$img/ ; \ + done +.PHONY: test-images + +test-unit: + ./hack/build.sh -t +.PHONY: test-unit + +test-e2e: + ./openshift/e2e-tests-openshift.sh +.PHONY: test-e2e + +# Run make DOCKER_REPO_OVERRIDE= test-e2e-local if test images are available +# in the given repository. Make sure you first build and push them there by running `make test-images`. +# Run make BRANCH= test-e2e-local if test images from the latest CI +# build for this branch should be used. Example: `make BRANCH=knative-v0.17.2 test-e2e-local`. +# If neither DOCKER_REPO_OVERRIDE nor BRANCH are defined the tests will use test images +# from the last nightly build. +# If TEST is defined then only the single test will be run. +test-e2e-local: + ./openshift/e2e-tests-local.sh $(TEST) +.PHONY: test-e2e-local + +# Generates a ci-operator configuration for a specific branch. +generate-ci-config: + ./openshift/ci-operator/generate-ci-config.sh $(BRANCH) > ci-operator-config.yaml +.PHONY: generate-ci-config diff --git a/OWNERS b/OWNERS index 24ec5a423d..7405d1f818 100644 --- a/OWNERS +++ b/OWNERS @@ -1,6 +1,7 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + approvers: -- client-writers -- technical-oversight-committee -- knative-release-leads +- knative-client-approvers + reviewers: -- client-reviewers +- knative-client-reviewers diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES index e16cb47212..feb847e2ee 100644 --- a/OWNERS_ALIASES +++ b/OWNERS_ALIASES @@ -1,220 +1,11 @@ -# This file is auto-generated from peribolos. -# Do not modify this file, instead modify peribolos/knative.yaml - aliases: - api-core-wg-leads: - - dprotaso - autoscaling-reviewers: - - nader-ziada - - psschwei - - taragu - autoscaling-wg-leads: - - julz - autoscaling-writers: - - julz - - yanweiguo - client-reviewers: - - itsmurugappan - client-wg-leads: + knative-client-approvers: + - alanfx - dsimansk - - navidshaikh - - rhuss - client-writers: - - dsimansk - - maximilien - - navidshaikh - - rhuss - conformance-task-force-leads: - - omerbensaadon - - salaboy - conformance-writers: - - omerbensaadon - - salaboy - docs-reviewers: - - RichardJJG - - mpetason - - nainaz - - omerbensaadon - - pmbanugo - - snneji - docs-wg-leads: - - csantanapr - - omerbensaadon - - snneji - docs-writers: - - RichardJJG - - abrennan89 - - carieshmarie - - csantanapr - - omerbensaadon - - richieescarez - - snneji - eventing-reviewers: - - aslom - - tayarani - - tommyreddad - eventing-triage: - - akashrv - - antoineco - - lberk - eventing-wg-leads: - - devguyio - - lionelvillard - eventing-writers: - - akashrv - - aliok - - antoineco - - devguyio - - lberk - - lionelvillard - - matzew - - pierDipi - - vaikas - knative-admin: - - csantanapr - - dprotaso - - duglin - - evankanderson - - julz - - knative-prow-releaser-robot - - knative-prow-robot - - knative-prow-updater-robot - - knative-test-reporter-robot - - lance - - markusthoemmes - matzew - - nak3 - - pmorie - rhuss - - spencerdillard - - thisisnotapril - - vaikas - knative-release-leads: - - matzew - - nak3 - knative-robots: - - knative-prow-releaser-robot - - knative-prow-robot - - knative-prow-updater-robot - - knative-test-reporter-robot - networking-reviewers: - - JRBANCEL - - ZhiminXiang - - andrew-su - - arturenault - - carlisia - - nak3 - - shashwathi - - tcnghia - - vagababov - - yanweiguo - networking-wg-leads: - - ZhiminXiang - - nak3 - networking-writers: - - JRBANCEL - - ZhiminXiang - - nak3 - - vagababov - operations-reviewers: - - Cynocracy - - aliok - - houshengbo - - jcrossley3 - - matzew - - trshafer - operations-wg-leads: - - houshengbo - operations-writers: - - Cynocracy - - aliok - - houshengbo - - jcrossley3 + knative-client-reviewers: + - alanfx + - dsimansk - matzew - - trshafer - pkg-configmap-reviewers: - - dprotaso - - mattmoor - - vagababov - pkg-configmap-writers: - - dprotaso - - mattmoor - - vagababov - pkg-controller-reviewers: - - dprotaso - - mattmoor - - tcnghia - - vagababov - - whaught - pkg-controller-writers: - - dprotaso - - mattmoor - - tcnghia - - vagababov - productivity-reviewers: - - albertomilan - - efiturri - - evankanderson - - gerardo-lc - - joshua-bone - - kvmware - - shinigambit - - steuhs - productivity-wg-leads: - - chizhg - - n3wscott - productivity-writers: - - chaodaiG - - chizhg - - coryrc - - n3wscott - security-wg-leads: - - evankanderson - - julz - security-writers: - - evankanderson - - julz - serving-observability-reviewers: - - skonto - - yanweiguo - serving-observability-writers: - - yanweiguo - serving-reviewers: - - carlisia - - julz - - nader-ziada - - nealhu - - psschwei - - whaught - serving-writers: - - dprotaso - - julz - - markusthoemmes - - tcnghia - - vagababov - source-wg-leads: - - lionelvillard - steering-committee: - - csantanapr - - lance - - pmorie - - thisisnotapril - - vaikas - technical-oversight-committee: - - dprotaso - - evankanderson - - julz - - markusthoemmes - rhuss - trademark-committee: - - duglin - - evankanderson - - spencerdillard - ux-wg-leads: - - csantanapr - - omerbensaadon - - snneji - ux-writers: - - csantanapr - - omerbensaadon - - snneji diff --git a/openshift-serverless-clients.spec b/openshift-serverless-clients.spec new file mode 100644 index 0000000000..5c979dfaab --- /dev/null +++ b/openshift-serverless-clients.spec @@ -0,0 +1,148 @@ +#debuginfo not supported with Go +%global debug_package %{nil} +%global package_name openshift-serverless-clients +%global product_name OpenShift Serverless +%global golang_version 1.17 +%global kn_version 0.26.0 +%global kn_release 1 +%global kn_cli_version v%{kn_version} +%global source_dir knative-client +%global source_tar %{source_dir}-%{kn_version}-%{kn_release}.tar.gz + +Name: %{package_name} +Version: %{kn_version} +Release: %{kn_release}%{?dist} +Summary: %{product_name} client kn CLI binary +License: ASL 2.0 +URL: https://github.com/openshift/knative-client/tree/release-%{kn_cli_version} + +Source0: %{source_tar} +BuildRequires: golang >= %{golang_version} +Provides: %{package_name} +Obsoletes: %{package_name} < %{kn_version} + +%description +Client kn provides developer experience to work with Knative Serving APIs. + +%prep +%setup -q -n %{source_dir} + +%build +TAG=%{kn_cli_version} make build-cross + +%install +mkdir -p %{buildroot}/%{_bindir} +install -m 0755 kn-linux-$(go env GOARCH) %{buildroot}/%{_bindir}/kn + +install -d %{buildroot}%{_datadir}/%{name}-redistributable/{linux,macos,windows} +install -p -m 755 kn-linux-amd64 %{buildroot}%{_datadir}/%{name}-redistributable/linux/kn-linux-amd64 +install -p -m 755 kn-linux-arm64 %{buildroot}%{_datadir}/%{name}-redistributable/linux/kn-linux-arm64 +install -p -m 755 kn-linux-ppc64le %{buildroot}%{_datadir}/%{name}-redistributable/linux/kn-linux-ppc64le +install -p -m 755 kn-linux-s390x %{buildroot}%{_datadir}/%{name}-redistributable/linux/kn-linux-s390x +install -p -m 755 kn-darwin-amd64 %{buildroot}/%{_datadir}/%{name}-redistributable/macos/kn-darwin-amd64 +install -p -m 755 kn-windows-amd64.exe %{buildroot}/%{_datadir}/%{name}-redistributable/windows/kn-windows-amd64.exe + +%files +%license LICENSE +%{_bindir}/kn + +%package redistributable +Summary: %{product_name} client CLI binaries for Linux, macOS and Windows +BuildRequires: golang >= %{golang_version} +Provides: %{package_name}-redistributable +Obsoletes: %{package_name} < %{kn_version} + +%description redistributable +%{product_name} client kn cross platform binaries for Linux, macOS and Windows. + +%files redistributable +%license LICENSE +%dir %{_datadir}/%{name}-redistributable/linux/ +%dir %{_datadir}/%{name}-redistributable/macos/ +%dir %{_datadir}/%{name}-redistributable/windows/ +%{_datadir}/%{name}-redistributable/linux/kn-linux-amd64 +%{_datadir}/%{name}-redistributable/linux/kn-linux-arm64 +%{_datadir}/%{name}-redistributable/linux/kn-linux-ppc64le +%{_datadir}/%{name}-redistributable/linux/kn-linux-s390x +%{_datadir}/%{name}-redistributable/macos/kn-darwin-amd64 +%{_datadir}/%{name}-redistributable/windows/kn-windows-amd64.exe + +%changelog +* Thu Nov 18 2021 David Simansky v0.26.0-1 +- Bump kn release v0.26.0 + +* Tue Nov 2 2021 David Simansky v0.25.1-1 +- Bump kn release v0.25.1 + +* Mon Sep 13 2021 David Simansky v0.24.0-1 +- Bump kn release v0.24.0 + +* Mon Aug 2 2021 David Simansky v0.23.2-1 +- Bump kn release v0.23.2 + +* Wed Jun 16 2021 David Simansky v0.22.0-1 +- Bump kn release v0.22.0 + +* Thu May 6 2021 David Simansky v0.21.0-1 +- Bump kn release v0.21.0 + +* Thu Mar 4 2021 David Simansky v0.20.0-1 +- Bump kn release v0.20.0 + +* Wed Jan 27 2021 David Simansky v0.19.1-2 +- Bump kn release v0.19.1-2 + +* Thu Dec 17 2020 Navid Shaikh v0.19.1-1 +- Bump kn release v0.19.1 + +* Wed Dec 09 2020 Navid Shaikh v0.18.4-1 +- Bump kn release v0.18.4 + +* Mon Oct 12 2020 Navid Shaikh v0.17.2-1 +- Bump kn release v0.17.2 + +* Thu Oct 8 2020 David Simansky v0.17.1-1 +- Bump kn release v0.17.1 + +* Wed Aug 26 2020 David Simansky v0.16.1-1 +- Bump kn release v0.16.1 + +* Mon Aug 17 2020 Navid Shaikh v0.15.2-1 +- Bump kn release v0.15.2 + +* Thu May 28 2020 David Simansky v0.14.0-1 +- Bump kn release v0.14.0 + +* Thu Apr 16 2020 Navid Shaikh v0.13.2-1 +- Bump kn release v0.13.2 + +* Mon Mar 09 2020 Navid Shaikh v0.13.1-1 +- Bump kn release v0.13.1 + +* Mon Mar 09 2020 Navid Shaikh v0.12.0-1 +- Bump kn release v0.12.0 + +* Wed Jan 22 2020 Navid Shaikh v0.11.0-1 +- Bump kn release v0.11.0 + +* Fri Dec 13 2019 Navid Shaikh v0.10.0-1 +- Bump kn release v0.10.0 + +* Fri Nov 08 2019 Navid Shaikh v0.9.0-1 +- Bump kn release v0.9.0 + +* Wed Aug 28 2019 Navid Shaikh v0.2.3-1 +- First tech preview release +- Uses dist macro to include the target platform in RPM name + +* Mon Aug 26 2019 Navid Shaikh v0.2.2-2 +- Initial tech preview release +- Uses license abbrevation ASL 2.0 for Apache Software License 2.0 +- bump the release to v0.2.2-2 + +* Mon Aug 26 2019 Navid Shaikh v0.2.2-1 +- Initial tech preview release +- bump the version to v0.2.2 + +* Tue Aug 20 2019 Navid Shaikh v0.2.1-1 +- Initial tech preview release diff --git a/openshift/ci-operator/build-image/Dockerfile b/openshift/ci-operator/build-image/Dockerfile new file mode 100644 index 0000000000..bf682f9507 --- /dev/null +++ b/openshift/ci-operator/build-image/Dockerfile @@ -0,0 +1,26 @@ +# Copyright 2019 The OpenShift Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Dockerfile to bootstrap build and test in openshift-ci +FROM registry.ci.openshift.org/openshift/release:golang-1.17 + +# Add kubernetes repository +ADD openshift/ci-operator/build-image/kubernetes.repo /etc/yum.repos.d/ + +RUN yum install -y kubectl ansible httpd-tools + +RUN GO111MODULE=on go get github.com/mikefarah/yq/v3 + +# Allow runtime users to add entries to /etc/passwd +RUN chmod g+rw /etc/passwd diff --git a/openshift/ci-operator/build-image/kubernetes.repo b/openshift/ci-operator/build-image/kubernetes.repo new file mode 100644 index 0000000000..795626ebca --- /dev/null +++ b/openshift/ci-operator/build-image/kubernetes.repo @@ -0,0 +1,7 @@ +[kubernetes] +name=Kubernetes +baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 +enabled=1 +gpgcheck=1 +repo_gpgcheck=0 +gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg diff --git a/openshift/ci-operator/generate-ci-config.sh b/openshift/ci-operator/generate-ci-config.sh new file mode 100755 index 0000000000..b4201955aa --- /dev/null +++ b/openshift/ci-operator/generate-ci-config.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +# Copyright 2019 The OpenShift Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [ -n "$1" ]; then + # Use provided branch value + branch=$1 +else + # Use current branch otherwise + branch=$(git rev-parse --abbrev-ref HEAD) +fi +version=$(echo ${branch} | cut -d '-' -f 2) +tag=${version:-'main'} +promotion=${branch/release/knative} + +cat < ci + cat openshift/release/knative-eventing-mtbroker-ci.yaml >> ci + + oc apply -f ci + rm ci + + # Wait for 5 pods to appear first + timeout 900 '[[ $(oc get pods -n $EVENTING_NAMESPACE --no-headers | wc -l) -lt 5 ]]' || return 1 + wait_until_pods_running $EVENTING_NAMESPACE || return 1 + header "Knative Eventing installed successfully" + popd +} + +install_serverless_operator_branch() { + local branch=$1 + local operator_dir=/tmp/serverless-operator + local failed=0 + header "Installing serverless operator from openshift-knative/serverless-operator branch $branch" + rm -rf $operator_dir + git clone --branch $branch https://github.com/openshift-knative/serverless-operator.git $operator_dir || failed=1 + pushd $operator_dir + # unset OPENSHIFT_BUILD_NAMESPACE (old CI) and OPENSHIFT_CI (new CI) as its used in serverless-operator's CI + # environment as a switch to use CI built images, we want pre-built images of k-s-o and k-o-i + unset OPENSHIFT_BUILD_NAMESPACE + unset OPENSHIFT_CI + + # Install all components Serving,Eventing,Strimzi and Kafka + make install-all || failed=1 + subheader "Successfully installed serverless operator." + + # Workaround default 'https' scheme + oc patch knativeserving.operator.knative.dev/knative-serving \ + --namespace knative-serving --type merge \ + --patch '{"spec":{"config":{"network":{"defaultExternalScheme":"http"}}}}' || return 1 + + header "Applying Strimzi Topic CR" + cat <<-EOF | oc apply -n kafka -f - || failed=1 +apiVersion: kafka.strimzi.io/v1beta1 +kind: KafkaTopic +metadata: + name: test-topic + labels: + strimzi.io/cluster: my-cluster +spec: + partitions: 100 + replicas: 1 +EOF + + popd + return $failed +} + +# Add to exec script if needed +resources_debug() { + echo ">> Check resources" + echo ">> - meminfo:" + cat /proc/meminfo + echo ">> - memory.limit_in_bytes" + cat /sys/fs/cgroup/memory/memory.limit_in_bytes + echo ">> - cpu.cfs_period_us" + cat /sys/fs/cgroup/cpu/cpu.cfs_period_us + echo ">> - cpu.cfs_quota_us" + cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us +} diff --git a/openshift/e2e-tests-local.sh b/openshift/e2e-tests-local.sh new file mode 100755 index 0000000000..8bd076fea3 --- /dev/null +++ b/openshift/e2e-tests-local.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# The script executes E2E tests + +source "$(dirname "$0")/e2e-common.sh" + +set +x + +failed=0 + +(( !failed )) && run_client_e2e_tests "" "${TEST}" || failed=1 +(( failed )) && exit 1 + +success diff --git a/openshift/e2e-tests-openshift.sh b/openshift/e2e-tests-openshift.sh new file mode 100755 index 0000000000..02f35bb86a --- /dev/null +++ b/openshift/e2e-tests-openshift.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# The script prepares Serving/Eventing instances on OpenShift and executes E2E tests + +source "$(dirname "$0")/e2e-common.sh" + +set -Eeuox pipefail + +failed=0 + +# Build binary & unit tests +(( !failed )) && build_knative_client || failed=1 +(( !failed )) && run_unit_tests || failed=1 + +if [[ "${PULL_BASE_REF:-}" == "release-next" ]]; then + # Midstream based setup to run on nightly versions of Serving & Eventing + # Serving setup & tests + (( !failed )) && install_knative_serving_branch "${SERVING_BRANCH}" || failed=1 + (( !failed )) && run_client_e2e_tests serving || failed=1 + # Eventing setup & tests + (( !failed )) && install_knative_eventing_branch "${EVENTING_BRANCH}" || failed=1 + (( !failed )) && run_client_e2e_tests eventing || failed=1 +else + # Serverless operator based setup for release branches + (( !failed )) && install_serverless_operator_branch "${SERVERLESS_BRANCH}" || failed=1 + (( !failed )) && run_client_e2e_tests serving || failed=1 + (( !failed )) && run_client_e2e_tests eventing || failed=1 +fi + +(( failed )) && exit 1 + +success diff --git a/openshift/release/README.md b/openshift/release/README.md new file mode 100644 index 0000000000..39d086f1a5 --- /dev/null +++ b/openshift/release/README.md @@ -0,0 +1,35 @@ +# Release creation + +## Branching + +As far as branching goes, we have two use-cases: + +1. Creating a branch based off an upstream release tag. +2. Having a branch that follow upstream's HEAD and serves as a vehicle for continuous integration. + +A prerequisite for both scripts is that your local clone of the repository has a remote "upstream" +that points to the upstream repository and a remote "openshift" that points to the openshift fork. + +Run the scripts from the root of the repository. + +### Creating a branch based off an upstream release tag + +To create a clean branch from an upstream release tag, use the `create-release-branch.sh` script: + +```bash +$ ./openshift/release/create-release-branch.sh v0.4.1 release-0.4 +``` + +This will create a new branch "release-0.4" based off the tag "v0.4.1" and add all OpenShift specific +files that we need to run CI on top of it. + +### Updating the release-next branch that follow upstream's HEAD + +To update a branch to the latest HEAD of upstream use the `update-to-head.sh` script: + +```bash +$ ./openshift/release/update-to-head.sh +``` + +That will pull the latest main from upstream, rebase the current fixes on the release-next branch +on top of it, update the Openshift specific files if necessary, and then trigger CI. \ No newline at end of file diff --git a/openshift/release/common.sh b/openshift/release/common.sh new file mode 100755 index 0000000000..207dcf86dd --- /dev/null +++ b/openshift/release/common.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# Collection of shared functions used to generate and prepare releases. + +ROOT_DIR=$(dirname $0)/../.. + +readonly FAAS_VERSION=${FAAS_VERSION:-"main"} +readonly FAAS_REPO=${FAAS_REPO:-"github.com/boson-project/faas"} + +# The vendor/ dir is omitted to be added separately +UPDATED_FILES=$(cat <> "${ROOT_DIR}/go.mod" +replace ( + github.com/boson-project/faas => github.com/boson-project/faas ${faas_version} + + // Pin conflicting dependency versions + // Buildpacks required version + github.com/docker/docker => github.com/docker/docker v1.4.2-0.20200221181110-62bd5a33f707 + // Darwin cross-build required version + golang.org/x/sys => golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 +) +EOF +} + +# Updates and pulls go dependencies, same as upstreams hack/build.sh::update. +mod_update() { + echo ":: Updating go dependencies ::" + go mod tidy + go mod vendor + + # Cleanup + find "./vendor" \( -name "OWNERS" -o -name "*_test.go" \) -print0 | xargs -0 rm -f +} + +# Creates new git commits with all the necessary files +add_files() { + echo ":: Adding faas as a plugin ${FAAS_VERSION}::" + local updated_files=$1 + pushd ${ROOT_DIR} + git add ${updated_files} + git commit -m ":space_invader: Add faas as a plugin ${FAAS_VERSION}" + # Create distinct commit for vendor/ dir + git add vendor + git commit -m ":open_file_folder: Update vendor dir for faas ${FAAS_VERSION}" + + popd +} + +# Wrapper to execute necessary steps to update faas dependencies. +update_faas_plugin() { + generate_file "${FAAS_REPO}" + mod_replace "${FAAS_VERSION}" + mod_update + add_files "${UPDATED_FILES}" +} diff --git a/openshift/release/create-release-branch.sh b/openshift/release/create-release-branch.sh new file mode 100755 index 0000000000..94922b6799 --- /dev/null +++ b/openshift/release/create-release-branch.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright 2019 The OpenShift Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Usage: create-release-branch.sh v0.4.1 release-0.4 + +release=$1 +target=$2 + +ROOT_DIR=$(dirname "$0")/../.. +source "$ROOT_DIR/openshift/release/common.sh" + +# Custom files +custom_files=$(cat < ci +git add ci +git commit -m ":robot: Triggering CI on branch 'release-next' after synching to upstream/main" +git push -f openshift release-next-ci + +if hash hub 2>/dev/null; then + # Test if there is already a sync PR in + COUNT=$(hub api -H "Accept: application/vnd.github.v3+json" repos/openshift/${REPO_NAME}/pulls --flat \ + | grep -c ":robot: Triggering CI on branch 'release-next' after synching to upstream/main") || true + if [ "$COUNT" = "0" ]; then + hub pull-request --no-edit -l "kind/sync-fork-to-upstream" -b openshift/${REPO_NAME}:release-next -h openshift/${REPO_NAME}:release-next-ci + fi +else + echo "hub (https://github.com/github/hub) is not installed, so you'll need to create a PR manually." +fi diff --git a/openshift/serverless/operator-install.yaml b/openshift/serverless/operator-install.yaml new file mode 100644 index 0000000000..c582a7d03b --- /dev/null +++ b/openshift/serverless/operator-install.yaml @@ -0,0 +1,34 @@ +# Copyright 2019 The OpenShift Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: operators.coreos.com/v1 +kind: CatalogSourceConfig +metadata: + name: ci-serverless-operator + namespace: openshift-marketplace +spec: + targetNamespace: openshift-operators + packages: serverless-operator + source: redhat-operators +--- +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + name: serverless-operator + namespace: openshift-operators +spec: + channel: techpreview + name: serverless-operator + source: ci-serverless-operator + sourceNamespace: openshift-operators diff --git a/package_cliartifacts.sh b/package_cliartifacts.sh new file mode 100755 index 0000000000..03e7358d03 --- /dev/null +++ b/package_cliartifacts.sh @@ -0,0 +1,52 @@ +# This script is used to package kn cross platform cli artifacts +# for kn-cli-artifacts image +# Copyright 2020 The OpenShift Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +pkg_tar() { + local dir + case "$1" in + amd64|arm64|ppc64le|s390x) + dir=linux-$1 + mkdir "${OUTDIR}/${dir}" + mv kn-linux-$1 ${OUTDIR}/${dir}/kn + chmod +x ${OUTDIR}/${dir}/kn + ;; + macos) + dir=macos-amd64 + mkdir "${OUTDIR}/${dir}" + mv kn-darwin-amd64 ${OUTDIR}/${dir}/kn + chmod +x ${OUTDIR}/${dir}/kn + ;; + esac + cp LICENSE ${OUTDIR}/${dir} + tar -zcf kn-${dir}.tar.gz -C ${OUTDIR}/${dir} . +} + +pkg_zip_for_windows() { + mkdir "${OUTDIR}/windows" + mv kn-windows-amd64.exe ${OUTDIR}/windows/kn.exe + cp LICENSE ${OUTDIR}/windows/ + zip --quiet --junk-path - ${OUTDIR}/windows/* > kn-windows-amd64.zip +} + +OUTDIR=$(mktemp -dt knbinary.XXXXXXXXXX) +trap "rm -rf '${OUTDIR}'" EXIT INT TERM + +pkg_tar amd64 +pkg_tar arm64 +pkg_tar ppc64le +pkg_tar s390x +pkg_tar macos +pkg_zip_for_windows