From 8758da3ebe8b34add75a3c3e3cacc2ebcc4b622d Mon Sep 17 00:00:00 2001 From: Amritanshu Darbari Date: Tue, 1 Jul 2025 15:59:59 +0530 Subject: [PATCH] ci: Add GitHub Actions workflow for CI - Create a CI pipeline that runs on push and pull_request events to the main branch. - The workflow checks out the code, sets up Go, and runs both unit and integration tests. - This ensures that all changes are automatically validated before being merged. --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 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..5b7d112 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: Go CI/CD Pipeline + +# This is the name of the workflow as it will appear in the "Actions" tab of your GitHub repository. + +# The "on" section defines the events that trigger this workflow. +on: + # Run this workflow on any push event to the "main" branch. + push: + branches: [ "main" ] + # Run this workflow on any pull request that targets the "main" branch. + pull_request: + branches: [ "main" ] + +# A workflow is made up of one or more "jobs" that can run in parallel or sequentially. +jobs: + # We have a single job in this workflow called "build-and-test". + build-and-test: + # This job will run on a fresh virtual machine hosted by GitHub, using the latest version of Ubuntu. + runs-on: ubuntu-latest + + # "steps" are the sequence of tasks that will be executed as part of the job. + steps: + # Step 1: This is a pre-made action that checks out your repository's code + # onto the runner, so the workflow can access it. + - name: Checkout Code + uses: actions/checkout@v4 + + # Step 2: This action sets up the Go programming language environment on the runner. + - name: Set up Go + uses: actions/setup-go@v5 + with: + # We specify the exact version of Go to match our project's go.mod file. + go-version: '1.24.3' + + # Step 3: Run the unit tests. We run these first because they are fast + # and give us quick feedback if something is wrong. + - name: Run Unit Tests + run: go test -v ./... + + # Step 4: Run the integration test. This step only runs if the unit tests passed. + # The ubuntu-latest runner comes with Docker pre-installed, which our test needs. + - name: Run Integration Test + run: go test -v -tags=integration