-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vincent Demeester <[email protected]>
- Loading branch information
1 parent
7866b50
commit 3627bf5
Showing
7 changed files
with
153 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
permissions: | ||
contents: read | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
push: | ||
branches: [main] | ||
branches: ["**"] | ||
schedule: | ||
- cron: "0 0 * * *" | ||
workflow_dispatch: | ||
|
@@ -18,12 +21,13 @@ name: build-test-publish | |
jobs: | ||
go: | ||
runs-on: ubuntu-latest | ||
# if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Set up Go | ||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 | ||
with: | ||
go-version: "1.21" | ||
go-version: "1.22" | ||
- run: go env | ||
- name: go build | ||
run: go build -v ./... | ||
|
@@ -37,24 +41,23 @@ jobs: | |
e2e: | ||
name: e2e tests | ||
runs-on: ubuntu-latest | ||
env: | ||
KUBECONFIG: /home/runner/.kube/config.kind | ||
# if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere | ||
needs: [go] | ||
steps: | ||
- uses: ko-build/[email protected] | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: azure/setup-helm@v4 | ||
# instantiate a KinD (Kubernetes in Docker) cluster, installs `kubectl` and configures the | ||
# `kubeconfig` to reach the local cluster | ||
- uses: helm/[email protected] | ||
with: | ||
cluster_name: kind | ||
wait: 120s | ||
# - uses: helm/[email protected] | ||
# with: | ||
# cluster_name: kind | ||
# wait: 120s | ||
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 | ||
with: | ||
go-version: "1.21.x" | ||
- uses: openshift-pipelines/setup-tektoncd@v1 | ||
with: | ||
pipeline_version: v0.56.1 | ||
feature_flags: '{"enable-step-actions": "true"}' | ||
go-version: "1.22" | ||
|
||
- name: Setup tmate session | ||
uses: mxschmitt/action-tmate@v3 | ||
|
@@ -63,18 +66,26 @@ jobs: | |
limit-access-to-actor: true | ||
detached: true | ||
|
||
- name: Install kind | ||
run: | | ||
set -euxfo pipefail | ||
./hack/kind-install.sh | ||
- uses: tektoncd/actions/setup-tektoncd@main | ||
with: | ||
pipeline_version: v0.61.1 | ||
feature_flags: '{"enable-step-actions": "true"}' | ||
setup_registry: false | ||
- name: tests | ||
env: | ||
OSP_PAC_GITHUB_TOKEN: ${{ secrets.OSP_PAC_GITHUB_TOKEN }} | ||
OSP_PAC_USERNAME: os-pac | ||
# env: | ||
# OSP_PAC_GITHUB_TOKEN: ${{ secrets.OSP_PAC_GITHUB_TOKEN }} | ||
# OSP_PAC_USERNAME: os-pac | ||
run: | | ||
set -euxfo pipefail | ||
REGISTRY=registry.registry.svc.cluster.local:32222 | ||
KO_DOCKER_REPO=ghcr.io/openshift-pipelines/tekton-caches | ||
KO_DOCKER_REPO=localhost:5000/tekton-caches | ||
IMAGE_REF="${KO_DOCKER_REPO}/cache:$(git rev-parse HEAD | tr -d '\n')" | ||
echo "${OSP_PAC_GITHUB_TOKEN}" | ko login ghcr.io --username ${OSP_PAC_USERNAME} --password-stdin | ||
kubectl -n registry get deployment | ||
kubectl -n registry port-forward deployment/registry 5000:5000 & | ||
make e2e | ||
|
@@ -90,14 +101,15 @@ jobs: | |
-w name=gomodcache,emptyDir= --showlog | ||
tkn task start cache-upload-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | ||
tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | ||
tkn task start cache-upload-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | ||
tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | ||
tkn task start cache-upload-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | ||
tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog | ||
tkn taskrun list | ||
kubectl get taskrun -o yaml | ||
publish: | ||
name: publish latest | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere | ||
needs: [go] | ||
|
||
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | ||
|
@@ -107,7 +119,7 @@ jobs: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 | ||
with: | ||
go-version: "1.21" | ||
go-version: "1.22" | ||
- id: meta | ||
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # 5.5.1 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env bash | ||
# This setups kind for running e2e tests on it. | ||
# | ||
# This targets both local setup (with docker or podman) and github workflows. | ||
|
||
set -euf | ||
cd $(dirname $(readlink -f ${0})) | ||
|
||
export KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-kind} | ||
export KUBECONFIG=${HOME}/.kube/config.${KIND_CLUSTER_NAME} | ||
export DOMAIN_NAME=caches-127-0-0-1.nip.io | ||
export DOCKER=${DOCKER:-docker} | ||
|
||
TMPD=$(mktemp -d /tmp/.GITXXXX) | ||
REG_PORT='5000' | ||
REG_NAME='kind-registry' | ||
# SUDO=sudo | ||
# [[ $(uname -s) == "Darwin" ]] && { | ||
# SUDO= | ||
# } | ||
SUDO= | ||
|
||
if ! builtin type -p kind &>/dev/null; then | ||
echo "Install kind. https://kind.sigs.k8s.io/docs/user/quick-start/#installation" | ||
exit 1 | ||
fi | ||
kind=$(type -p kind) | ||
|
||
# cleanup on exit (useful for running locally) | ||
cleanup() { rm -rf ${TMPD}; } | ||
trap cleanup EXIT | ||
|
||
function start_registry() { | ||
running="$(${DOCKER} inspect -f '{{.State.Running}}' ${REG_NAME} 2>/dev/null || echo false)" | ||
|
||
if [[ ${running} != "true" ]]; then | ||
${DOCKER} rm -f kind-registry || true | ||
${DOCKER} run \ | ||
-d --restart=always -p "127.0.0.1:${REG_PORT}:5000" \ | ||
-e REGISTRY_HTTP_SECRET=secret \ | ||
--name "${REG_NAME}" \ | ||
registry:2 | ||
fi | ||
} | ||
|
||
|
||
function install_kind() { | ||
if [[ ${DOCKER} == "podman" ]]; then | ||
export KIND_EXPERIMENTAL_PROVIDER=podman | ||
fi | ||
${SUDO} $kind delete cluster --name ${KIND_CLUSTER_NAME} || true | ||
sed "s,%DOCKERCFG%,${HOME}/.docker/config.json," kind.yaml >${TMPD}/kconfig.yaml | ||
|
||
cat <<EOF >>${TMPD}/kconfig.yaml | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${REG_PORT}"] | ||
endpoint = ["http://${REG_NAME}:5000"] | ||
EOF | ||
|
||
${SUDO} ${kind} create cluster --name ${KIND_CLUSTER_NAME} --config ${TMPD}/kconfig.yaml | ||
mkdir -p $(dirname ${KUBECONFIG}) | ||
${SUDO} ${kind} --name ${KIND_CLUSTER_NAME} get kubeconfig >${KUBECONFIG} | ||
|
||
${DOCKER} network connect "kind" "${REG_NAME}" 2>/dev/null || true | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: local-registry-hosting | ||
namespace: kube-public | ||
data: | ||
localRegistryHosting.v1: | | ||
host: "localhost:${REG_PORT}" | ||
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" | ||
EOF | ||
|
||
} | ||
|
||
main() { | ||
start_registry | ||
install_kind | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
networking: | ||
apiServerAddress: 127.0.0.1 | ||
apiServerPort: 8443 | ||
nodes: | ||
- role: control-plane | ||
kubeadmConfigPatches: | ||
- | | ||
kind: InitConfiguration | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
node-labels: "ingress-ready=true" | ||
extraMounts: | ||
- containerPath: /var/lib/kubelet/config.json | ||
hostPath: "%DOCKERCFG%" | ||
# extraPortMappings: | ||
# - containerPort: 80 | ||
# hostPort: 80 | ||
# protocol: TCP | ||
# - containerPort: 443 | ||
# hostPort: 443 | ||
# protocol: TCP | ||
# - containerPort: 32567 | ||
# hostPort: 3000 | ||
# protocol: TCP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters