Skip to content

Merge pull request #34 from opendefensecloud/chore/updates-and-codegen #122

Merge pull request #34 from opendefensecloud/chore/updates-and-codegen

Merge pull request #34 from opendefensecloud/chore/updates-and-codegen #122

Workflow file for this run

name: Golang CI
permissions:
contents: read
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [labeled, unlabeled, opened, synchronize, reopened]
jobs:
changes:
runs-on: ubuntu-24.04
outputs:
backend: ${{ steps.filter.outputs.backend }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4
id: filter
with:
filters: |
backend:
- '**/*.go'
- '.github/workflows/golang.yaml'
- 'flake.nix'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- 'common.mk'
- 'tools.lock'
lint:
runs-on: ubuntu-24.04
needs: changes
if: needs.changes.outputs.backend == 'true'
outputs:
go-version: ${{ steps.go-version.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- id: go-version
uses: opendefensecloud/dev-kit/.github/actions/get-go-version@f16fb83a8669ba840346929d9c45b9efe95c4da0 # v1.0.15
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
go-version: ${{ steps.go-version.outputs.version }}
- name: lint-license-and-shell
run: |
# shellcheck is pre-installed on ubuntu-24.04, this is mostly for local execution
if ! command -v shellcheck &> /dev/null; then
echo "shellcheck is missing. Installing..."
sudo apt-get update && sudo apt-get install -y shellcheck
fi
make lint-no-golangci
- name: golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9
test:
needs: lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
go-version: ${{ needs.lint.outputs.go-version }}
- name: test
run: |
make test