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