-
Notifications
You must be signed in to change notification settings - Fork 9
178 lines (153 loc) · 5.44 KB
/
Copy pathci.yaml
File metadata and controls
178 lines (153 loc) · 5.44 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
lint:
runs-on: [ ubuntu-24.04-arm ]
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: 'go.mod'
cache: true
cache-dependency-path: |
**/go.sum
- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
govulncheck ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.10.1
build-and-test:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, ubuntu-24.04-arm, windows-latest ]
include:
- os: windows-latest
docker_host: ssh://test@localhost:2222
runs-on: ${{ matrix.os }}
steps:
- name: Install WSL (Windows)
if: runner.os == 'Windows'
uses: Vampire/setup-wsl@d1da7f2c0322a5ee4f24975344f67fc0f5baf364 # v7
with:
distribution: Ubuntu-24.04
# Docker and Podman require the Linux kernel and container primitives provided by WSL2.
wsl-version: 2
additional-packages: |
openssh-server
docker.io
- name: Setup SSH (Windows - WSL)
if: runner.os == 'Windows'
shell: wsl-bash {0}
run: |
useradd -G kvm,docker -m -s /bin/bash test
passwd -d test
cat > /etc/ssh/sshd_config.d/01-passwordless-authentication.conf << 'EOF'
PasswordAuthentication yes
PermitEmptyPasswords yes
UsePAM no
Port 2222
EOF
systemctl daemon-reload
systemctl restart ssh
- name: Add WSL host key (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Keep WSL running
wsl --exec dbus-launch true
# Windows ssh-keyscan has KexAlgorithm limitations so use ssh to add host key - https://github.com/PowerShell/Win32-OpenSSH/issues/2140
ssh -p 2222 -o StrictHostKeyChecking=accept-new test@localhost "exit"
- name: Install Podman and Docker Compose provider (Linux)
if: runner.os == 'Linux'
shell: bash
env:
COMPOSE_VERSION: v2.32.4
run: |
sudo apt-get update
sudo apt-get install --yes podman
case "$(uname -m)" in
x86_64) compose_arch=x86_64 ;;
aarch64|arm64) compose_arch=aarch64 ;;
*) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac
curl --fail --location --show-error \
"https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-linux-${compose_arch}" \
--output /tmp/docker-compose
sudo install --mode 0755 /tmp/docker-compose /usr/local/bin/docker-compose
- name: Install Podman and Docker Compose provider (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
COMPOSE_VERSION: v2.32.4
run: |
winget install --exact --id RedHat.Podman `
--silent `
--accept-package-agreements `
--accept-source-agreements
$podmanDirectories = @(
"$env:LOCALAPPDATA\Programs\Podman",
"$env:ProgramFiles\Podman",
"$env:ProgramFiles\RedHat\Podman"
)
$podmanDirectory = $podmanDirectories |
Where-Object { Test-Path (Join-Path $_ "podman.exe") } |
Select-Object -First 1
if (-not $podmanDirectory) {
throw "Unable to locate podman.exe after installation"
}
$toolsDirectory = Join-Path $env:RUNNER_TEMP "container-tools"
New-Item -ItemType Directory -Force $toolsDirectory | Out-Null
Invoke-WebRequest `
-Uri "https://github.com/docker/compose/releases/download/$env:COMPOSE_VERSION/docker-compose-windows-x86_64.exe" `
-OutFile (Join-Path $toolsDirectory "docker-compose.exe")
$podmanDirectory | Out-File $env:GITHUB_PATH -Encoding utf8 -Append
$toolsDirectory | Out-File $env:GITHUB_PATH -Encoding utf8 -Append
- name: Start Podman machine (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
podman machine init --cpus 2 --memory 2048 --now
- name: Verify Podman test prerequisites (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
podman version
podman info
docker-compose version
podman compose version
- name: Verify Podman test prerequisites (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
podman version
podman info
docker-compose version
podman compose version
- name: Checkout repository
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: 'go.mod'
cache: true
cache-dependency-path: |
**/go.sum
- name: Build
run: |
go build -v ./cmd/topo
- name: Run tests with coverage
env:
DOCKER_HOST: ${{ matrix.docker_host }}
run: |
go test ./... -p 1 -v -covermode=atomic -coverprofile=coverage.out