Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 639b9d3

Browse files
committed
retries
1 parent 4369765 commit 639b9d3

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

.github/workflows/ci.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ jobs:
382382
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
383383
fi
384384
export TS_DEBUG_DISCO=true
385-
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
385+
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" --rerun-fails=2 \
386386
--packages="./..." -- $PARALLEL_FLAG -short -failfast
387387
388388
- name: Upload Test Cache
@@ -436,6 +436,7 @@ jobs:
436436
TS_DEBUG_DISCO: "true"
437437
LC_CTYPE: "en_US.UTF-8"
438438
LC_ALL: "en_US.UTF-8"
439+
TEST_RETRIES: 2
439440
shell: bash
440441
run: |
441442
# By default Go will use the number of logical CPUs, which
@@ -499,6 +500,7 @@ jobs:
499500
TS_DEBUG_DISCO: "true"
500501
LC_CTYPE: "en_US.UTF-8"
501502
LC_ALL: "en_US.UTF-8"
503+
TEST_RETRIES: 2
502504
shell: bash
503505
run: |
504506
# By default Go will use the number of logical CPUs, which
@@ -560,6 +562,7 @@ jobs:
560562
env:
561563
POSTGRES_VERSION: "16"
562564
TS_DEBUG_DISCO: "true"
565+
TEST_RETRIES: 2
563566
run: |
564567
make test-postgres
565568
@@ -784,6 +787,7 @@ jobs:
784787
if: ${{ !matrix.variant.premium }}
785788
env:
786789
DEBUG: pw:api
790+
CODER_E2E_TEST_RETRIES: 2
787791
working-directory: site
788792

789793
# Run all of the tests with a premium license
@@ -793,6 +797,7 @@ jobs:
793797
DEBUG: pw:api
794798
CODER_E2E_LICENSE: ${{ secrets.CODER_E2E_LICENSE }}
795799
CODER_E2E_REQUIRE_PREMIUM_TESTS: "1"
800+
CODER_E2E_TEST_RETRIES: 2
796801
working-directory: site
797802

798803
- name: Upload Playwright Failed Tests

Makefile

+10-2
Original file line numberDiff line numberDiff line change
@@ -875,12 +875,19 @@ provisioner/terraform/testdata/version:
875875
fi
876876
.PHONY: provisioner/terraform/testdata/version
877877

878+
# Set the retry flags if TEST_RETRIES is set
879+
ifdef TEST_RETRIES
880+
GOTESTSUM_RETRY_FLAGS := --rerun-fails=$(TEST_RETRIES)
881+
else
882+
GOTESTSUM_RETRY_FLAGS :=
883+
endif
884+
878885
test:
879-
$(GIT_FLAGS) gotestsum --format standard-quiet -- -v -short -count=1 ./... $(if $(RUN),-run $(RUN))
886+
$(GIT_FLAGS) gotestsum --format standard-quiet $(GOTESTSUM_RETRY_FLAGS) -- -v -short -count=1 ./... $(if $(RUN),-run $(RUN))
880887
.PHONY: test
881888

882889
test-cli:
883-
$(GIT_FLAGS) gotestsum --format standard-quiet -- -v -short -count=1 ./cli/...
890+
$(GIT_FLAGS) gotestsum --format standard-quiet $(GOTESTSUM_RETRY_FLAGS) -- -v -short -count=1 ./cli/...
884891
.PHONY: test-cli
885892

886893
# sqlc-cloud-is-setup will fail if no SQLc auth token is set. Use this as a
@@ -919,6 +926,7 @@ test-postgres: test-postgres-docker
919926
$(GIT_FLAGS) DB=ci gotestsum \
920927
--junitfile="gotests.xml" \
921928
--jsonfile="gotests.json" \
929+
$(GOTESTSUM_RETRY_FLAGS) \
922930
--packages="./..." -- \
923931
-timeout=20m \
924932
-failfast \

coderd/ai/ai_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package ai_test
2+
3+
import (
4+
"crypto/rand"
5+
"math/big"
6+
"testing"
7+
)
8+
9+
func TestXD(t *testing.T) {
10+
t.Parallel()
11+
12+
n, err := rand.Int(rand.Reader, big.NewInt(10))
13+
if err != nil {
14+
t.Fatal(err)
15+
}
16+
17+
t.Logf("n: %d", n)
18+
19+
if n.Int64() > 2 {
20+
t.Fatalf("n is greater than 2")
21+
}
22+
}

site/e2e/playwright.config.ts

+18
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,30 @@ import {
1010
} from "./constants";
1111

1212
export const wsEndpoint = process.env.CODER_E2E_WS_ENDPOINT;
13+
export const retries = (() => {
14+
if (process.env.CODER_E2E_TEST_RETRIES === undefined) {
15+
return undefined;
16+
}
17+
const count = Number.parseInt(process.env.CODER_E2E_TEST_RETRIES, 10);
18+
if (Number.isNaN(count)) {
19+
throw new Error(
20+
`CODER_E2E_TEST_RETRIES is not a number: ${process.env.CODER_E2E_TEST_RETRIES}`,
21+
);
22+
}
23+
if (count < 0) {
24+
throw new Error(
25+
`CODER_E2E_TEST_RETRIES is less than 0: ${process.env.CODER_E2E_TEST_RETRIES}`,
26+
);
27+
}
28+
return count;
29+
})();
1330

1431
const localURL = (port: number, path: string): string => {
1532
return `http://localhost:${port}${path}`;
1633
};
1734

1835
export default defineConfig({
36+
retries,
1937
globalSetup: require.resolve("./setup/preflight"),
2038
projects: [
2139
{

0 commit comments

Comments
 (0)