name: "Lines of code statistics"
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  release:
    types:
      - published

permissions: read-all

jobs:
  loc:
    name: Lines of code
    runs-on: ubuntu-latest
    steps:
      - name: Install go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
        with:
          cache: false
          check-latest: true
          go-version: 1.26.x
      - name: Check out source code
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
      - name: Install dependencies
        run: |
          cd $GITHUB_WORKSPACE
          go install github.com/hhatto/gocloc/cmd/gocloc@latest
      - name: All sources
        run: |
          cd $GITHUB_WORKSPACE
          gocloc .
      - name: All sources (except tests)
        run: |
          cd $GITHUB_WORKSPACE
          gocloc --not-match='.*_test.go' .
