Skip to content

Som | Add circle ci setup - 1 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
version: 2.1

executors:
go-executor:
docker:
- image: cimg/go:1.20
working_directory: ~/go/src/github.com/isomnath/belvedere
test-executor:
docker:
- image: cimg/go:1.20
- image: circleci/postgres:11.4-alpine
environment:
POSTGRES_DB: belvedere
POSTGRES_USER: belvedere
POSTGRES_PASSWORD: password
- image: datadog/agent:latest
environment:
DD_API_KEY: dummy
DD_APM_ENABLED: true
working_directory: ~/go/src/github.com/isomnath/belvedere

jobs:
checkout_code:
executor: go-executor
working_directory: ~/go/src/github.com/isomnath/belvedere
steps:
- run:
name: directory logging
command: |
pwd
ls -al ~
ls -al ~/go/src/github.com/isomnath/belvedere/go
ls -al ~/go/src/github.com/isomnath/belvedere/
- save_cache:
paths:
- ~/go/src/github.com/isomnath/belvedere
key: go-mod-v4-{{ checksum "go.sum" }}
- attach_workspace:
at: ~/workspace
- run:
echo "1.0.$CIRCLE_BUILD_NUM" > ~/workspace/version
- persist_to_workspace:
root: ~/workspace
paths: version

code_analysis:
executor: go-executor
working_directory: ~/go/src/github.com/isomnath/belvedere
steps:
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- attach_workspace:
at: ~/workspace
- run:
name: Install Dependencies
command: make setup-ci
- run:
name: Run static code analysis
command: |
make fmt
make vet
make lint

unit_test:
executor: test-executor
working_directory: ~/go/src/github.com/isomnath/belvedere
steps:
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- attach_workspace:
at: ~/workspace
- run:
name: Prepare workspace for running unit tests
command: |
# Setup go paths
export GOPATH=~/go
export CGO_ENABLED=0
# Install postgres client
sudo apt-get update && sudo apt install postgresql-client libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgtk-3-0 libgbm1 libasound2
make setup-ci
go get ./...
make copy-config-ci
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Static Unit Tests
command: |
make test-cover-report
cp coverage.out ~/workspace
- persist_to_workspace:
root: ~/workspace
paths:
- coverage.out

workflows:
version: 2.1
analyse-and-test:
jobs:
- checkout_code
- code_analysis:
requires:
- checkout_code
- unit_test:
requires:
- code_analysis
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ setup-ci:
@go install golang.org/x/lint/golint@latest
@echo "installing import manager tool ..."
@go install golang.org/x/tools/cmd/goimports@latest
@echo "downloading coveralls cli tool ..."
@go install github.com/mattn/goveralls@latest
@echo "installing all project dependencies ..."
@go get ./...

Expand Down