-
Notifications
You must be signed in to change notification settings - Fork 368
171 lines (147 loc) · 5.35 KB
/
check-network.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: k0s Check Network
on:
workflow_dispatch:
inputs:
prNumber:
description: PR against which to this workflow
required: false
schedule:
- cron: "0 23 * * *"
jobs:
check-network:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_TERRAFORM_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_TERRAFORM_KEY }}
AWS_DEFAULT_REGION: eu-west-1
TF_VERSION: 1.2.2
KUBECONFIG: ${{ github.workspace }}/kubeconfig
name: "K8s Network Conformance Testing"
if: github.repository == 'k0sproject/k0s'
runs-on: ubuntu-latest
outputs:
k0s_version: ${{ steps.bin_info.outputs.K0S_VERSION }}
kubernetes_version: ${{ steps.k0s_build.outputs.KUBERNETES_VERSION }}
defaults:
run:
working-directory: ./inttest/sonobuoy/terraform
steps:
- name: Get PR Reference
env:
INPUT_PRNUMBER: ${{ github.event.inputs.prNumber }}
run: |
# check if a an input to override the reference is set
if [[ ${INPUT_PRNUMBER} != "" ]]; then
GIT_REF="refs/pull/${INPUT_PRNUMBER}/merge"
echo "github_ref=$GIT_REF" >> $GITHUB_ENV
exit 0
else
# PR number was not set manually
echo "no manual override: leaving GitHub reference unchanged."
echo "github_ref=$GITHUB_REF" >> $GITHUB_ENV
fi
working-directory: ./
- name: Run git checkout
uses: actions/checkout@v4
with:
ref: ${{ env.github_ref }}
# Dev builds rely on "git describe --tags" to set the binary version
fetch-depth: 0
- name: Prepare build environment
working-directory: ./
run: .github/workflows/prepare-build-env.sh
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TF_VERSION }}
- name: Terraform Init
run: terraform init
- name: Cache embedded binaries
uses: actions/cache@v3
with:
key: ${{ runner.os }}-embedded-bins-linux-${{ hashFiles('embedded-bins/**/*') }}
path: |
.bins.linux.stamp
bindata_linux
embedded-bins/staging/linux/bin/
embedded-bins/Makefile.variables
pkg/assets/zz_generated_offsets_linux.go
- name: Cache GOCACHE
uses: actions/cache@v3
with:
key: ${{ runner.os }}-build-gocache-linux-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-gocache-linux-${{ github.ref_name }}-
path: |
build/cache/go/build
- name: Cache GOMODCACHE
uses: actions/cache@v3
with:
key: ${{ runner.os }}-build-gomodcache-linux-${{ hashFiles('go.sum') }}
path: |
build/cache/go/mod
- name: Build k0s Binary
id: k0s_build
run: |
make build
KUBERNETES_VERSION="$(./vars.sh kubernetes_version)"
echo KUBERNETES_VERSION="$KUBERNETES_VERSION" >> $GITHUB_OUTPUT
working-directory: ./
- name: Set k0s' Version
id: bin_info
run: |
# run k0s version
K0S_VER=$("$GITHUB_WORKSPACE/k0s" version)
if [ -z "$K0S_VER" ]; then
echo "empty k0s version. failing..."
exit 1
fi
echo K0S_VERSION="$K0S_VER" >> $GITHUB_OUTPUT
- name: Terraform Apply
env:
TF_VAR_k0s_version: ${{ steps.bin_info.outputs.K0S_VERSION }}
TF_VAR_k0s_binary_path: ${{ github.workspace }}/k0s
run: |
PR_NUMBER=$(echo ${GITHUB_REF} | cut -d / -f 3 )
export TF_VAR_cluster_name="k0s_pr_${PR_NUMBER}"
# debug
echo "k0s_version = ${TF_VAR_k0s_version}"
# Start SSH Agent
eval `ssh-agent -s`
terraform apply -auto-approve
- name: Set k0sctl version
run: |
version=$(cd hack/tool; go list -m -f '{{.Version}}' github.com/k0sproject/k0sctl)
echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV
- name: Create k0s Cluster using k0sctl
id: k0sctl
run: |
# download k0sctl
curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl
chmod +x ./k0sctl
./k0sctl apply -c k0sctl.yaml
# save kubeconfig file
./k0sctl kubeconfig > $KUBECONFIG
- name: Run Sonobuoy
run: make check-network
working-directory: ./inttest
- name: Terraform Destroy
env:
TF_VAR_k0s_version: ${{ steps.bin_info.outputs.K0S_VERSION }}
run: |
PR_NUMBER=$(echo ${GITHUB_REF} | cut -d / -f 3 )
export TF_VAR_cluster_name="k0s_pr_${PR_NUMBER}"
terraform destroy -auto-approve
if: ${{ always() }}
- name: slack notify
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
uses: 8398a7/action-slack@v3
with:
job_name: "K8s Network Conformance Testing"
status: ${{ job.status }}
fields: workflow,ref,commit,author,job,took # selectable (default: repo,message)
if: ${{ always() }} # Pick up events even if the job fails or is canceled.