|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | +# |
| 4 | +# CI workflow for nvcf-go public GitHub repository. |
| 5 | +# Runs on push to main and on pull requests. |
| 6 | +# |
| 7 | +# External contributor sandboxing (SEC-1): |
| 8 | +# PRs from non-collaborators require maintainer approval before workflows run. |
| 9 | +# This is enforced via the repository's "Fork pull request workflows" setting |
| 10 | +# (Settings → Actions → Fork pull request workflows from outside collaborators |
| 11 | +# → set to "Require approval for all outside collaborators"). |
| 12 | + |
| 13 | +name: CI |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: |
| 18 | + - main |
| 19 | + pull_request: |
| 20 | + branches: |
| 21 | + - main |
| 22 | + workflow_dispatch: |
| 23 | + |
| 24 | +env: |
| 25 | + GO_VERSION: "1.24" |
| 26 | + |
| 27 | +jobs: |
| 28 | + # --------------------------------------------------------------------------- |
| 29 | + # Build — verify the library compiles cleanly |
| 30 | + # --------------------------------------------------------------------------- |
| 31 | + build: |
| 32 | + name: Build |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Set up Go |
| 39 | + uses: actions/setup-go@v5 |
| 40 | + with: |
| 41 | + go-version: ${{ env.GO_VERSION }} |
| 42 | + cache: true |
| 43 | + |
| 44 | + - name: Download dependencies |
| 45 | + run: go mod download |
| 46 | + |
| 47 | + - name: Build |
| 48 | + run: go build ./... |
| 49 | + |
| 50 | + # --------------------------------------------------------------------------- |
| 51 | + # Lint — static analysis |
| 52 | + # --------------------------------------------------------------------------- |
| 53 | + lint: |
| 54 | + name: Lint |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Set up Go |
| 61 | + uses: actions/setup-go@v5 |
| 62 | + with: |
| 63 | + go-version: ${{ env.GO_VERSION }} |
| 64 | + cache: true |
| 65 | + |
| 66 | + - name: Run go vet |
| 67 | + run: go vet ./... |
| 68 | + |
| 69 | + - name: Run golangci-lint |
| 70 | + uses: golangci/golangci-lint-action@v6 |
| 71 | + with: |
| 72 | + version: v2.1 |
| 73 | + args: --timeout=5m ./... |
| 74 | + |
| 75 | + # --------------------------------------------------------------------------- |
| 76 | + # Test — unit tests |
| 77 | + # --------------------------------------------------------------------------- |
| 78 | + test: |
| 79 | + name: Test |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - name: Checkout |
| 83 | + uses: actions/checkout@v4 |
| 84 | + |
| 85 | + - name: Set up Go |
| 86 | + uses: actions/setup-go@v5 |
| 87 | + with: |
| 88 | + go-version: ${{ env.GO_VERSION }} |
| 89 | + cache: true |
| 90 | + |
| 91 | + - name: Download dependencies |
| 92 | + run: go mod download |
| 93 | + |
| 94 | + - name: Run tests |
| 95 | + run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... |
| 96 | + |
| 97 | + - name: Upload coverage |
| 98 | + uses: codecov/codecov-action@v4 |
| 99 | + if: always() |
| 100 | + with: |
| 101 | + files: coverage.txt |
| 102 | + fail_ci_if_error: false |
0 commit comments