Skip to content

Commit

Permalink
Add GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
leoparente committed Dec 5, 2024
1 parent 1d664fe commit b232b00
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
run:
timeout: 5m
modules-download-mode: readonly

output:
formats: colored-line-number

linters:
enable:
- revive
- errcheck
- unused
- staticcheck
- ineffassign
- govet
- gosimple
- bodyclose
- gci

issues:
exclude-use-default: false
exclude-rules:
- path: /*.go
text: "package-comments: should have a package comment"
linters:
- revive

severity:
default-severity: error

linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/netboxlabs/orb-discovery)
custom-order: true
33 changes: 33 additions & 0 deletions .github/workflows/network-discovery-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Network Discovery - lint
on:
push:
branches:
- "!release"
paths:
- "network-discovery/**"
pull_request:
paths:
- "network-discovery/**"

permissions:
contents: read

jobs:
golangci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
check-latest: true
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.62
working-directory: nerwork-discovery
args: --config ../.github/golangci.yaml
skip-pkg-cache: true
skip-build-cache: true
66 changes: 66 additions & 0 deletions .github/workflows/network-discovery-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Network Discovery - test
on:
push:
branches:
- "!release"
paths:
- "network-discovery/**"
- "!network-discovery/docker/**"
pull_request:
paths:
- "network-discovery/**"
- "!network-discovery/docker/**"

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

permissions:
contents: write
pull-requests: write

jobs:
go-test:
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: network-discovery
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
check-latest: true
- name: Run go build
run: go build ./...
- name: Install additional dependencies
run: |
go install github.com/mfridman/[email protected]
- name: Run go test
id: go-test
run: |
make test-coverage
echo 'coverage-report<<EOF' >> $GITHUB_OUTPUT
cat .coverage/test-report.md >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "coverage-total=$(cat .coverage/coverage.txt)" >> $GITHUB_OUTPUT
- name: Find comment
uses: peter-evans/find-comment@v3
id: existing-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Go test coverage
- name: Post comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.existing-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Go test coverage
${{ steps.go-test.outputs.coverage-report }}
Total coverage: ${{ steps.go-test.outputs.coverage-total }}%
edit-mode: replace

0 comments on commit b232b00

Please sign in to comment.