Skip to content

CI

CI #1086

Workflow file for this run

name: CI
concurrency:
group: ci-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
push:
branches:
- master
- release/*
tags:
- "*"
pull_request:
schedule:
- cron: "0 10 * * *" # ~2am PST
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
jobs:
# cache-tools:
# runs-on: ubuntu-latest # It should be faster than running in hour DC
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Setup Go
# uses: actions/setup-go@v5
# with:
# go-version: stable
# cache: true
# - name: Cache dev tools
# uses: actions/cache@v3
# with:
# path: bin
# key: bin-${{ hashFiles('hack/tools.mk') }}
# - name: Prepare all dev tools
# run: |
# make tools
# - name: Setup tmate session for debug
# if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 30
# with:
# limit-access-to-actor: true
test:
runs-on: lab
steps:
- name: Checkout repository
uses: actions/checkout@v4
# with:
# fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
cache: true
# Don't remove it! We shouldn't allow CI to pass if there are any changes not committed after running make
- name: Make all (autogeneration) and fail on dirty
run: |
make lint-lic fmt build
git status --short
git diff --quiet
- name: Go Lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: Run tests
run: |
make test
- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
with:
limit-access-to-actor: true
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
preset:
- lab
- vlab
dhcpd:
- isc
- hedgehog
exclude:
- preset: vlab
dhcpd: isc
- preset: vlab
os: macos-latest
- dhcpd: isc
os: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
cache: true
- name: Setup docker on MacOS
if: matrix.os == 'macos-latest'
run: |
brew install docker
- name: Build hhfab for local OS/ARCH
run: |
make hhfab-local
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: hhfab init and build
run: |
bin/hhfab init -p=${{ matrix.preset }} --dhcpd=${{ matrix.dhcpd }} --dev -v
bin/hhfab build -v
bin/hhfab build-iso -v
ls -lah .hhfab
- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
with:
limit-access-to-actor: true
vlab:
runs-on: vlab
needs:
- test
- build
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
mode:
- collapsed-core
- spine-leaf
dhcpd:
- isc
- hedgehog
steps:
- name: Runner host
run: |
echo $KUBE_NODE
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
cache: true
- name: Build hhfab
run: |
make hhfab
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to lab registry
uses: docker/login-action@v3
with:
registry: m-pub.l.hhdev.io:31000
username: lab
password: ${{ secrets.LAB_REGISTRY_TOKEN }}
- name: hhfab init and build
# TODO replace --install-complete with --run-complete hack/vlab-test.sh
run: |
export XDG_CONFIG_HOME=$(pwd)/.config
export HHFAB_BASE_REPO=m-pub.l.hhdev.io:31000/githedgehog
bin/hhfab init -p=vlab --fabric-mode=${{ matrix.mode }} --dhcpd=${{ matrix.dhcpd }} --dev -v
bin/hhfab build -v
bin/hhfab build-iso -v
ls -lah .hhfab
bin/hhfab vlab up -v --ready=setup-vpcs --ready=exit
- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 120
with:
limit-access-to-actor: true
publish:
runs-on: lab
if: startsWith(github.event.ref, 'refs/tags/') && github.event_name == 'push'
needs:
- build
- vlab
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
cache: true
# - name: Cache dev tools
# uses: actions/cache@v3
# with:
# path: bin
# key: bin-${{ hashFiles('hack/tools.mk') }}
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Images, Helm charts and Bins on release
run: |
OCI_REPO=ghcr.io/githedgehog/fabricator make push
- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
with:
limit-access-to-actor: true