Skip to content

Commit cf8de8c

Browse files
committed
try fixing ci
1 parent fd7977f commit cf8de8c

File tree

4 files changed

+46
-77
lines changed

4 files changed

+46
-77
lines changed

.github/actions/provision-zulip/action.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -135,28 +135,3 @@ runs:
135135
run: |
136136
echo "site_url=${ZULIP_URL}" >> "$GITHUB_OUTPUT"
137137
echo "log_path=${ZULIP_DEV_LOG}" >> "$GITHUB_OUTPUT"
138-
139-
- name: Upload Zulip log
140-
if: always()
141-
uses: actions/upload-artifact@v4
142-
with:
143-
name: zulip-log-${{ inputs.zulip_ref }}-${{ github.job }}-${{ github.run_attempt }}
144-
path: ${{ env.ZULIP_DEV_LOG }}
145-
if-no-files-found: ignore
146-
retention-days: 7
147-
148-
- name: Show log on failure
149-
if: failure()
150-
shell: bash
151-
run: |
152-
echo "===== zulip-dev.log ====="
153-
tail -n +1 "${ZULIP_DEV_LOG}" || true
154-
155-
- name: Stop Zulip
156-
if: always()
157-
shell: bash
158-
run: |
159-
if [ -f "${ZULIP_RUN_PID}" ]; then
160-
kill "$(cat "${ZULIP_RUN_PID}")" || true
161-
fi
162-
pkill -f "tools/run-dev" || true
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Stop Zulip
2+
description: Collect logs and shut down a Zulip dev server
3+
4+
inputs:
5+
zulip_ref:
6+
description: Zulip git ref (branch/tag/commit)
7+
required: false
8+
default: main
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Upload Zulip log
14+
if: always()
15+
uses: actions/upload-artifact@v4
16+
with:
17+
name: zulip-log-${{ inputs.zulip_ref }}-${{ github.job }}-${{ github.run_attempt }}
18+
path: ${{ env.ZULIP_DEV_LOG }}
19+
if-no-files-found: ignore
20+
retention-days: 7
21+
22+
- name: Show log on failure
23+
if: failure()
24+
shell: bash
25+
run: |
26+
echo "===== zulip-dev.log ====="
27+
tail -n +1 "${ZULIP_DEV_LOG}" || true
28+
29+
- name: Stop Zulip
30+
if: always()
31+
shell: bash
32+
run: |
33+
if [ -f "${ZULIP_RUN_PID}" ]; then
34+
kill "$(cat "${ZULIP_RUN_PID}")" || true
35+
fi
36+
pkill -f "tools/run-dev" || true

.github/workflows/integration-tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ jobs:
5656
with:
5757
zulip_ref: ${{ matrix.zulip_ref }}
5858

59-
- name: Give Zulip some time to settle
60-
shell: bash
61-
run: |
62-
echo "Waiting 30 seconds for Zulip to settle..."
63-
sleep 30
64-
6559
- name: Run go test suite with coverage
6660
run: go test ./... -covermode=atomic -coverprofile=coverage.out -timeout 60m
6761

@@ -77,6 +71,12 @@ jobs:
7771
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7872
ZULIP_BRANCH: ${{ matrix.zulip_ref }}
7973

74+
- name: Stop Zulip
75+
if: always()
76+
uses: ./.github/actions/stop-zulip
77+
with:
78+
zulip_ref: ${{ matrix.zulip_ref }}
79+
8080
godoc:
8181
name: Godoc
8282
runs-on: arc-runner-set

internal/test_utils/utils.go

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"io"
1010
"math/rand/v2"
1111
"mime/multipart"
12-
"net"
1312
"net/http"
1413
"net/url"
1514
"os"
@@ -86,7 +85,6 @@ func GetBotClient(t *testing.T) client.Client {
8685
t.Helper()
8786
rc := createBot(t, "test-bot")
8887
client, err := client.NewClient(rc,
89-
client.WithHTTPClient(newHTTPClientForTestSite()),
9088
client.SkipWarnOnInsecureTLS(),
9189
client.EnableStatistics())
9290
require.NoError(t, err)
@@ -193,49 +191,14 @@ func getTestClient(t *testing.T, username string) (*z.RC, client.Client) {
193191

194192
apiClient, err := client.NewTestClient(rc,
195193
client.SkipWarnOnInsecureTLS(),
196-
client.EnableStatistics(),
197-
client.WithHTTPClient(newHTTPClientForTestSite()))
194+
client.EnableStatistics())
198195
if err != nil {
199196
t.Fatalf("Failed to create z.client: %v", err)
200197
}
201198

202199
return rc, apiClient
203200
}
204201

205-
func newHTTPClientForTestSite() *http.Client {
206-
const timeout = 30 * time.Second
207-
const keepAlive = 30 * time.Second
208-
209-
baseTransport, ok := http.DefaultTransport.(*http.Transport)
210-
if !ok {
211-
panic("default transport is not an *http.Transport")
212-
}
213-
214-
transport := baseTransport.Clone()
215-
dialer := &net.Dialer{
216-
Timeout: timeout,
217-
KeepAlive: keepAlive,
218-
}
219-
220-
transport.DialContext = func(ctx context.Context, network, address string) (net.Conn, error) {
221-
host, port, err := net.SplitHostPort(address)
222-
if err != nil {
223-
return nil, err
224-
}
225-
if host == "localhost" || host == "::1" {
226-
host = "127.0.0.1"
227-
}
228-
return dialer.DialContext(ctx, network, net.JoinHostPort(host, port))
229-
}
230-
231-
return &http.Client{
232-
Transport: transport,
233-
Timeout: http.DefaultClient.Timeout,
234-
CheckRedirect: http.DefaultClient.CheckRedirect,
235-
Jar: http.DefaultClient.Jar,
236-
}
237-
}
238-
239202
type UserInfo struct {
240203
APIKey string `json:"api_key"`
241204
EMail string `json:"email"`
@@ -251,10 +214,7 @@ func fetchUserInfo(t *testing.T, username string) UserInfo {
251214
attemptDelay = 3 * time.Second
252215
)
253216

254-
httpClient := newHTTPClientForTestSite()
255-
if httpClient == nil {
256-
httpClient = http.DefaultClient
257-
}
217+
httpClient := http.DefaultClient
258218

259219
for attempt := range numAttempts {
260220
info, done := getUserInfo(t, httpClient, username, attempt)
@@ -303,7 +263,7 @@ func getUserInfo(t *testing.T, client *http.Client, username string, attempt int
303263
t.Fatalf("Empty API key received for user %s", username)
304264
}
305265
if result.EMail != username {
306-
t.Fatalf("Unexpected email in API key Response: got %s, want %s", result.EMail, username)
266+
t.Fatalf("Unexpected email in API key response: got %s, want %s", result.EMail, username)
307267
}
308268
return result, true
309269
}
@@ -436,9 +396,7 @@ func createBot(t *testing.T, botName string) *z.RC {
436396
req.SetBasicAuth(rc.Email, rc.APIKey)
437397
req.Header.Set("Content-Type", w.FormDataContentType())
438398

439-
httpClient := newHTTPClientForTestSite()
440-
441-
resp, err := httpClient.Do(req)
399+
resp, err := http.DefaultClient.Do(req)
442400
require.NoError(t, err)
443401
defer resp.Body.Close()
444402

0 commit comments

Comments
 (0)