-
-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (86 loc) · 3.34 KB
/
before-cd-test.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
on:
push:
paths-ignore:
- jobs/vector.nomad
- terraform/vector.tf
pull_request:
jobs:
# This name is used by status check requirement
before-cd-test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install Nomad and Consul
run: |
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install -y nomad consul
echo "nomad_version: $(nomad -v)"
echo "consul_version: $(consul -v)"
- name: Validate job files
run: |
shopt -s globstar
for job in **/*.nomad; do
nomad job validate "$job";
done
- name: Start a Nomad Agent and a Consul agent
run: |
sudo nomad agent -dev-connect -config nomad/development.hcl &>/dev/null &
consul agent -dev -bootstrap &>/dev/null &
- name: Wait for initializing...
timeout-minutes: 5
run: |
RETRY=$((SECONDS+60))
until nomad node status > /dev/null; do
if [ $SECONDS -gt $RETRY ]; then
echo 'Nomad is not booted after 60 seconds, kill...'
if [ -n "$(pidof nomad)" ]; then sudo kill "$(pidof nomad)"; fi
sudo nomad agent -dev -config nomad/development.hcl &>/dev/null &
RETRY=$((SECONDS+60))
fi
sleep 1
done;
- name: Run a Nomad job
run: |
for job in jobs/development/*.nomad; do
nomad job run -detach "$job"
done
- name: Access MediaWiki until success
timeout-minutes: 5
run: |
echo 'Waiting for http...'
until curl -sLfo /dev/null localhost:8080; do
sleep 1; done
- name: Test VisualEditor API
run: |
curl -sSLvo /dev/null "http://localhost:8080/api.php?action=visualeditor&page=arbitrary_page&paction=parse&wikitext=arbitrary"
curl -sSLvo /dev/null "http://localhost:8080/localhost/v1/"
- name: backup of accessing
if: ${{ failure() }}
run: |
echo 'Failed to connect to localhost:8080';
function header {
line="--------------------------------------------------------"
echo -e "$line\n$1\n$line"
}
header "journalctl"
journalctl -u nomad
header "docker images"
docker image ls --no-trunc
header "nomad status"
nomad status
for JOB in mysql memcached fastcgi http; do
header "nomad job '$JOB' status"
nomad job status "$JOB"
allocs=$(nomad job status "$JOB" | awk '/Allocations/,0' | tail -n +3 | awk '{if($6=="failed")print $1}')
for ALLOC in $allocs; do
header "[$JOB] Allocation '$ALLOC' status"
nomad alloc status "$ALLOC";
task=$(nomad alloc status -short "$ALLOC" | tail -n1 | awk '{print $1}')
header "[$JOB] Allocation '$ALLOC' stdout logs "
nomad alloc logs "$ALLOC" $task;
header "[$JOB] Allocation '$ALLOC' stderr logs "
nomad alloc logs -stderr "$ALLOC" $task;
done
done
curl -sSLv localhost:8080 || true