Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Add golang tests and linter launch #29

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/go_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Go linter for images

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Go linter for images
runs-on: [self-hosted, regular]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/[email protected]

- name: Run Go lint
run: |
basedir=$(pwd)
failed='false'
for dir in $(find images -type d); do
if ls $dir/go.mod &> /dev/null; then
echo "Running linter in $dir"
cd $dir
golangci-lint run
if [ $? -ne 0 ]; then
echo "Linter failed in $dir"
failed='true'
fi
cd $basedir
fi
done
if [ $failed == 'true' ]; then
exit 1
fi
41 changes: 41 additions & 0 deletions .github/workflows/go_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Go tests for images

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Go tests for images
runs-on: [self-hosted, regular]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Run Go tests
run: |
basedir=$(pwd)
failed='false'
for dir in $(find images -type d); do
if ls $dir/*_test.go &> /dev/null; then
echo "Running tests in $dir"
cd $dir
go test -v
if [ $? -ne 0 ]; then
echo "Tests failed in $dir"
failed='true'
fi
cd $basedir
fi
done
if [ $failed == 'true' ]; then
exit 1
fi
39 changes: 39 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
run:
timeout: 10m

issues:
exclude:
- ST1005.*
- "should not use dot imports"
- "don't use an underscore in package name"
- "exported: .*"

linters-settings:
gci:
sections:
- standard
- default
errcheck:
ignore: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy

linters:
disable-all: true
enable:
- dogsled
- errcheck
- gci
- gocritic
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
# - structcheck
- typecheck
- unconvert
- unparam
- whitespace
- copyloopvar
Loading