Skip to content

Commit ec0d744

Browse files
Merge pull request #10 from Datasance/router/08-mirror
Router/08 mirror
2 parents 5eab162 + 8ffd173 commit ec0d744

57 files changed

Lines changed: 1783 additions & 1174 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
22
.vscode
33
x.json
4-
zz.yaml
4+
zz.yaml
5+
bin
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Set router build environment
2+
description: Resolves router image registry, container image, OCI source, distribution, and GitHub repo from workflow env or github.repository.
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Set image registry and OCI source
8+
shell: bash
9+
run: |
10+
REGISTRY="${{ env.IMAGE_REGISTRY }}"
11+
OCI_SOURCE="${{ env.OCI_SOURCE_REPO }}"
12+
ROUTER_IMAGE="${{ env.ROUTER_CONTAINER_IMAGE }}"
13+
if [ -z "$REGISTRY" ] || [ -z "$OCI_SOURCE" ] || [ -z "$ROUTER_IMAGE" ]; then
14+
case "${{ github.repository }}" in
15+
eclipse-iofog/router)
16+
REGISTRY="${REGISTRY:-ghcr.io/eclipse-iofog}"
17+
OCI_SOURCE="${OCI_SOURCE:-https://github.com/eclipse-iofog/router}"
18+
ROUTER_IMAGE="${ROUTER_IMAGE:-ghcr.io/eclipse-iofog/router}"
19+
;;
20+
*)
21+
REGISTRY="${REGISTRY:-ghcr.io/datasance}"
22+
OCI_SOURCE="${OCI_SOURCE:-https://github.com/Datasance/router}"
23+
ROUTER_IMAGE="${ROUTER_IMAGE:-ghcr.io/datasance/router}"
24+
;;
25+
esac
26+
fi
27+
echo "IMAGE_REGISTRY=$REGISTRY" >> "${GITHUB_ENV}"
28+
echo "OCI_SOURCE_REPO=$OCI_SOURCE" >> "${GITHUB_ENV}"
29+
echo "ROUTER_CONTAINER_IMAGE=$ROUTER_IMAGE" >> "${GITHUB_ENV}"
30+
31+
- name: Set router distribution
32+
shell: bash
33+
run: |
34+
DISTRIBUTION="${{ env.ROUTER_DISTRIBUTION }}"
35+
GITHUB_REPO="${{ env.ROUTER_GITHUB_REPO }}"
36+
if [ -z "$DISTRIBUTION" ] || [ -z "$GITHUB_REPO" ]; then
37+
case "${{ github.repository }}" in
38+
eclipse-iofog/router)
39+
DISTRIBUTION="${DISTRIBUTION:-iofog}"
40+
GITHUB_REPO="${GITHUB_REPO:-eclipse-iofog/router}"
41+
;;
42+
*)
43+
DISTRIBUTION="${DISTRIBUTION:-datasance}"
44+
GITHUB_REPO="${GITHUB_REPO:-Datasance/router}"
45+
;;
46+
esac
47+
fi
48+
echo "ROUTER_DISTRIBUTION=$DISTRIBUTION" >> "${GITHUB_ENV}"
49+
echo "ROUTER_GITHUB_REPO=$GITHUB_REPO" >> "${GITHUB_ENV}"

