| 1 |
# Use the latest 2.1 version of CircleCI pipeline process engine. |
| 2 |
# See: https://circleci.com/docs/configuration-reference |
| 3 |
|
| 4 |
# For a detailed guide to building and testing with Go, read the docs: |
| 5 |
# https://circleci.com/docs/language-go/ for more details |
| 6 |
version: 2.1 |
| 7 |
|
| 8 |
# Define a job to be invoked later in a workflow. |
| 9 |
# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs |
| 10 |
jobs: |
| 11 |
build: |
| 12 |
# Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. |
| 13 |
# See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job |
| 14 |
docker: |
| 15 |
# Specify the version you desire here |
| 16 |
# See: https://circleci.com/developer/images/image/cimg/go |
| 17 |
- image: cimg/go:1.26.4@sha256:75f97ecb36a99b9fec79c80a3aaf85e406016c2606035241a95d19334e893391 |
| 18 |
|
| 19 |
# Add steps to the job |
| 20 |
# See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps |
| 21 |
steps: |
| 22 |
# Checkout the code as the first step. |
| 23 |
- checkout |
| 24 |
- restore_cache: |
| 25 |
keys: |
| 26 |
- go-mod-v4-{{ checksum "go.sum" }} |
| 27 |
- run: |
| 28 |
name: Install Dependencies |
| 29 |
command: go mod download |
| 30 |
- save_cache: |
| 31 |
key: go-mod-v4-{{ checksum "go.sum" }} |
| 32 |
paths: |
| 33 |
- "/go/pkg/mod" |
| 34 |
- run: |
| 35 |
name: Run tests |
| 36 |
command: | |
| 37 |
mkdir -p /tmp/test-reports |
| 38 |
gotestsum --junitfile /tmp/test-reports/unit-tests.xml |
| 39 |
- store_test_results: |
| 40 |
path: /tmp/test-reports |
| 41 |
|
| 42 |
# Orchestrate jobs using workflows |
| 43 |
# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows |
| 44 |
workflows: |
| 45 |
build-test: # This is the name of the workflow, feel free to change it to better match your workflow. |
| 46 |
# Inside the workflow, you define the jobs you want to run. |
| 47 |
jobs: |
| 48 |
- build |