-
Notifications
You must be signed in to change notification settings - Fork 9
136 lines (132 loc) · 4.86 KB
/
pr-test-and-build.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
# Name: pr-test-and-build.yaml
# Author: Mathew Fleisch <mathew.fleisch@gmail.com>
# Description: This action will run go lint/unit tests as well as
# build a docker container and test it against a KinD cluster.
# See Makefile for more details.
name: PR CI
on:
pull_request:
branches:
- main
jobs:
unit_test:
name: Lint and Unit Tests
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Install stuff with asdf
uses: asdf-vm/actions/install@v1
with:
tool_versions: |
action-validator 0.1.2
dockle 0.4.5
helm 3.8.1
yq 4.22.1
-
name: Lint Actions
run: make --no-print-directory lint-actions
# -
# name: Lint Container Using Dockle
# env:
# DOCKER_CONTENT_TRUST: 1
# run: |
# make --no-print-directory docker-build
# make --no-print-directory docker-lint
integration_test:
name: KinD Integration Tests
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Install stuff with asdf
uses: asdf-vm/actions/install@v1
with:
tool_versions: |
helm 3.8.1
yq 4.22.1
-
name: KinD Tests
shell: bash
env:
CONFIGJSON: ${{ secrets.CONFIGJSON }}
ENVFILE: ${{ secrets.ENVFILE }}
run: |
if [ -z "${CONFIGJSON}" ]; then
echo "Loading fallback configuration" \
&& cp configuration.json local.json;
else
echo "Loading override configuration" \
&& echo "${{ secrets.CONFIGJSON }}" | base64 -d | sed -e 's/\r//' > local.json;
fi
if [ -z "${ENVFILE}" ]; then
echo "Problem loading github secret ENVFILE"
else
echo "Loading secrets" \
&& echo "${{ secrets.ENVFILE }}" | base64 -d | sed -e 's/\r//' | sed -e 's/configuration\.json/local.json/g' > .env \
&& source .env
fi
ls -alF
echo "DB_SEED_FILEPATH=$DB_SEED_FILEPATH"
echo "DB_HOST=$DB_HOST"
echo "DB_NAME=$DB_NAME"
echo "DB_PASS=$DB_PASS"
echo "DB_USER=$DB_USER"
echo "DB_DUMP_FILENAME=$DB_DUMP_FILENAME"
echo "DB_CONTAINER_NAME=$DB_CONTAINER_NAME"
echo "REPO_OWNER=$REPO_OWNER"
echo "BOT_CONTAINER_NAME=$BOT_CONTAINER_NAME"
echo "BOT_CONFIGURATION_FILEPATH=$BOT_CONFIGURATION_FILEPATH"
make help
echo "Building KinD cluster" \
&& make --no-print-directory kind-create
echo "Building docker container and load into KinD cluster" \
&& make --no-print-directory kind-load
echo "Running tests..." \
&& make --no-print-directory kind-test
sleep 5
echo "Delete (restart) AGIMUS pod now that MySQL should be running and seeded..."
kubectl --namespace agimus delete pod $(kubectl --namespace agimus get pods | grep agimus | awk '{print $1}') || true
sleep 3
echo "If after 20 seconds the string 'BOT IS ONLINE AND READY FOR COMMANDS' is not present in the logs, the test has failed..."
timeout 20s kubectl --namespace agimus logs -f $(kubectl --namespace agimus get pods | grep agimus | awk '{print $1}') || true
bash_test="$(kubectl --namespace agimus logs $(kubectl --namespace agimus get pods | grep agimus | awk '{print $1}') | grep 'BOT IS ONLINE AND READY FOR COMMANDS')"
echo "$bash_test"
if [[ -n "$bash_test" ]]; then
echo "AGIMUS is online!!!"
exit 0
else
echo "AGIMUS is NOT online!!!"
exit 1
fi
-
name: Debug
if: ${{ always() }}
shell: bash
env:
CONFIGJSON: ${{ secrets.CONFIGJSON }}
run: |
make help
ls -alF
echo "Deployments:"
kubectl --namespace agimus get deployments -o wide
echo "Pods:"
kubectl --namespace agimus get pods -o wide
echo "Secrets:"
kubectl --namespace agimus get secrets
echo "Configmaps:"
kubectl --namespace agimus get configmaps
echo "Agimus Config:"
kubectl --namespace agimus get configmaps agimus-config -o jsonpath='{.data.local\.json}' | jq '.' || true
echo "Describe Agimus pod:"
kubectl --namespace agimus describe pod $(kubectl --namespace agimus get pods | grep agimus | awk '{print $1}') || true
echo "Logs:"
kubectl --namespace agimus logs $(kubectl --namespace agimus get pods | grep agimus | awk '{print $1}') || true