-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (102 loc) · 3.12 KB
/
test.yml
File metadata and controls
117 lines (102 loc) · 3.12 KB
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
name: Test
on:
push:
pull_request:
permissions:
contents: read
jobs:
test-pre-deploy:
name: Test pre-deploy notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Start mock server
shell: bash
run: |
while true; do
echo -e "HTTP/1.1 201 Created\r\nContent-Type: application/json\r\nContent-Length: 2\r\n\r\n{}" \
| nc -l 8080 -q 1
done &
sleep 0.5
- name: Run action (pre-deploy)
uses: ./
with:
api-token: test-token
shipyrd-url: http://localhost:8080
status: pre-deploy
destination: staging
test-post-deploy:
name: Test post-deploy notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Start mock server
shell: bash
run: |
while true; do
echo -e "HTTP/1.1 201 Created\r\nContent-Type: application/json\r\nContent-Length: 2\r\n\r\n{}" \
| nc -l 8080 -q 1
done &
sleep 0.5
- name: Run action (post-deploy, default status)
uses: ./
with:
api-token: test-token
shipyrd-url: http://localhost:8080
test-failed:
name: Test failed notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Start mock server
shell: bash
run: |
while true; do
echo -e "HTTP/1.1 201 Created\r\nContent-Type: application/json\r\nContent-Length: 2\r\n\r\n{}" \
| nc -l 8080 -q 1
done &
sleep 0.5
- name: Run action (failed)
uses: ./
with:
api-token: test-token
shipyrd-url: http://localhost:8080
status: failed
test-auth-failure:
name: Test auth failure exits non-zero
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Start mock server (returns 401)
shell: bash
run: |
while true; do
echo -e "HTTP/1.1 401 Unauthorized\r\nContent-Type: application/json\r\nContent-Length: 24\r\n\r\n{\"error\":\"Invalid token\"}" \
| nc -l 8080 -q 1
done &
sleep 0.5
- name: Run action (should fail)
id: notify
uses: ./
continue-on-error: true
with:
api-token: bad-token
shipyrd-url: http://localhost:8080
- name: Verify step failed
env:
NOTIFY_OUTCOME: ${{ steps.notify.outcome }}
shell: bash
run: |
if [ "$NOTIFY_OUTCOME" != "failure" ]; then
echo "Expected action to fail on 401 but it succeeded"
exit 1
fi
echo "Correctly failed on 401"