-
-
Notifications
You must be signed in to change notification settings - Fork 546
108 lines (105 loc) · 3.03 KB
/
Copy pathmain.yml
File metadata and controls
108 lines (105 loc) · 3.03 KB
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
name: CI
on:
push:
tags: [ 'v*' ]
branches: [ main ]
pull_request:
permissions:
contents: write
env:
GOLANG_VERSION: 1.21.x
jobs:
lint:
name: lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.0
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: Install dependencies
run: go get .
- name: Build
run: go build -v ./...
- name: Test with the Go CLI
run: go test ./...
e2e:
needs: [ test, lint ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-24.04, macos-15, windows-latest ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: Run tests on *nix
if: runner.os != 'Windows'
run: |
TEST_CONTENT="hello"
TEST_FILE="/tmp/qrcp-test.txt"
echo $TEST_CONTENT > $TEST_FILE
go build
OS=$(uname)
INTERFACE=lo
if [[ "$OS" == "Darwin" ]]; then
INTERFACE="lo0"
fi
./qrcp -i $INTERFACE -p 1606 --path test $TEST_FILE > /dev/null 2>&1 &
QRCP_PID=$!
sleep 2
CURL_OUTPUT=$(curl -s http://127.0.0.1:1606/send/test)
kill $QRCP_PID || true
if [[ "${TEST_CONTENT}" != "${CURL_OUTPUT}" ]]; then
exit 1
fi
- name: Run tests on Windows
if: runner.os == 'Windows'
run: |
$TestContent = "hello"
$TestFile = "$env:TEMP\qrcp-test.txt"
$TestContent | Out-File -FilePath $TestFile -Encoding UTF8
go build
$Job = Start-Job -ScriptBlock {
Start-Process -FilePath ./qrcp -ArgumentList "-i", "any", "-p", "1606", "--path", "test", "$env:TEMP\qrcp-test.txt" -NoNewWindow -Wait
}
Start-Sleep -Seconds 2
$Request = Invoke-WebRequest -Uri http://127.0.0.1:1606/send/test
$FileContent = Get-Content -Path $TestFile -Raw
if ($Request.Content -ne $FileContent) {
Write-Host "Expected: $FileContent"
Write-Host "Got: $($Request.Content)"
exit 1
}
release:
runs-on: ubuntu-24.04
needs: [ e2e ]
if: startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
args: release --clean
version: '~> v2'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}