CI #1311
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
concurrency: | |
group: ci-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- master | |
- release/* | |
tags: | |
- "v*" | |
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: | |
test: | |
runs-on: ubuntu-latest-x86-4-cores | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: stable | |
cache: true | |
- name: Setup Just | |
uses: extractions/setup-just@v2 | |
- name: GHA Lint | |
run: | | |
just --timestamp lint-gha | |
# Don't remove it! We shouldn't allow CI to pass if there are any changes not committed after running just | |
- name: Just all autogeneration and fail on dirty | |
run: | | |
just --timestamp gen | |
git status --short | |
git diff --quiet | |
- name: Some Go lint | |
run: | | |
just --timestamp _lint | |
- name: More Go lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
# keep in sync with hack/tools.just | |
version: v1.61.0 | |
- name: Run tests | |
run: | | |
just --timestamp 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 | |
# faster build installer without airgap using hosted runners and ghcr.io | |
build: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest-x86-4-cores | |
- ubuntu-24.04-arm64-4-core | |
- macos-latest | |
buildmode: | |
- "--usb=false" | |
- "--usb=true" | |
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 Just | |
uses: extractions/setup-just@v2 | |
- name: Setup docker on MacOS | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew install docker | |
- name: Login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build hhfab for local OS/ARCH | |
run: | | |
just --timestamp hhfab-build-local | |
- name: hhfab init and build | |
run: | | |
bin/hhfab init -v --dev --import-host-upstream | |
bin/hhfab build -v ${{ matrix.buildmode }} | |
ls -lah result | |
- 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-multi: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
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 Just | |
uses: extractions/setup-just@v2 | |
- name: Build bins for all OS/ARCH | |
run: | | |
just --timestamp build-multi | |
- 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 | |
builds: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- build-multi | |
if: ${{ always() }} | |
steps: | |
- run: | | |
result="${{ needs.build.result }}" | |
if [[ $result == "success" || $result == "skipped" ]]; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
vlab: | |
runs-on: vlab | |
needs: | |
- test | |
- builds | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
fabricmode: | |
- spine-leaf | |
- collapsed-core | |
includeonie: | |
- "--include-onie=false" | |
buildmode: | |
- "--usb=true" | |
include: | |
- fabricmode: spine-leaf | |
includeonie: "--include-onie=false" | |
buildmode: "--usb=false" | |
- fabricmode: spine-leaf | |
includeonie: "--include-onie=true" | |
buildmode: "--usb=true" | |
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: Setup local registry | |
env: | |
LOCALREG_SYNC_REGISTRY: m-pub.l.hhdev.io:31000 | |
LOCALREG_SYNC_USERNAME: lab | |
LOCALREG_SYNC_PASSWORD: ${{ secrets.LAB_REGISTRY_TOKEN }} | |
run: | | |
just --timestamp _localreg & | |
- name: Build hhfab | |
run: | | |
just --timestamp oci_repo=127.0.0.1:30000 oci=http push | |
- name: hhfab init and vlab up | |
env: | |
HHFAB_REG_REPO: 127.0.0.1:30000 | |
run: | | |
bin/hhfab init -v --dev -m ${{ matrix.fabricmode }} ${{ matrix.includeonie }} | |
bin/hhfab vlab gen -v | |
bin/hhfab vlab up -v --ready setup-vpcs --ready test-connectivity --ready exit ${{ matrix.buildmode }} | |
- name: Dump local registry logs | |
if: ${{ always() }} | |
run: | | |
cat .zot/log | |
- 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 | |
vlabs: | |
runs-on: ubuntu-latest | |
needs: | |
- vlab | |
if: ${{ always() }} | |
steps: | |
- run: | | |
result="${{ needs.vlab.result }}" | |
if [[ $result == "success" || $result == "skipped" ]]; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
publish: | |
runs-on: lab | |
if: startsWith(github.event.ref, 'refs/tags/v') && github.event_name == 'push' | |
needs: | |
- builds | |
- 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: | | |
just --timestamp oci_repo=ghcr.io push push-multi | |
- name: Create GH Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
make_latest: true # TODO do it for master only | |
files: | | |
bin/hhfab-*.tar.gz | |
- 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 |