From f32b49562c4dd5e0b4f7e77f522a98fd9119cbf5 Mon Sep 17 00:00:00 2001 From: kevinvernaza Date: Thu, 13 Nov 2025 16:27:52 +0000 Subject: [PATCH 1/2] ci: add GitHub Actions pipeline for build and test --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/ci.yml 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 From 0cd589bf7c672b7767563e83e2f9246eb7545027 Mon Sep 17 00:00:00 2001 From: kevinvernaza Date: Thu, 13 Nov 2025 16:47:56 +0000 Subject: [PATCH 2/2] test: add CI pipeline and sample unit test for lab7 --- .github/workflows/test.yml | 34 ++++++++++++++++++++++++++++++++++ main_test.go | 11 +++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 main_test.go 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) + } +}