From 7fc099b2862c20088781b303cc350e8a27d8f764 Mon Sep 17 00:00:00 2001 From: 24_OskinEA <24_OskinEA@iux.local> Date: Sun, 17 May 2026 21:40:13 +0300 Subject: [PATCH] add gitea ci workflow --- .gitea/workflows/ci.yml | 44 +++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++++++++++++++++ calculator.go | 13 +++++++++++ calculator_test.go | 24 ++++++++++++++++++++ cmd/main.go | 11 ++++++++++ go.mod | 3 +++ 6 files changed, 142 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 .github/workflows/ci.yml create mode 100644 calculator.go create mode 100644 calculator_test.go create mode 100644 cmd/main.go create mode 100644 go.mod diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..cfeca9b --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,44 @@ +name: Go CI + +on: + push: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - uses: golangci/golangci-lint-action@v6 + with: + version: latest + + test: + runs-on: ubuntu-latest + needs: lint + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - run: go test -cover ./... + + build: + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - run: go build -o app ./cmd diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a025a73 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: Go CI + +on: + push: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - uses: golangci/golangci-lint-action@v6 + with: + version: latest + + test: + runs-on: ubuntu-latest + needs: lint + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - run: go test -cover ./... + + build: + runs-on: ubuntu-latest + needs: test + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - run: go build -o app ./cmd diff --git a/calculator.go b/calculator.go new file mode 100644 index 0000000..2b77b15 --- /dev/null +++ b/calculator.go @@ -0,0 +1,13 @@ +package calculator + +func Add(a, b int) int { + return a + b +} + +func Subtract(a, b int) int { + return a - b +} + +func Multiply(a, b int) int { + return a * b +} diff --git a/calculator_test.go b/calculator_test.go new file mode 100644 index 0000000..dc1d080 --- /dev/null +++ b/calculator_test.go @@ -0,0 +1,24 @@ +package calculator + +import "testing" + +func TestAdd(t *testing.T) { + result := Add(2, 3) + if result != 5 { + t.Errorf("expected 5, got %d", result) + } +} + +func TestSubtract(t *testing.T) { + result := Subtract(5, 3) + if result != 2 { + t.Errorf("expected 2, got %d", result) + } +} + +func TestMultiply(t *testing.T) { + result := Multiply(4, 3) + if result != 12 { + t.Errorf("expected 12, got %d", result) + } +} diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 0000000..7d32d4b --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + + "go-ci-lab" +) + +func main() { + fmt.Println(calculator.Add(2, 3)) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..dde04a8 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module go-ci-lab + +go 1.22.2