github.com/google/osv-scalibr@v0.4.1/.github/workflows/go.yml (about)

     1  # This workflow will build a golang project
     2  # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
     3  
     4  name: Go
     5  
     6  on:
     7    push:
     8      branches: [ "main" ]
     9    pull_request:
    10      branches: [ "main" ]
    11  
    12  jobs:
    13    linelint:
    14      runs-on: ubuntu-latest
    15      steps:
    16        - uses: actions/checkout@v4
    17        - uses: fernandrone/linelint@7907a5dca0c28ea7dd05c6d8d8cacded713aca11 # v0.0.6
    18    filenames:
    19      runs-on: ubuntu-latest
    20      steps:
    21        - uses: actions/checkout@v4
    22          with:
    23            persist-credentials: false
    24        - run: |
    25            find . -mindepth 1 ! -regex '.*/[#@A-Za-z0-9._-]*' -print0 \
    26              | xargs -0 -I{} bash -c \
    27                'printf "::error file=%q::This filename contains undesired characters\n" "$1" && false' _ {}
    28    tidy:
    29      runs-on: ubuntu-latest
    30      steps:
    31        - uses: actions/checkout@v4
    32  
    33        - uses: actions/setup-go@v5
    34          with:
    35            go-version: 1.24.x
    36  
    37        - run: go mod tidy -diff
    38    lint:
    39      strategy:
    40        fail-fast: false
    41        matrix:
    42          os: [ubuntu-latest, macos-latest, windows-latest]
    43      runs-on: ${{ matrix.os }}
    44      steps:
    45          # gofmt and goimports expect that files on Window use \r\n
    46          # so we need git to not automatically translate between \n
    47        - run: git config --global core.autocrlf false
    48        - uses: actions/checkout@v4
    49  
    50        - uses: actions/setup-go@v5
    51          with:
    52            go-version: 1.24.x
    53  
    54        - name: Run golangci-lint
    55          uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
    56          with:
    57            version: v2.6
    58            args: --timeout=5m
    59    tests:
    60      strategy:
    61        fail-fast: false
    62        matrix:
    63          os: [ubuntu-latest, macos-latest, windows-latest]
    64      runs-on: ${{ matrix.os }}
    65      steps:
    66        - uses: actions/checkout@v4
    67  
    68        - name: Set up Go
    69          uses: actions/setup-go@v5
    70          with:
    71            go-version: 1.24.x
    72  
    73        - name: Install Protoc
    74          uses: arduino/setup-protoc@v3
    75          with:
    76            version: "23.x"
    77            repo-token: ${{ secrets.GITHUB_TOKEN }}
    78  
    79        - name: Set up protoc-gen-go
    80          run: go install google.golang.org/protobuf/cmd/protoc-gen-go
    81  
    82        - name: Build
    83          run: make
    84  
    85        - name: Test
    86          run: make test