Skip to content

Commit dc1f796

Browse files
authored
Merge pull request #16 from Semih702/ci/go-checks
ci: add Go checks and LF normalization
2 parents 6db4e39 + 122be1c commit dc1f796

4 files changed

Lines changed: 107 additions & 0 deletions

File tree

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
8+
[*.go]
9+
indent_style = tab
10+
11+
[*.{yml,yaml}]
12+
indent_style = space
13+
indent_size = 2
14+
15+
[*.md]
16+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Normalize Go files to LF
2+
*.go text eol=lf
3+
4+
# Shell scripts (CI / tooling)
5+
*.sh text eol=lf
6+
7+
# YAML / config files
8+
*.yml text eol=lf
9+
*.yaml text eol=lf
10+
11+
# Markdown
12+
*.md text eol=lf

.github/workflows/go-ci.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: go-ci
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "collector/**"
7+
- "proxy/**"
8+
- ".github/workflows/go-ci.yaml"
9+
push:
10+
branches: ["main"]
11+
paths:
12+
- "collector/**"
13+
- "proxy/**"
14+
- ".github/workflows/go-ci.yaml"
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
go-checks:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
module: [collector, proxy]
26+
27+
defaults:
28+
run:
29+
shell: bash
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Go
36+
uses: actions/setup-go@v5
37+
with:
38+
go-version-file: ${{ matrix.module }}/go.mod
39+
cache: true
40+
cache-dependency-path: |
41+
${{ matrix.module }}/go.sum
42+
43+
- name: gofmt (check)
44+
working-directory: ${{ matrix.module }}
45+
run: |
46+
set -euo pipefail
47+
unformatted="$(gofmt -l .)"
48+
if [ -n "$unformatted" ]; then
49+
echo "gofmt required in:"
50+
echo "$unformatted"
51+
exit 1
52+
fi
53+
54+
- name: go mod tidy (check)
55+
working-directory: ${{ matrix.module }}
56+
run: |
57+
set -euo pipefail
58+
go mod tidy
59+
git diff --exit-code -- go.mod go.sum
60+
61+
- name: go mod verify
62+
working-directory: ${{ matrix.module }}
63+
run: |
64+
set -euo pipefail
65+
go mod verify
66+
67+
- name: go vet
68+
working-directory: ${{ matrix.module }}
69+
run: |
70+
set -euo pipefail
71+
go vet ./...
72+
73+
- name: go test
74+
working-directory: ${{ matrix.module }}
75+
run: |
76+
set -euo pipefail
77+
go test ./...

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Editor-specific settings
2+
.vscode/

0 commit comments

Comments
 (0)