CI #613
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 | |
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: oldstable | |
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@v4 | |
with: | |
version: latest | |
# unfortunately the package cache is creating lots of errors/warnings right now | |
# for details: https://github.com/golangci/golangci-lint-action/issues/677 | |
skip-pkg-cache: true | |
- 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: lab | |
timeout-minutes: 30 | |
strategy: | |
matrix: | |
preset: | |
- lab | |
- vlab | |
dhcpd: | |
- isc | |
- hedgehog | |
exclude: | |
- preset: vlab | |
dhcpd: hedgehog | |
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 git for private Go modules | |
env: | |
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
run: git config --global url.https://[email protected]/.insteadOf https://github.com/ | |
- name: Build all | |
run: | | |
make build | |
- 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 | |
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: | |
matrix: | |
mode: | |
- collapsed-core | |
- spine-leaf | |
dhcpd: | |
- isc | |
- hedgehog | |
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 git for private Go modules | |
env: | |
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
run: git config --global url.https://[email protected]/.insteadOf https://github.com/ | |
- 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 | |
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: Setup git for private Go modules | |
env: | |
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
run: git config --global url.https://[email protected]/.insteadOf https://github.com/ | |
- 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 |