-
Notifications
You must be signed in to change notification settings - Fork 100
83 lines (80 loc) · 2.16 KB
/
pre-commit.yml
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
name: pre-commit
on:
pull_request:
push:
branches: [main]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'
- name: Install Go tools
run: |
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
tests:
runs-on: ubuntu-latest
needs: pre-commit
services:
docker:
image: docker:19.03.12
options: --privileged # required for nested containers
ports:
- 2375:2375
volumes:
- /var/lib/docker
steps:
- name: Set up Docker environment
run: |
docker info
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'
- name: Checkout code
uses: actions/checkout@v3
- name: Add entry to /etc/hosts
run: |
echo "127.0.0.1 hal.computers.com" | sudo tee -a /etc/hosts
- name: Run Go tests with retries
env:
TEST_GIT_TOKEN: ${{ secrets.TEST_GIT_TOKEN }}
run: |
max_attempts=5
attempt_num=1
until [ $attempt_num -gt $max_attempts ]
do
echo "Attempt $attempt_num of $max_attempts"
go test -p 1 ./... && break || echo "Test failed. Retrying..."
attempt_num=$((attempt_num + 1))
if [ $attempt_num -gt $max_attempts ]
then
echo "All test attempts failed."
exit 1
fi
sleep 5
done
- name: Run JS/TS tests with retries
run: |
max_attempts=5
attempt_num=1
cd pkg/spore-drive/clients/js
npm i
until [ $attempt_num -gt $max_attempts ]
do
echo "Attempt $attempt_num of $max_attempts"
npm run test && break || echo "Test failed. Retrying..."
attempt_num=$((attempt_num + 1))
if [ $attempt_num -gt $max_attempts ]
then
echo "All test attempts failed."
exit 1
fi
sleep 5
done