name: Go Build - CI on: workflow_dispatch: push: tags-ignore: - "v*" branches-ignore: - main pull_request: types: - opened - reopened - synchronize branches: - main jobs: quality: name: Code Quality runs-on: ubuntu-latest steps: # Checkout code - name: Checkout repository uses: actions/checkout@v4 # Set up Go environment - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: "go.mod" cache-dependency-path: "**/*.sum" cache: true - name: GolangCI Lint uses: golangci/golangci-lint-action@v8 with: version: latest - name: Run format-check run: | UNFORMATTED=$(gofmt -l .) if [ -n "$UNFORMATTED" ]; then echo "The following files are not formatted according to gofmt:" echo "$UNFORMATTED" exit 1 fi test: name: Unit Tests runs-on: ubuntu-latest steps: # Checkout code - name: Checkout repository uses: actions/checkout@v4 # Set up Go environment - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: "go.mod" cache: true cache-dependency-path: "**/*.sum" - name: Run tests run: go test -cover -coverprofile=coverage.txt ./... - name: Archive code coverage results uses: actions/upload-artifact@v4 with: name: code-coverage path: "coverage.txt" if-no-files-found: error code_coverage: name: "Code coverage report" if: github.event_name == 'pull_request' runs-on: ubuntu-latest needs: - test permissions: contents: read actions: read # to download code coverage results from "test" job pull-requests: write # write permission needed to comment on PR steps: - uses: fgrosse/go-coverage-report@v1.2.0 with: coverage-artifact-name: "code-coverage" coverage-file-name: "coverage.txt" github-baseline-workflow-ref: "release.yaml" tinygo: runs-on: ubuntu-latest needs: - test - quality steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: "go.mod" cache-dependency-path: "**/*.sum" cache: true # Setup tinygo - uses: acifani/setup-tinygo@v2 with: tinygo-version: "0.37.0" # Build fanunit firmware - name: Build FanUnit Firmware run: make build-fanunit - name: Archive FanUnit Firmware uses: actions/upload-artifact@v4 with: name: fanunit.uf2 path: "fanunit.uf2" goreleaser: runs-on: ubuntu-latest needs: - tinygo steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 # Install cosign - name: Install Cosign uses: sigstore/cosign-installer@v3 # Install GoLang - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: "go.mod" cache-dependency-path: "**/*.sum" cache: true # Setup docker buildx - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # Download FanUnit Firmware - name: Download fanunit firmware uses: actions/download-artifact@v4 with: pattern: fanunit.uf2 # Run goreleaser - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: version: latest args: release --snapshot --clean --skip sign env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: compute-blade-agent path: dist/*-SNAPSHOT-* if-no-files-found: error