CI #1549
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: lab | |
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: Lint and generate code | |
run: | | |
just --timestamp lint-gha gen _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 | |
# Don't remove it! We shouldn't allow CI to pass if there are any changes not committed after running gen/lint/test | |
- name: Fail on dirty | |
run: | | |
git status --short | |
git diff --quiet | |
- 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: lab | |
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 | |
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 | |
vlab-upgrade: | |
runs-on: vlab | |
needs: | |
- test | |
- builds | |
timeout-minutes: 90 | |
strategy: | |
fail-fast: false | |
matrix: | |
fabricmode: | |
- spine-leaf | |
fromversion: | |
- "beta-1" | |
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 | |
run: | | |
just --timestamp _localreg & | |
- name: Initial VLAB with old version | |
env: | |
HHFAB_REG_REPO: 127.0.0.1:30000 | |
run: | | |
mkdir old | |
curl -fsSL https://i.hhdev.io/hhfab | USE_SUDO=false INSTALL_DIR=./old VERSION="${{ matrix.fromversion }}" bash | |
old/hhfab init -v --dev -m ${{ matrix.fabricmode }} --include-onie=true | |
old/hhfab vlab gen -v | |
old/hhfab vlab up -v --ready setup-vpcs --ready test-connectivity --ready exit --usb=true | |
- name: Build current hhfab | |
run: | | |
just --timestamp oci_repo=127.0.0.1:30000 oci=http push | |
- name: hhfab vlab up --upgrade | |
env: | |
HHFAB_REG_REPO: 127.0.0.1:30000 | |
run: | | |
bin/hhfab vlab up -v --ready setup-vpcs --ready test-connectivity --ready exit --upgrade | |
- 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 | |
- vlab-upgrade | |
if: ${{ always() }} | |
steps: | |
- run: | | |
result="${{ needs.vlab.result }}" | |
if [[ $result == "success" || $result == "skipped" ]]; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
publish-release: | |
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 | |
publish-master: | |
runs-on: lab | |
if: github.event.ref == 'refs/heads/master' && 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 for master | |
run: | | |
just --timestamp oci_repo=ghcr.io version_extra=-master push push-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 |