-
Notifications
You must be signed in to change notification settings - Fork 23
147 lines (130 loc) · 5.4 KB
/
test.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
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
name: Test
on: [ push, pull_request ]
jobs:
test:
# run job on all pushes OR external PR, not both
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
cache: true
- name: Create stub static/
run: mkdir static && touch static/index.html
- name: Check deps
shell: bash
run: ./build.sh deps
- name: gofmt && go mod tidy
if: matrix.os == 'ubuntu-latest'
run: |
go mod tidy -compat=1.23
cd cmd/awl-tray && go mod tidy -compat=1.23 && cd ../..
test -z "$(gofmt -d .)" || (gofmt -d . && false)
test -z "$(git status --porcelain)" || (git status; git diff && false)
- name: Test
run: go test -count=1 -v ./...
- name: Test with -race
run: go test -race -count=1 -v ./...
- name: Build cmd/awl
run: go build github.com/anywherelan/awl/cmd/awl
- name: Upload cmd/awl build
uses: actions/upload-artifact@v4
with:
name: awl-build-${{ runner.os }}
path: |
awl
awl.exe
if-no-files-found: error
end-to-end-test:
# run only on pushes because we use repository secrets which are unavailable to forks
if: ${{ github.event_name == 'push' }}
needs: [ test ]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Retrieve saved cmd/awl build
uses: actions/download-artifact@v4
with:
name: awl-build-${{ runner.os }}
- name: Download librespeed-cli
env:
CONFIG_AWL_LINUX: ${{ secrets.CONFIG_AWL_LINUX }}
CONFIG_AWL_MACOS: ${{ secrets.CONFIG_AWL_MACOS }}
CONFIG_AWL_WINDOWS: ${{ secrets.CONFIG_AWL_WINDOWS }}
CONFIG_LIBRESPEED: ${{ secrets.CONFIG_LIBRESPEED }}
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
curl -sSL https://github.com/librespeed/speedtest-cli/releases/download/v1.0.10/librespeed-cli_1.0.10_linux_amd64.tar.gz | tar -xzf -
echo $CONFIG_AWL_LINUX > config_awl.json
elif [ "$RUNNER_OS" == "macOS" ]; then
curl -sSL https://github.com/librespeed/speedtest-cli/releases/download/v1.0.10/librespeed-cli_1.0.10_darwin_arm64.tar.gz | tar -xzf -
echo $CONFIG_AWL_MACOS > config_awl.json
elif [ "$RUNNER_OS" == "Windows" ]; then
curl -sSL https://github.com/librespeed/speedtest-cli/releases/download/v1.0.10/librespeed-cli_1.0.10_windows_amd64.zip > download.zip
unzip download.zip
echo $CONFIG_AWL_WINDOWS > config_awl.json
else
echo "$RUNNER_OS not supported"
exit 1
fi
echo $CONFIG_LIBRESPEED > config_librespeed.json
- name: Run librespeed-cli, awl, librespeed-cli through awl
if: matrix.os == 'ubuntu-latest'
run: |
chmod +x awl
sudo ./awl &
./librespeed-cli --local-json config_librespeed.json --server 1 --json --share --telemetry-level disabled | python3 -m json.tool
sleep 10
awl_pid=`jobs -l | grep './awl' | awk '{print $2}'`
./awl cli peers status
./librespeed-cli --local-json config_librespeed.json --server 2 --json --share --telemetry-level disabled | python3 -m json.tool
ping 10.66.0.2 -w 20 -c 10
# TODO: remove this temporal hack for linux
ping awl-tester.awl -w 20 -c 10 || true
sleep 1
sudo kill -SIGINT $awl_pid
sleep 1
- name: Run librespeed-cli, awl, librespeed-cli through awl
if: matrix.os == 'macos-latest'
run: |
chmod +x awl
sudo ./awl &
./librespeed-cli --local-json config_librespeed.json --server 1 --json --share --telemetry-level disabled | python3 -m json.tool
sleep 10
awl_pid=`jobs -l | grep './awl' | awk '{print $2}'`
./awl cli peers status
./librespeed-cli --local-json config_librespeed.json --server 2 --json --share --telemetry-level disabled | python3 -m json.tool
ping 10.66.0.2 -c 10
ping awl-tester.awl -c 10
sleep 1
sudo kill -SIGINT $awl_pid
sleep 1
- name: Run librespeed-cli, awl, librespeed-cli through awl
if: matrix.os == 'windows-latest'
run: |
chmod +x awl.exe
./awl.exe &
./librespeed-cli.exe --local-json config_librespeed.json --server 1 --json --share --telemetry-level disabled | python3 -m json.tool
sleep 10
awl_pid=`jobs -l | grep './awl' | awk '{print $2}'`
./awl.exe cli peers status
./librespeed-cli.exe --local-json config_librespeed.json --server 2 --json --share --telemetry-level disabled | python3 -m json.tool
ping -w 20000 -n 10 10.66.0.2
ping -w 20000 -n 10 -a awl-tester.awl
sleep 1
kill -SIGINT $awl_pid
sleep 1