Skip to content

Commit 0f134f4

Browse files
committed
github: rework test environment
1 parent c3d19db commit 0f134f4

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

.github/workflows/clipboard.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,45 @@ on:
1414

1515
jobs:
1616
platform_test:
17-
17+
env:
18+
DISPLAY: ':0.0'
1819
runs-on: ${{ matrix.os }}
1920
strategy:
2021
fail-fast: false
2122
matrix:
2223
os: [ubuntu-latest, macos-latest, windows-latest]
23-
2424
steps:
25-
26-
- name: install xvfb libx11-dev
25+
- name: Install and run dependencies (xvfb libx11-dev)
26+
if: ${{ runner.os == 'Linux' }}
2727
run: |
2828
sudo apt update
2929
sudo apt install -y xvfb libx11-dev
30-
if: ${{ runner.os == 'Linux' }}
30+
Xvfb :0 -screen 0 1024x768x24 > /dev/null 2>&1 &
31+
# Wait for Xvfb
32+
MAX_ATTEMPTS=120 # About 60 seconds
33+
COUNT=0
34+
echo -n "Waiting for Xvfb to be ready..."
35+
while ! xdpyinfo -display "${DISPLAY}" >/dev/null 2>&1; do
36+
echo -n "."
37+
sleep 0.50s
38+
COUNT=$(( COUNT + 1 ))
39+
if [ "${COUNT}" -ge "${MAX_ATTEMPTS}" ]; then
40+
echo " Gave up waiting for X server on ${DISPLAY}"
41+
exit 1
42+
fi
43+
done
44+
echo "Done - Xvfb is ready!"
3145
3246
- uses: actions/checkout@v2
3347
- uses: actions/setup-go@v2
3448
with:
3549
stable: 'false'
36-
go-version: '1.17.0'
50+
go-version: '1.17.x'
3751

38-
- name: TestLinux
52+
- name: Build
3953
run: |
40-
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
41-
export DISPLAY=:99.0
42-
sleep 5s
43-
go test -v -covermode=atomic ./...
44-
if: ${{ runner.os == 'Linux' }}
54+
go build
4555
46-
- name: TestOthers
56+
- name: Run Tests
4757
run: |
4858
go test -v -covermode=atomic ./...

0 commit comments

Comments
 (0)