forked from eclipse-iofog/router
-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (128 loc) · 4.5 KB
/
Copy pathci.yml
File metadata and controls
147 lines (128 loc) · 4.5 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
name: CI
on:
pull_request:
branches: [develop]
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
push:
branches: [develop]
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
workflow_dispatch:
permissions: read-all
env:
GO_VERSION: '1.26.4'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: go.sum
- run: go version
- name: golangci-lint
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
version: v2.12.2
args: --timeout=5m0s --config .golangci.yaml
- name: Static security analysis
run: make security-code
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: go.sum
- run: go version
- name: Run unit tests
run: make test
- name: Check formatting
run: make fmt-check
docker-smoke:
name: Docker smoke (${{ matrix.slug }})
runs-on: ubuntu-latest
needs: [lint, test]
strategy:
fail-fast: false
matrix:
include:
- slug: amd64
platform: linux/amd64
dockerfile: Dockerfile
- slug: arm64
platform: linux/arm64
dockerfile: Dockerfile
- slug: armv7
platform: linux/arm/v7
dockerfile: Dockerfile.edge
- slug: riscv64
platform: linux/riscv64
dockerfile: Dockerfile.edge
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: ./.github/actions/set-build-env
env:
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY }}
ROUTER_CONTAINER_IMAGE: ${{ vars.ROUTER_CONTAINER_IMAGE }}
OCI_SOURCE_REPO: ${{ vars.OCI_SOURCE_REPO }}
ROUTER_DISTRIBUTION: ${{ vars.ROUTER_DISTRIBUTION }}
ROUTER_GITHUB_REPO: ${{ vars.ROUTER_GITHUB_REPO }}
- name: Set up QEMU
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Build and load image
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platform }}
load: true
push: false
cache-from: type=gha,scope=router-${{ matrix.slug }}
cache-to: type=gha,mode=max,scope=router-${{ matrix.slug }}
build-args: |
OCI_SOURCE_REPO=${{ env.OCI_SOURCE_REPO }}
OCI_VERSION=ci
OCI_REVISION=${{ github.sha }}
ROUTER_DISTRIBUTION=${{ env.ROUTER_DISTRIBUTION }}
tags: ${{ env.ROUTER_CONTAINER_IMAGE }}:ci-smoke-${{ matrix.slug }}
- name: Runtime smoke (router → launch.sh → skrouterd)
env:
IMAGE: ${{ env.ROUTER_CONTAINER_IMAGE }}:ci-smoke-${{ matrix.slug }}
PLATFORM: ${{ matrix.platform }}
run: |
set -euo pipefail
docker run -d --name router-smoke --platform "${PLATFORM}" \
-e SKUPPER_PLATFORM=kubernetes \
-v "${GITHUB_WORKSPACE}/test/smoke-skrouterd.json:/tmp/skrouterd.json:ro" \
"${IMAGE}"
cleanup() { docker rm -f router-smoke >/dev/null 2>&1 || true; }
trap cleanup EXIT
for _ in $(seq 1 30); do
if docker logs router-smoke 2>&1 | grep -q "Listening on 0.0.0.0:5672"; then
echo "Runtime smoke passed: skrouterd listening on :5672"
exit 0
fi
if ! docker ps -q -f name=router-smoke | grep -q .; then
echo "Container exited before skrouterd became ready"
docker logs router-smoke 2>&1 || true
exit 1
fi
sleep 2
done
echo "Timed out waiting for skrouterd to listen on :5672"
docker logs router-smoke 2>&1 || true
exit 1