-
Notifications
You must be signed in to change notification settings - Fork 5
164 lines (143 loc) · 5.44 KB
/
integration.yml
File metadata and controls
164 lines (143 loc) · 5.44 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
155
156
157
158
159
160
161
162
163
164
name: Integration
on:
workflow_dispatch:
push:
tags:
- "v*-rc*"
permissions:
contents: read
jobs:
integration:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build gh-devlake
run: go build -o gh-devlake .
- name: Prepare dedicated deploy directory
run: mkdir -p ./devlake-local
- name: Deploy DevLake locally (GitHub runner)
if: ${{ !env.ACT }}
working-directory: ./devlake-local
run: ../gh-devlake deploy local --dir . --source official --start
- name: Deploy DevLake locally (act)
if: ${{ env.ACT }}
working-directory: ./devlake-local
run: |
../gh-devlake deploy local --dir . --source official --start=false
sed -i 's/^API_TIMEOUT=.*/API_TIMEOUT=30s/' .env
sed -i 's/^API_RETRY=.*/API_RETRY=1/' .env
docker compose up -d
- name: Set DevLake URL
run: |
if [ -n "${ACT:-}" ]; then
echo "DEVLAKE_URL=http://host.docker.internal:8080" >> "$GITHUB_ENV"
echo "GRAFANA_URL=http://host.docker.internal:4000/grafana" >> "$GITHUB_ENV"
echo "CONFIG_UI_URL=http://host.docker.internal:4000" >> "$GITHUB_ENV"
else
echo "DEVLAKE_URL=http://localhost:8080" >> "$GITHUB_ENV"
echo "GRAFANA_URL=http://localhost:4000/grafana" >> "$GITHUB_ENV"
echo "CONFIG_UI_URL=http://localhost:4000" >> "$GITHUB_ENV"
fi
- name: Wait for DevLake API
run: |
for i in $(seq 1 36); do
code=$(curl -s -o /dev/null -w '%{http_code}' "$DEVLAKE_URL/ping" || true)
if [ "$code" = "200" ]; then
echo "DevLake API is ready"
exit 0
fi
echo "Waiting for DevLake API... ($i/36) status=$code"
sleep 10
done
echo "DevLake not ready after 6 minutes" >&2
if [ -d ./devlake-local ]; then
docker compose -f ./devlake-local/docker-compose.yml logs devlake || true
fi
exit 1
- name: Trigger migration
run: |
curl -sf "$DEVLAKE_URL/proceed-db-migration" >/dev/null || true
- name: Wait for migration completion
run: |
for i in $(seq 1 60); do
code=$(curl -s -o /dev/null -w '%{http_code}' "$DEVLAKE_URL/ping" || true)
if [ "$code" = "200" ]; then
echo "Migration complete"
exit 0
fi
echo "Migrating... ($i/60) status=$code"
sleep 5
done
echo "Migration did not complete in time" >&2
exit 1
- name: Verify service health
run: |
curl -sf "$DEVLAKE_URL/ping"
curl -sf "$CONFIG_UI_URL"
curl -sf "$GRAFANA_URL/api/health"
- name: Local act mode note
if: ${{ env.ACT }}
run: |
echo "Running in local act mode: stopping after deploy+health smoke checks."
echo "Full connection/scope/project E2E runs on GitHub runners (workflow_dispatch or v*-rc* tags)."
- name: Configure GitHub connection
if: ${{ !env.ACT }}
timeout-minutes: 6
env:
DEVLAKE_TEST_PAT: ${{ secrets.DEVLAKE_TEST_PAT }}
DEVLAKE_TEST_ORG: ${{ secrets.DEVLAKE_TEST_ORG }}
run: |
if [ -z "$DEVLAKE_TEST_PAT" ]; then
echo "DEVLAKE_TEST_PAT secret is required" >&2
exit 1
fi
TEST_ORG="${DEVLAKE_TEST_ORG:-DevExpGbb}"
curl -sf \
-H "Authorization: Bearer $DEVLAKE_TEST_PAT" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/user >/dev/null
./gh-devlake configure connection add \
--url "$DEVLAKE_URL" \
--plugin github \
--org "$TEST_ORG" \
--token "$DEVLAKE_TEST_PAT" \
--endpoint https://api.github.com \
--name "ci-test"
- name: Dump DevLake logs on connection failure
if: ${{ !env.ACT && failure() }}
run: |
if [ -d ./devlake-local ]; then
docker compose -f ./devlake-local/docker-compose.yml logs --tail=200 devlake || true
fi
- name: Configure GitHub scopes
if: ${{ !env.ACT }}
env:
DEVLAKE_TEST_ORG: ${{ secrets.DEVLAKE_TEST_ORG }}
DEVLAKE_TEST_REPO: ${{ secrets.DEVLAKE_TEST_REPO }}
run: |
TEST_ORG="${DEVLAKE_TEST_ORG:-DevExpGbb}"
TEST_REPO="${DEVLAKE_TEST_REPO:-DevExpGbb/gh-devlake}"
./gh-devlake configure scope \
--url "$DEVLAKE_URL" \
--plugin github \
--org "$TEST_ORG" \
--repos "$TEST_REPO"
- name: Create project and trigger first sync
if: ${{ !env.ACT }}
run: |
printf "1\n" | ./gh-devlake configure project --url "$DEVLAKE_URL" --project-name ci-test
- name: Check status
if: ${{ !env.ACT }}
run: ./gh-devlake status --url "$DEVLAKE_URL"
- name: Cleanup stack
if: always()
run: |
if [ -d ./devlake-local ]; then
cd ./devlake-local
docker compose down -v
fi