go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/.github/workflows/pr-test-lint.yml (about)

     1  name: Code Test
     2  
     3  ## Only trigger tests if source is changing
     4  on:
     5    push:
     6      paths:
     7        - '**.go'
     8        - '**.mod'
     9        - 'go.sum'
    10  
    11  env:
    12    GO_VERSION: ">=1.21.0"
    13  
    14  jobs:
    15    # Check if there is any dirty change for go mod tidy
    16    go-mod:
    17      runs-on: ubuntu-latest
    18      steps:
    19        - name: Checkout code
    20          uses: actions/checkout@v4
    21  
    22        - name: Install Go
    23          uses: actions/setup-go@v4
    24          with:
    25            go-version: ${{ env.GO_VERSION }}
    26            cache: false
    27  
    28        - name: Check go mod
    29          run: |
    30            go mod tidy
    31            git diff --exit-code go.mod
    32  
    33    golangci-lint:
    34      runs-on: ubuntu-latest
    35      steps:
    36        - name: Checkout code
    37          uses: actions/checkout@v4
    38  
    39        - name: Install Go
    40          uses: actions/setup-go@v4
    41          with:
    42            go-version: ${{ env.GO_VERSION }}
    43            cache: false
    44  
    45        - run: make providers/build/core
    46  
    47        - name: Run golangci-lint
    48          uses: golangci/golangci-lint-action@v3.7.0
    49          with:
    50            version: latest
    51  
    52    go-test:
    53      runs-on: ubuntu-latest
    54      steps:
    55        - name: Install Go
    56          uses: actions/setup-go@v4
    57          with:
    58            go-version: ${{ env.GO_VERSION }}
    59            cache: false
    60            
    61        - name: Checkout code
    62          uses: actions/checkout@v4
    63  
    64        # https://github.com/actions/cache/blob/main/examples.md#go---modules
    65        - uses: actions/cache@v3
    66          with:
    67            path: |
    68              ~/.cache/go-build
    69              ~/go/pkg/mod
    70            key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    71            restore-keys: |
    72              ${{ runner.os }}-go-
    73  
    74        - name: Test cnquery
    75          run: make test/go/plain-ci
    76          
    77        - name: Test Providers
    78          run: make providers/test
    79  
    80        - uses: actions/upload-artifact@v3  # upload test results
    81          if: success() || failure()        # run this step even if previous step failed
    82          with:                           
    83            name: test-results
    84            path: report.xml
    85  
    86    license-check:
    87      runs-on: ubuntu-latest
    88      steps:
    89        - name: Checkout code
    90          uses: actions/checkout@v4
    91  
    92        - name: Setup Copywrite
    93          uses: hashicorp/setup-copywrite@v1.1.2
    94          with:
    95            version: v0.16.4
    96  
    97        - name: Check Header Compliance
    98          run: copywrite headers --plan