From 122be1cc9dacdcd99781287204b9221695c993ed Mon Sep 17 00:00:00 2001 From: Semih702 Date: Mon, 9 Feb 2026 00:05:50 +0300 Subject: [PATCH] ci: add Go checks and LF normalization --- .editorconfig | 16 ++++++++ .gitattributes | 12 ++++++ .github/workflows/go-ci.yaml | 77 ++++++++++++++++++++++++++++++++++++ .gitignore | 2 + 4 files changed, 107 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/workflows/go-ci.yaml create mode 100644 .gitignore diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d7f1065 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 + +[*.go] +indent_style = tab + +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..12ca261 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +# Normalize Go files to LF +*.go text eol=lf + +# Shell scripts (CI / tooling) +*.sh text eol=lf + +# YAML / config files +*.yml text eol=lf +*.yaml text eol=lf + +# Markdown +*.md text eol=lf diff --git a/.github/workflows/go-ci.yaml b/.github/workflows/go-ci.yaml new file mode 100644 index 0000000..0a23bae --- /dev/null +++ b/.github/workflows/go-ci.yaml @@ -0,0 +1,77 @@ +name: go-ci + +on: + pull_request: + paths: + - "collector/**" + - "proxy/**" + - ".github/workflows/go-ci.yaml" + push: + branches: ["main"] + paths: + - "collector/**" + - "proxy/**" + - ".github/workflows/go-ci.yaml" + +permissions: + contents: read + +jobs: + go-checks: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + module: [collector, proxy] + + defaults: + run: + shell: bash + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: ${{ matrix.module }}/go.mod + cache: true + cache-dependency-path: | + ${{ matrix.module }}/go.sum + + - name: gofmt (check) + working-directory: ${{ matrix.module }} + run: | + set -euo pipefail + unformatted="$(gofmt -l .)" + if [ -n "$unformatted" ]; then + echo "gofmt required in:" + echo "$unformatted" + exit 1 + fi + + - name: go mod tidy (check) + working-directory: ${{ matrix.module }} + run: | + set -euo pipefail + go mod tidy + git diff --exit-code -- go.mod go.sum + + - name: go mod verify + working-directory: ${{ matrix.module }} + run: | + set -euo pipefail + go mod verify + + - name: go vet + working-directory: ${{ matrix.module }} + run: | + set -euo pipefail + go vet ./... + + - name: go test + working-directory: ${{ matrix.module }} + run: | + set -euo pipefail + go test ./... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..981c788 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Editor-specific settings +.vscode/ \ No newline at end of file