diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..61eeef4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI Pipeline - nf-example + +on: + push: + branches: [ "main", "lab7-ci" ] + pull_request: + branches: [ "main" ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: Install dependencies + run: go mod tidy + + - name: Run Linter + run: | + go install golang.org/x/lint/golint@latest + golint ./... + + - name: Build the application + run: go build -v ./... + + - name: Run Unit Tests + run: go test ./... -v diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2cadfa9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: CI Pipeline for nf-example + +on: + push: + branches: [ lab7-ci, main ] + pull_request: + branches: [ main ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + + - name: Install dependencies + run: go mod tidy + + - name: Lint check + run: | + go fmt ./... + echo "✅ Code formatting checked" + + - name: Build project + run: go build -v ./... + + - name: Run unit tests + run: go test ./... -v diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..6854be9 --- /dev/null +++ b/main_test.go @@ -0,0 +1,11 @@ +package main + +import "testing" + +func TestSum(t *testing.T) { + a, b := 2, 3 + result := a + b + if result != 5 { + t.Errorf("Expected 5, got %d", result) + } +}