CI / changes (push) Successful in 5s
CI / go (push) Successful in 23s
CI / openapi (push) Has been skipped
CI / bird2 (push) Successful in 14s
CI / docker-images (deploy/docker/bird2/Dockerfile, evobgp-bird2) (push) Successful in 50s
CI / docker-images (deploy/docker/evobgp-agent/Dockerfile, evobgp-agent) (push) Successful in 1m6s
CI / docker-images (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, evobgp-all) (push) Has been cancelled
CI / docker-images (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, evobgp-api) (push) Has been cancelled
CI / docker-images (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, evobgp-deploy) (push) Has been cancelled
CI / docker-images (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, evobgp-ingest) (push) Has been cancelled
CI / docker-images (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, evobgp-node) (push) Has been cancelled
CI / docker-images (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, evobgp-render) (push) Has been cancelled
CI / docker-images (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, evobgp-scheduler) (push) Has been cancelled
CI / docker-images (deploy/docker/evobgp-web/Dockerfile, evobgp-web) (push) Has been cancelled
237 lines
8.1 KiB
YAML
237 lines
8.1 KiB
YAML
name: CI
|
||
|
||
on:
|
||
push:
|
||
branches: [main, master]
|
||
pull_request:
|
||
branches: [main, master]
|
||
|
||
jobs:
|
||
changes:
|
||
runs-on: ubuntu-latest
|
||
outputs:
|
||
openapi: ${{ steps.openapi.outputs.changed }}
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
with:
|
||
fetch-depth: 0
|
||
- id: openapi
|
||
name: Detect OpenAPI-related file changes
|
||
run: |
|
||
set -euo pipefail
|
||
PATHS="docs/openapi.yaml redocly.yaml"
|
||
changed=false
|
||
|
||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||
base="${{ github.event.pull_request.base.sha }}"
|
||
head="${{ github.event.pull_request.head.sha }}"
|
||
if git diff --name-only "$base" "$head" -- $PATHS | grep -q .; then
|
||
changed=true
|
||
fi
|
||
else
|
||
before="${{ github.event.before }}"
|
||
after="${{ github.sha }}"
|
||
if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" ]; then
|
||
if git diff --name-only "$before" "$after" -- $PATHS | grep -q .; then
|
||
changed=true
|
||
fi
|
||
elif git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
|
||
if git diff --name-only HEAD~1 HEAD -- $PATHS | grep -q .; then
|
||
changed=true
|
||
fi
|
||
else
|
||
# Нет родителя (первый коммит / тонкий clone) — линт OpenAPI выполняем один раз
|
||
changed=true
|
||
fi
|
||
fi
|
||
|
||
echo "changed=$changed" >> "$GITHUB_OUTPUT"
|
||
echo "OpenAPI lint will run: $changed"
|
||
|
||
openapi:
|
||
needs: [changes]
|
||
if: needs.changes.outputs.openapi == 'true'
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
- uses: actions/setup-node@v4
|
||
with:
|
||
node-version: "20"
|
||
- name: Lint OpenAPI (Redocly)
|
||
run: npx --yes @redocly/cli@1 lint docs/openapi.yaml
|
||
|
||
go:
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
- uses: actions/setup-go@v5
|
||
with:
|
||
go-version: "1.22"
|
||
- name: Vet
|
||
run: go vet ./...
|
||
- name: Test
|
||
run: go test ./... -race -count=1
|
||
- name: Build all commands
|
||
run: |
|
||
set -euxo pipefail
|
||
out="${RUNNER_TEMP}/evobgp-bin"
|
||
mkdir -p "$out"
|
||
for d in cmd/*/; do
|
||
name="$(basename "$d")"
|
||
go build -o "$out/$name" "./$d"
|
||
done
|
||
|
||
bird2:
|
||
runs-on: ubuntu-latest
|
||
needs: [go]
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
# Вложенный docker + bind-mount ломается, если демон Docker на хосте не видит путь
|
||
# workspace runner'а (/workspace/...). bird -p на самом job-раннере надёжнее.
|
||
- name: Install bird2
|
||
run: |
|
||
set -euxo pipefail
|
||
if command -v sudo >/dev/null 2>&1; then SUDO=sudo; else SUDO=""; fi
|
||
$SUDO apt-get update -qq
|
||
DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y -qq bird2
|
||
bird --version
|
||
- name: bird -p on all scenario bird.conf files
|
||
env:
|
||
WORKSPACE: ${{ github.workspace }}
|
||
run: |
|
||
set -euxo pipefail
|
||
WS="${WORKSPACE:-$PWD}"
|
||
cd "$WS"
|
||
if [ ! -f internal/birdfmt/testdata/scenarios/minimal/bird.conf ]; then
|
||
echo "Нет сценариев BIRD в checkout. Проверьте, что internal/birdfmt/testdata/scenarios закоммичен и push в remote."
|
||
ls -la internal/birdfmt/testdata/ 2>/dev/null || ls -la
|
||
exit 1
|
||
fi
|
||
for conf in internal/birdfmt/testdata/scenarios/*/bird.conf; do
|
||
echo "==> $conf"
|
||
bird -c "$WS/$conf" -p
|
||
done
|
||
|
||
# Сборка образов и push в Container Registry Gitea (только push в main/master; см. .gitea/README.md).
|
||
docker-images:
|
||
needs: [go]
|
||
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
|
||
runs-on: ubuntu-latest
|
||
strategy:
|
||
fail-fast: false
|
||
matrix:
|
||
include:
|
||
- image: evobgp-api
|
||
dockerfile: deploy/docker/gobinary/Dockerfile
|
||
bin: evobgp-api
|
||
birdc: "1"
|
||
- image: evobgp-all
|
||
dockerfile: deploy/docker/gobinary/Dockerfile
|
||
bin: evobgp-all
|
||
birdc: "1"
|
||
- image: evobgp-scheduler
|
||
dockerfile: deploy/docker/gobinary/Dockerfile
|
||
bin: evobgp-scheduler
|
||
birdc: "0"
|
||
- image: evobgp-ingest
|
||
dockerfile: deploy/docker/gobinary/Dockerfile
|
||
bin: evobgp-ingest
|
||
birdc: "0"
|
||
- image: evobgp-render
|
||
dockerfile: deploy/docker/gobinary/Dockerfile
|
||
bin: evobgp-render
|
||
birdc: "0"
|
||
- image: evobgp-deploy
|
||
dockerfile: deploy/docker/gobinary/Dockerfile
|
||
bin: evobgp-deploy
|
||
birdc: "0"
|
||
- image: evobgp-node
|
||
dockerfile: deploy/docker/gobinary/Dockerfile
|
||
bin: evobgp-node
|
||
birdc: "0"
|
||
- image: evobgp-web
|
||
dockerfile: deploy/docker/evobgp-web/Dockerfile
|
||
- image: evobgp-agent
|
||
dockerfile: deploy/docker/evobgp-agent/Dockerfile
|
||
- image: evobgp-bird2
|
||
dockerfile: deploy/docker/bird2/Dockerfile
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- name: Set up Docker Buildx
|
||
uses: docker/setup-buildx-action@v3
|
||
|
||
- name: Prepare registry (REGISTRY in env + outputs)
|
||
id: meta
|
||
env:
|
||
HOST: ${{ secrets.GITEA_REGISTRY_HOST }}
|
||
run: |
|
||
set -euo pipefail
|
||
owner_lc="$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')"
|
||
echo "owner_lc=$owner_lc" >> "$GITHUB_OUTPUT"
|
||
short_sha="$(echo '${{ github.sha }}' | cut -c1-7)"
|
||
echo "short_sha=$short_sha" >> "$GITHUB_OUTPUT"
|
||
if [ -z "${HOST:-}" ]; then
|
||
echo "GITEA_REGISTRY_HOST not set — build without push."
|
||
echo "docker_push=false" >> "$GITHUB_OUTPUT"
|
||
echo "REGISTRY=" >> "$GITHUB_ENV"
|
||
else
|
||
h="$HOST"
|
||
h="${h#https://}"
|
||
h="${h#http://}"
|
||
h="${h%/}"
|
||
echo "docker_push=true" >> "$GITHUB_OUTPUT"
|
||
echo "REGISTRY=$h" >> "$GITHUB_ENV"
|
||
fi
|
||
|
||
- name: Log in to Gitea Registry
|
||
if: steps.meta.outputs.docker_push == 'true' && secrets.ACTIONS_PAT != ''
|
||
uses: docker/login-action@v3
|
||
with:
|
||
registry: ${{ env.REGISTRY }}
|
||
username: ${{ gitea.actor }}
|
||
password: ${{ secrets.ACTIONS_PAT }}
|
||
|
||
- name: Build and push ${{ matrix.image }}
|
||
env:
|
||
OWNER_LC: ${{ steps.meta.outputs.owner_lc }}
|
||
SHORT_SHA: ${{ steps.meta.outputs.short_sha }}
|
||
DO_PUSH: ${{ steps.meta.outputs.docker_push }}
|
||
PAT_OK: ${{ secrets.ACTIONS_PAT != '' }}
|
||
DF: ${{ matrix.dockerfile }}
|
||
IMAGE: ${{ matrix.image }}
|
||
BIN: ${{ matrix.bin }}
|
||
BIRDC: ${{ matrix.birdc }}
|
||
run: |
|
||
set -euxo pipefail
|
||
WS="${{ github.workspace }}"
|
||
cd "$WS"
|
||
|
||
TAG_LOCAL="evobgp:${IMAGE}-${SHORT_SHA}"
|
||
BUILD_ARGS=()
|
||
if [ -n "${BIN:-}" ]; then
|
||
BUILD_ARGS+=(--build-arg "BIN=${BIN}")
|
||
BUILD_ARGS+=(--build-arg "INSTALL_BIRDC=${BIRDC:-0}")
|
||
fi
|
||
|
||
if [ "$DO_PUSH" = "true" ] && [ -n "${REGISTRY:-}" ] && [ "$PAT_OK" = "true" ]; then
|
||
IMG="${REGISTRY}/${OWNER_LC}/${IMAGE}"
|
||
docker buildx build \
|
||
--platform linux/amd64 \
|
||
--file "$DF" \
|
||
"${BUILD_ARGS[@]}" \
|
||
--tag "${IMG}:latest" \
|
||
--tag "${IMG}:${SHORT_SHA}" \
|
||
--tag "${IMG}:sha-${{ github.sha }}" \
|
||
--push \
|
||
"$WS"
|
||
else
|
||
docker buildx build \
|
||
--platform linux/amd64 \
|
||
--file "$DF" \
|
||
"${BUILD_ARGS[@]}" \
|
||
--tag "$TAG_LOCAL" \
|
||
--load \
|
||
"$WS"
|
||
fi
|