-
Notifications
You must be signed in to change notification settings - Fork 86
156 lines (136 loc) Β· 4.68 KB
/
e2e.yml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Usage: /ok-to-test [k8s-version]
# Examples:
# /ok-to-test
# /ok-to-test v1.18.4
name: e2e
on:
issue_comment:
types: [created]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
if: contains(github.event.issue.html_url, '/pull/') && startsWith(github.event.comment.body, '/ok-to-test')
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Checkout pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
sudo mv bin/hub /usr/local/bin
hub pr checkout $PR_NUMBER
- name: Login Docker
env:
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: 1gtm
run: |
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
- name: Build
env:
REGISTRY: appscodeci
run: |
make push
config:
runs-on: ubuntu-20.04
needs: build
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
name: Generate test matrix
run: |
k8s=(v1.20.15 v1.22.15 v1.24.7 v1.26.0)
IFS=' '
read -ra COMMENT <<< "${{ github.event.comment.body }}"
if [ ! -z ${COMMENT[1]} ]; then
k8s=(${COMMENT[1]})
fi
matrix=()
for x in ${k8s[@]}; do
matrix+=( $( jq -n -c --arg x "$x" '{"k8s":$x}' ) )
done
# https://stackoverflow.com/a/63046305/244009
function join { local IFS="$1"; shift; echo "$*"; }
matrix=$(echo "{"include":[$(join , ${matrix[@]})]}")
echo $matrix
echo "::set-output name=matrix::$matrix"
kubernetes:
name: Kubernetes
needs: config
runs-on: ubuntu-20.04
strategy:
matrix: ${{ fromJson(needs.config.outputs.matrix) }}
steps:
- uses: actions/checkout@v1
- name: Checkout pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
sudo mv bin/hub /usr/local/bin
hub pr checkout $PR_NUMBER
- name: Create Kubernetes ${{ matrix.k8s }} cluster
id: kind
uses: engineerd/[email protected]
with:
version: v0.17.0
config: hack/kubernetes/kind.yaml
image: kindest/node:${{ matrix.k8s }}
- name: Prepare cluster for testing
id: local-path
env:
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: 1gtm
REGISTRY_SECRET: regcred
run: |
echo "waiting for nodes to be ready ..."
kubectl wait --for=condition=Ready nodes --all --timeout=5m
kubectl get nodes
echo
kubectl version
echo
echo "create docker-registry secret"
kubectl create secret docker-registry ${REGISTRY_SECRET} --namespace=kube-system --docker-server=https://index.docker.io/v1/ --docker-username=${USERNAME} --docker-password=${DOCKER_TOKEN}
- name: Install NFS server dependencies
run: |
nodes=$(kubectl get nodes -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{end}')
for i in $nodes
do
echo "Installing NFS server dependencies in node: $i ...."
docker exec $i apt-get update
docker exec $i apt-get install -y nfs-kernel-server
done
- name: Check out installer
run: |
cd ..
git clone https://github.com/stashed/installer.git
cd installer
git checkout master
- name: Run e2e tests
env:
REGISTRY: appscodeci
REGISTRY_SECRET: regcred
TEST_CREDENTIALS: ${{ secrets.TEST_CREDENTIALS }}
GOOGLE_SERVICE_ACCOUNT_JSON_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON_KEY }}
run: |
echo "preparing test credentials"
mkdir -p hack/config
echo -n "$TEST_CREDENTIALS" > hack/config/.env
echo >> hack/config/.env
echo "GOOGLE_SERVICE_ACCOUNT_JSON_KEY=$(echo $GOOGLE_SERVICE_ACCOUNT_JSON_KEY)" >> hack/config/.env
make install
echo
sleep 10
make e2e-parallel