-
Notifications
You must be signed in to change notification settings - Fork 11
172 lines (152 loc) · 5.87 KB
/
push.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
172
name: Install applications on Kubernetes
on:
pull_request:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
jobs:
install:
runs-on: self-hosted
steps:
- name: Cleanup
continue-on-error: true
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- run: pip install -r test/features/requirements.txt
- name: Install dependencies
env:
HELM_VERSION: "v3.16.3"
HELM_DIFF_VERSION: "3.9.12"
HELMFILE_VERSION: "v0.169.1"
YQ_VERSION: "v4.44.3"
run: |
./.github/ci_config/bin/install-dependencies
- name: Prepare the environment (add secrets and enable installation of all components)
run: |
DNAME='CN=CI,O=TheHyve,L=Utrecht,C=NL' ./bin/init
helmfile_mods='\ \ \ \ \ \ - ../.github/ci_config/ci-config.yaml\n'
helmfile_mods+='\ \ \ \ \ \ - ../.github/ci_config/secrets.yaml.gotmpl'
sed -i "/secrets.yaml/a $helmfile_mods" environments.yaml
sed -i '/_install: /s/false/true/' etc/production.yaml
# Deploy a minimal deployment accessible on 'localhost:80' with monitoring enabled
sed -i '/enable_logging_monitoring: /s/false/true/' etc/production.yaml
sed -i '/dev_deployment: /s/false/true/' etc/production.yaml
sed -i '/e2e_test: /s/false/true/' etc/production.yaml
- name: Ensure k3d cache directory exists
run: |
mkdir -p $HOME/k3d-containerd
test-helmfile-template:
needs: install
runs-on: self-hosted
steps:
- name: Test helmfile template
env:
FIREBASE_ADMINSDK_JSON: ${{ secrets.FIREBASE_ADMINSDK_JSON }}
run: |
helmfile template > /tmp/helmfile.yaml
delete-old-clusters:
runs-on: self-hosted
needs: test-helmfile-template
steps:
- name: Delete old clusters
run: |
k3d cluster delete --all || true
matrix-prep:
runs-on: self-hosted
needs: delete-old-clusters
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: nelonoel/[email protected]
- id: set-matrix
uses: JoshuaTheMiller/conditional-build-matrix@main
with:
# inputFile: '.github/workflows/matrix_includes.json' # Default input file path
filter: '[?runOnBranch==`${{ env.BRANCH_NAME }}` || runOnBranch==`always`]'
addInclude: true
test-k8s-versions:
needs: matrix-prep
runs-on: self-hosted
strategy:
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
steps:
- uses: nolar/setup-k3d-k3s@v1
with:
version: ${{ matrix.K3S_VERSION }}
k3d-args: --k3s-arg --disable=traefik@server:0 --k3s-arg --disable-helm-controller@server:0 --config .github/ci_config/k3d-config.yaml
# Note: k3d adds a 'k3d-' prefix to this name
k3d-name: ${{ matrix.KUBECTL_VERSION }}
# TODO would be better to do this with a command line parameter. I have been unable to get this to work.
- name: Set kubeContext
run: |
sed -i "s/kubeContext: .*/kubeContext: k3d-${{ matrix.KUBECTL_VERSION }}/" etc/production.yaml
- name: Install RADAR-Kubernetes
env:
FIREBASE_ADMINSDK_JSON: ${{ secrets.FIREBASE_ADMINSDK_JSON }}
run: |
echo "kubeconfig: $KUBECONFIG"
kubectl get pods --all-namespaces --context k3d-${{ matrix.KUBECTL_VERSION }}
helmfile sync
- name: Run end-to-end tests
run: |
cd test/features
behave -D secrets_file=$GITHUB_WORKSPACE/etc/secrets.yaml -D url=http://localhost:80 # Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Manually triggered tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true
- name: Slack Notification
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: ci-notifications
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_MESSAGE: 'The job has failed, go to https://github.com/RADAR-base/RADAR-Kubernetes/actions and use SSH for more information'
SLACK_TITLE: Post Title
SLACK_USERNAME: rtCamp
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: Setup tmate session if jobs have failed
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
with:
limit-access-to-actor: true
- name: Report cluster state
if: always()
run: |
kubectl get pods --all-namespaces
# TODO We can remove the k3s uninstallation once the k3d PR is merged.
- name: Delete clusters when job was canceled
if: cancelled()
run: |
k3d cluster delete --all || true
k3s-uninstall.sh || true
check-gitignore:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check gitignore
run: |
echo "Checking whether any files that should be ignored are uploaded"
echo
if find . -not -path './.git/*' -type f | git check-ignore --stdin --no-index; then
echo
echo "Remove the above files from this branch"
exit 1
else
echo "No ignored files have been added"
fi