.github/workflows/ci.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [develop]
6+
paths-ignore:
7+
- README.md
8+
- CHANGELOG.md
9+
- LICENSE
10+
push:
11+
branches: [develop]
12+
paths-ignore:
13+
- README.md
14+
- CHANGELOG.md
15+
- LICENSE
16+
workflow_dispatch:
17+
18+
permissions: read-all
19+
20+
env:
21+
GO_VERSION: '1.26.4'
22+
23+
jobs:
24+
lint:
25+
name: Lint
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
32+
with:
33+
go-version: ${{ env.GO_VERSION }}
34+
cache-dependency-path: go.sum
35+
36+
- run: go version
37+
38+
- name: golangci-lint
39+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
40+
with:
41+
version: v2.12.2
42+
args: --timeout=5m0s --config .golangci.yaml
43+
44+
- name: Static security analysis
45+
run: make security-code
46+
47+
test:
48+
name: Test
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
52+
53+
- name: Set up Go
54+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
55+
with:
56+
go-version: ${{ env.GO_VERSION }}
57+
cache-dependency-path: go.sum
58+
59+
- run: go version
60+
61+
- name: Run unit tests
62+
run: make test
63+
64+
- name: Check formatting
65+
run: make fmt-check
66+
67+
docker-smoke:
68+
name: Docker smoke (${{ matrix.slug }})
69+
runs-on: ubuntu-latest
70+
needs: [lint, test]
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
include:
75+
- slug: amd64
76+
platform: linux/amd64
77+
dockerfile: Dockerfile
78+
- slug: arm64
79+
platform: linux/arm64
80+
dockerfile: Dockerfile
81+
- slug: armv7
82+
platform: linux/arm/v7
83+
dockerfile: Dockerfile.edge
84+
- slug: riscv64
85+
platform: linux/riscv64
86+
dockerfile: Dockerfile.edge
87+
steps:
88+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
89+
90+
- uses: ./.github/actions/set-build-env
91+
env:
92+
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY }}
93+
ROUTER_CONTAINER_IMAGE: ${{ vars.ROUTER_CONTAINER_IMAGE }}
94+
OCI_SOURCE_REPO: ${{ vars.OCI_SOURCE_REPO }}
95+
ROUTER_DISTRIBUTION: ${{ vars.ROUTER_DISTRIBUTION }}
96+
ROUTER_GITHUB_REPO: ${{ vars.ROUTER_GITHUB_REPO }}
97+
98+
- name: Set up QEMU
99+
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
100+
101+
- name: Set up Docker Buildx
102+
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
103+
104+
- name: Build and load image
105+
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
106+
with:
107+
context: .
108+
file: ${{ matrix.dockerfile }}
109+
platforms: ${{ matrix.platform }}
110+
load: true
111+
push: false
112+
cache-from: type=gha,scope=router-${{ matrix.slug }}
113+
cache-to: type=gha,mode=max,scope=router-${{ matrix.slug }}
114+
build-args: |
115+
OCI_SOURCE_REPO=${{ env.OCI_SOURCE_REPO }}
116+
OCI_VERSION=ci
117+
OCI_REVISION=${{ github.sha }}
118+
ROUTER_DISTRIBUTION=${{ env.ROUTER_DISTRIBUTION }}
119+
tags: ${{ env.ROUTER_CONTAINER_IMAGE }}:ci-smoke-${{ matrix.slug }}
120+
121+
- name: Runtime smoke (router → launch.sh → skrouterd)
122+
env:
123+
IMAGE: ${{ env.ROUTER_CONTAINER_IMAGE }}:ci-smoke-${{ matrix.slug }}
124+
PLATFORM: ${{ matrix.platform }}
125+
run: |
126+
set -euo pipefail
127+
docker run -d --name router-smoke --platform "${PLATFORM}" \
128+
-e SKUPPER_PLATFORM=kubernetes \
129+
-v "${GITHUB_WORKSPACE}/test/smoke-skrouterd.json:/tmp/skrouterd.json:ro" \
130+
"${IMAGE}"
131+
cleanup() { docker rm -f router-smoke >/dev/null 2>&1 || true; }
132+
trap cleanup EXIT
133+
for _ in $(seq 1 30); do
134+
if docker logs router-smoke 2>&1 | grep -q "Listening on 0.0.0.0:5672"; then
135+
echo "Runtime smoke passed: skrouterd listening on :5672"
136+
exit 0
137+
fi
138+
if ! docker ps -q -f name=router-smoke | grep -q .; then
139+
echo "Container exited before skrouterd became ready"
140+
docker logs router-smoke 2>&1 || true
141+
exit 1
142+
fi
143+
sleep 2
144+
done
145+
echo "Timed out waiting for skrouterd to listen on :5672"
146+
docker logs router-smoke 2>&1 || true
147+
exit 1

.github/workflows/govulncheck.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: govulncheck
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 0"
6+
workflow_dispatch: {}
7+
8+
permissions: read-all
9+
10+
env:
11+
GO_VERSION: '1.26.4'
12+
13+
jobs:
14+
govulncheck:
15+
name: govulncheck
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
23+
with:
24+
go-version: ${{ env.GO_VERSION }}
25+
cache-dependency-path: go.sum
26+
27+
- name: Run govulncheck
28+
run: make vulncheck

.github/workflows/push.yaml

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)