-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodefresh.yaml
113 lines (104 loc) · 3.38 KB
/
codefresh.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# More examples of Codefresh YAML can be found at
# https://codefresh.io/docs/docs/yaml-examples/examples/
version: "1.0"
mode: parallel
# Stages can help you organize your steps in stages
stages:
- "prepare"
- "clone"
- "build"
- "test"
steps:
preapre_env:
title: "Prepare variables"
type: freestyle
stage: prepare
image: alpine
commands:
- |
export isRelease="${{RELEASE}}"
if [[ "$isRelease" == "true" ]]; then
export IMAGE_TAG="${{CF_RELEASE_TAG}}"
export CLONE_REVISION="${{CF_RELEASE_TAG}}"
else
export IMAGE_TAG="${{CF_BRANCH_TAG_NORMALIZED_LOWER_CASE}}"
export CLONE_REVISION="${{CF_BRANCH}}"
fi
cf_export IMAGE_TAG CLONE_REVISION
clone:
title: "Cloning repository"
type: "git-clone"
repo: "codefresh-contrib/vcluster-prometheus-operator-plugin"
revision: "${{CLONE_REVISION}}"
git: "codefresh-git-integration-contrib"
stage: "clone"
when:
steps:
- name: preapre_env
on:
- success
build:
title: "Build image"
type: build
stage: "build"
build_arguments:
- BUILDKIT_INLINE_CACHE=1
working_directory: '${{clone}}'
image_name: "${{CF_REPO_NAME}}"
tag: "${{IMAGE_TAG}}"
registry: "ghcr-codefresh-contrib"
platform: 'linux/amd64,linux/arm64'
buildx:
builder:
driver_opts: "image=moby/buildkit:v0.14.1"
cache_from:
- ghcr.io/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}:${{IMAGE_TAG}}
- ghcr.io/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}:main
when:
steps:
- name: clone
on:
- success
create_cluster:
title: 'Create k3d clusters'
stage: test
type: freestyle
image: 'ghcr.io/k3d-io/k3d:5.5.2-dind'
commands:
- export NETWORK=$(docker network ls | grep bridge | tail -1 | awk '{print $2}')
- export FULL_CLUSTER_NAME="k3d-test-prom-vcluster-plugin"
- export CLUSTER_IMAGE="rancher/k3s:v1.24.4-k3s1"
- k3d cluster create $FULL_CLUSTER_NAME --network $NETWORK -i $CLUSTER_IMAGE --no-lb
- export CLUSTER_IP=$(docker inspect k3d-$FULL_CLUSTER_NAME-server-0 | jq -r '.[0].NetworkSettings.IPAddress')
- yq e -i '(.clusters[] | select(.name=="k3d-"+env(FULL_CLUSTER_NAME)) | .cluster.server) = "https://"+env(CLUSTER_IP)+":6443"' $KUBECONFIG
- export KUBE_CONTEXT=k3d-$FULL_CLUSTER_NAME
- cf_export FULL_CLUSTER_NAME KUBE_CONTEXT
init_test_envs:
stage: test
title: 'Init test environments'
image: "dtzar/helm-kubectl:3.15"
working_directory: '${{clone}}'
commands:
- curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/download/v0.23.0/vcluster-linux-amd64" && chmod +x ./vcluster && mv ./vcluster /usr/local/bin/vcluster
- kubectl config use-context $KUBE_CONTEXT
- .e2e/scripts/init.sh "${{steps.build.imageId}}"
when:
steps:
- name: create_cluster
on:
- success
- name: build
on:
- success
run_chainsaw_tests:
stage: test
title: 'Run chainsaw tests'
image: 'ghcr.io/kyverno/chainsaw:v0.2.5'
working_directory: '${{clone}}'
commands:
- chainsaw test --kube-context $KUBE_CONTEXT --test-file .e2e/chainsaw-tests.yaml --skip-delete
when:
steps:
- name: init_test_envs
on:
- success