-
Notifications
You must be signed in to change notification settings - Fork 3
154 lines (134 loc) · 5.57 KB
/
test.yaml
File metadata and controls
154 lines (134 loc) · 5.57 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
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
name: End-to-end test
on:
push:
paths:
- .github/**
schedule:
- cron: '0 4,16 * * *'
workflow_dispatch:
jobs:
test-last-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Helm
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Minikube
uses: medyagh/setup-minikube@master
- name: Check cluster pods
run: kubectl get pods -A
- name: 1. Add Helm repository
run: helm repo add betterstack-logs https://betterstackhq.github.io/logs-helm-chart && helm repo update
- name: 2. Set up Helm chart
run: sed -e 's/$SOURCE_TOKEN/${{ secrets.HELM_E2E_TEST_SOURCE_TOKEN }}/g' -e 's/$INGESTING_HOST/${{ secrets.HELM_E2E_TEST_INGESTING_HOST }}/g' .github/helm-values-template.yaml > values.yaml
- name: 3. Deploy the chart
run: helm install betterstack-logs betterstack-logs/betterstack-logs -f values.yaml
- name: List the used Helm release version
run: helm list
- name: Wait for the chart to be ready
run: kubectl wait --for=condition=available deployment/betterstack-logs-metrics-server --timeout=60s
- name: Check cluster pods
run: kubectl get pods -A
- name: Deploy Hello World pod
run: kubectl run hello-world --image=hello-world --wait
- name: Check cluster pods
run: kubectl get pods -A
- name: Wait for a while with the running pods
run: sleep 60
- name: Check cluster pods
run: kubectl get pods -A
- name: Show logs from Vector pod for debugging
run: kubectl logs -l app.kubernetes.io/name=vector
- name: Check if all pods are running
run: kubectl get pods -A -o jsonpath='{range .items[*]}{.status.phase}{"\n"}{end}' | grep -qv "^Running$" && echo "Not all pods are running" && exit 1 || echo "OK"
notify-linear:
if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.event_name == 'schedule') }}
needs: [test-last-release]
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- name: "Gather failure context"
id: ctx
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FAILED=$(gh api \
"repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs" \
--paginate \
--jq '[.jobs[]
| select(.conclusion == "failure")
| "- **\(.name)** — failed at _\([.steps[] | select(.conclusion == "failure") | .name] | join(", "))_"]
| join("\n")')
if [ -z "$FAILED" ]; then
FAILED="_(no failed jobs reported by the API yet)_"
fi
{
echo "failed_jobs<<CTXEOF"
echo "$FAILED"
echo "CTXEOF"
} >> "$GITHUB_OUTPUT"
- name: "Create Linear issue"
env:
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
LINEAR_TEAM_ID: ${{ secrets.LINEAR_TEAM_ID }}
LINEAR_STATUS_ID: ${{ secrets.LINEAR_STATUS_PLAN_ID }}
LINEAR_PROJECT_ID: ${{ secrets.LINEAR_PROJECT_ID }}
LINEAR_ASSIGNEE_ID: ${{ secrets.LINEAR_ASSIGNEE_ID }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
EVENT_NAME: ${{ github.event_name }}
SHA: ${{ github.sha }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
FAILED_JOBS: ${{ steps.ctx.outputs.failed_jobs }}
run: |
SHORT_SHA="${SHA:0:7}"
# head_commit is only populated on push events; skip the line otherwise
COMMIT_LINE="**Commit:** \`$SHORT_SHA\`"
if [ -n "$COMMIT_MESSAGE" ]; then
COMMIT_SUBJECT="$(printf '%s' "$COMMIT_MESSAGE" | head -n1)"
COMMIT_LINE="**Commit:** \`$SHORT_SHA\` — $COMMIT_SUBJECT"
fi
ATTEMPT_NOTE=""
if [ "$RUN_ATTEMPT" != "1" ]; then
ATTEMPT_NOTE=" (attempt #$RUN_ATTEMPT)"
fi
TITLE="E2E failure: ${{ github.workflow }} (${{ github.repository }})"
DESCRIPTION=$(cat <<EOF
**${{ github.workflow }}** failed on \`${{ github.ref_name }}\` in \`${{ github.repository }}\` via \`$EVENT_NAME\`$ATTEMPT_NOTE
**Failing jobs:**
$FAILED_JOBS
$COMMIT_LINE
[View failing run]($RUN_URL)
EOF
)
PAYLOAD=$(jq -n \
--arg query 'mutation IssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { identifier url } } }' \
--arg title "$TITLE" \
--arg description "$DESCRIPTION" \
--arg teamId "$LINEAR_TEAM_ID" \
--arg assigneeId "$LINEAR_ASSIGNEE_ID" \
--arg stateId "$LINEAR_STATUS_ID" \
--arg projectId "$LINEAR_PROJECT_ID" \
'{
query: $query,
variables: {
input: {
title: $title,
description: $description,
teamId: $teamId,
assigneeId: $assigneeId,
stateId: $stateId,
projectId: $projectId,
priority: 2
}
}
}')
curl -sSf -X POST https://api.linear.app/graphql \
-H "Authorization: $LINEAR_API_KEY" \
-H 'Content-Type: application/json' \
-d "$PAYLOAD"