Skip to content

Commit a67a1e9

Browse files
add pipeline
1 parent 94e9820 commit a67a1e9

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

codefresh.yaml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# More examples of Codefresh YAML can be found at
2+
# https://codefresh.io/docs/docs/yaml-examples/examples/
3+
4+
version: "1.0"
5+
mode: parallel
6+
# Stages can help you organize your steps in stages
7+
stages:
8+
- "clone"
9+
- "build"
10+
- "test"
11+
12+
steps:
13+
clone:
14+
title: "Cloning repository"
15+
type: "git-clone"
16+
repo: "codefresh-contrib/vcluster-prometheus-operator-plugin"
17+
revision: "${{CF_BRANCH}}"
18+
git: "codefresh-git-integration-contrib"
19+
stage: "clone"
20+
21+
export_image_tag:
22+
title: "Export image tag"
23+
type: freestyle
24+
stage: build
25+
image: alpine
26+
commands:
27+
- |
28+
export isRelease="${{RELEASE}}"
29+
if [[ "$isRelease" == "true" ]]; then
30+
export IMAGE_TAG="${{CF_RELEASE_TAG}}"
31+
else
32+
export IMAGE_TAG="${{CF_BRANCH_TAG_NORMALIZED_LOWER_CASE}}"
33+
fi
34+
35+
cf_export IMAGE_TAG
36+
37+
38+
build_v1:
39+
title: "Build v1"
40+
type: build
41+
stage: "build"
42+
working_directory: '${{clone}}/v1'
43+
build_arguments:
44+
- BUILDKIT_INLINE_CACHE=1
45+
image_name: "${{CF_REPO_NAME}}"
46+
tag: "v1-${{IMAGE_TAG}}"
47+
registry: "ghcr-codefresh-contrib"
48+
platform: 'linux/amd64,linux/arm64'
49+
buildx:
50+
builder:
51+
driver_opts: "image=moby/buildkit:v0.14.1"
52+
cache_from:
53+
- ghcr.io/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}:v1-${{CF_BRANCH_TAG_NORMALIZED_LOWER_CASE}}
54+
- ghcr.io/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}:v1-main
55+
when:
56+
steps:
57+
- name: clone
58+
on:
59+
- success
60+
- name: export_image_tag
61+
on:
62+
- success
63+
64+
build_v2:
65+
title: "Build v2"
66+
type: build
67+
stage: "build"
68+
build_arguments:
69+
- BUILDKIT_INLINE_CACHE=1
70+
working_directory: '${{clone}}/v2'
71+
image_name: "${{CF_REPO_NAME}}"
72+
tag: "v2-${{IMAGE_TAG}}"
73+
registry: "ghcr-codefresh-contrib"
74+
platform: 'linux/amd64,linux/arm64'
75+
buildx:
76+
builder:
77+
driver_opts: "image=moby/buildkit:v0.14.1"
78+
cache_from:
79+
- ghcr.io/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}:v2-${{CF_BRANCH_TAG_NORMALIZED_LOWER_CASE}}
80+
- ghcr.io/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}:v2-main
81+
when:
82+
steps:
83+
- name: clone
84+
on:
85+
- success
86+
- name: export_image_tag
87+
on:
88+
- success
89+
90+
91+
create_clusters:
92+
title: 'Create k3d clusters'
93+
stage: test
94+
type: freestyle
95+
image: 'ghcr.io/k3d-io/k3d:5.5.2-dind'
96+
commands:
97+
- export NETWORK=$(docker network ls | grep bridge | tail -1 | awk '{print $2}')
98+
- export FULL_CLUSTER_NAME_V1="k3d-test-prom-vcluster-plugin-v1"
99+
- export FULL_CLUSTER_NAME_V2="k3d-test-prom-vcluster-plugin-v2"
100+
- export CLUSTER_IMAGE="rancher/k3s:v1.24.4-k3s1"
101+
- k3d cluster create $FULL_CLUSTER_NAME_V1 --network $NETWORK -i $CLUSTER_IMAGE --no-lb
102+
- k3d cluster create $FULL_CLUSTER_NAME_V2 --network $NETWORK -i $CLUSTER_IMAGE --no-lb
103+
- export CLUSTER_IP_V1=$(docker inspect k3d-$FULL_CLUSTER_NAME_V1-server-0 | jq -r '.[0].NetworkSettings.IPAddress')
104+
- export CLUSTER_IP_V2=$(docker inspect k3d-$FULL_CLUSTER_NAME_V2-server-0 | jq -r '.[0].NetworkSettings.IPAddress')
105+
- yq e -i '(.clusters[] | select(.name=="k3d-"+env(FULL_CLUSTER_NAME_V1)) | .cluster.server) = "https://"+env(CLUSTER_IP_V1)+":6443"' $KUBECONFIG
106+
- yq e -i '(.clusters[] | select(.name=="k3d-"+env(FULL_CLUSTER_NAME_V2)) | .cluster.server) = "https://"+env(CLUSTER_IP_V2)+":6443"' $KUBECONFIG
107+
- export V1_KUBE_CONTEXT=k3d-$FULL_CLUSTER_NAME_V1
108+
- export V2_KUBE_CONTEXT=k3d-$FULL_CLUSTER_NAME_V2
109+
- cf_export FULL_CLUSTER_NAME_V1 V1_KUBE_CONTEXT FULL_CLUSTER_NAME_V2 V2_KUBE_CONTEXT
110+
111+
init_test_envs:
112+
stage: test
113+
title: 'Init test environments'
114+
image: "dtzar/helm-kubectl:3.15"
115+
working_directory: '${{clone}}'
116+
commands:
117+
- curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/download/v0.20.0-beta.11/vcluster-linux-amd64" && chmod +x ./vcluster && mv ./vcluster /usr/local/bin/vcluster
118+
- kubectl config use-context $V1_KUBE_CONTEXT
119+
- v1/.e2e/scripts/init.sh "${{steps.build_v1.imageId}}"
120+
- kubectl config use-context $V2_KUBE_CONTEXT
121+
- v2/.e2e/scripts/init.sh "${{steps.build_v2.imageId}}"
122+
when:
123+
steps:
124+
- name: create_clusters
125+
on:
126+
- success
127+
- name: build_v1
128+
on:
129+
- success
130+
- name: build_v2
131+
on:
132+
- success
133+
134+
run_chainsaw_tests:
135+
stage: test
136+
title: 'Run chainsaw tests'
137+
image: 'ghcr.io/kyverno/chainsaw:v0.2.5'
138+
working_directory: '${{clone}}'
139+
commands:
140+
- chainsaw test --kube-context $V1_KUBE_CONTEXT --test-file .e2e/chainsaw-tests.yaml --skip-delete
141+
- chainsaw test --kube-context $V2_KUBE_CONTEXT --test-file .e2e/chainsaw-tests.yaml --skip-delete
142+
when:
143+
steps:
144+
- name: init_test_envs
145+
on:
146+
- success

0 commit comments

Comments
 (0)