Skip to content

Commit

Permalink
Configure CircleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Turi committed Aug 10, 2021
1 parent 014e045 commit 9fcc14a
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 0 deletions.
200 changes: 200 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
version: 2.1

orbs:
helm: banzaicloud/[email protected]
docker: banzaicloud/[email protected]
aws: circleci/[email protected]

executors:
helm311:
docker:
- image: ghcr.io/banzaicloud/helm:0.0.7

jobs:
build:
parameters:
working_directory:
default: "."
description: "Root dir relative to the repository where the build is to be executed"
type: string
has_integration_tests:
default: true
description: "Set to false if the component does not provide the test-integration target"
type: boolean
resource_class: large
docker:
- image: circleci/golang:1.16
environment:
GOFLAGS: -mod=readonly

steps:
- checkout

- restore_cache:
name: Restore build dependencies
keys:
- build-deps-v1-{{ .Branch }}-{{ checksum "Makefile" }}

- restore_cache:
name: Restore Go module cache
keys:
- gomod-v2-{{ .Branch }}-{{ checksum "<< parameters.working_directory >>/go.sum" }}

- run:
working_directory: << parameters.working_directory >>
name: Download Go module cache
command: go mod download

- restore_cache:
name: Restore license cache
keys:
- licensei-v4-<< parameters.working_directory >>-{{ .Branch }}-{{ checksum "<< parameters.working_directory >>/go.sum" }}
- licensei-v4-<< parameters.working_directory >>

- run:
name: Download license information for dependencies
command: make license-cache
working_directory: << parameters.working_directory >>

- save_cache:
name: Save license cache
key: licensei-v4-<< parameters.working_directory >>-{{ .Branch }}-{{ checksum "<< parameters.working_directory >>/go.sum" }}
paths:
- << parameters.working_directory >>/.licensei.cache

- run:
name: Check dependency licenses
command: make license-check
working_directory: << parameters.working_directory >>

- save_cache:
name: Save Go module cache
key: gomod-v2-{{ .Branch }}-{{ checksum "<< parameters.working_directory >>/go.sum" }}
paths:
- /go/pkg/mod

- run:
name: Run build
command: make build
working_directory: << parameters.working_directory >>

- run:
name: Run tests
command: TEST_PKGS=$(echo `go list ./... | circleci tests split`) TEST_REPORT_NAME=results_${CIRCLE_NODE_INDEX}.xml make test
working_directory: << parameters.working_directory >>

- when:
condition: << parameters.has_integration_tests >>
steps:
- run:
name: Run integration tests
command: TEST_PKGS=$(echo `go list ./... | circleci tests split`) TEST_REPORT_NAME=results_${CIRCLE_NODE_INDEX}.xml make test-integration
working_directory: << parameters.working_directory >>

- run:
name: Run linter
command: make lint
working_directory: << parameters.working_directory >>

- save_cache:
name: Save build dependencies
key: build-deps-v1-{{ .Branch }}-{{ checksum "Makefile" }}
paths:
- bin/

- store_test_results:
path: build/test_results/

workflows:
version: 2
crd-updater:
jobs:
- build:
has_integration_tests: false

- helm/lint-chart:
executor: helm311
name: Lint crd-updater chart
charts-dir: deploy/charts
filters:
tags:
ignore: /.*/

- helm/publish-chart:
context: helm
executor: helm311
name: Publish crd-updater chart
charts-dir: helm/crd-updater
filters:
branches:
ignore: /.*/
tags:
only: /^chart\/crd-updater\/[0-9]+\.[0-9]+\.[0-9]+(?:-(?:dev|rc|alpha|beta)\.[0-9]+)?$/

- docker/build:
name: Docker build
executor: docker/machine-dlc
image: banzaicloud/crd-updater
tag: ${CIRCLE_BRANCH//\//_}
dockerfile: Dockerfile
filters:
branches:
ignore: main

- docker/custom-publish:
name: Docker build main image
executor: docker/machine-dlc
context: github
login:
- docker/login
- docker/ghcr-login
dockerfile: Dockerfile
push:
- docker/push:
registry: docker.io
image: banzaicloud/crd-updater
tag: main
- docker/push:
registry: ghcr.io
image: banzaicloud/crd-updater
tag: main
filters:
branches:
only: main

- docker/custom-publish:
name: Publish tagged & latest image
executor: docker/machine-dlc
context: github
login:
- docker/login
- docker/ghcr-login
dockerfile: Dockerfile
push:
- docker/push:
registry: docker.io
image: banzaicloud/crd-updater
tag: ${CIRCLE_TAG//\//_}
- docker/push:
registry: ghcr.io
image: banzaicloud/crd-updater
tag: ${CIRCLE_TAG//\//_}
- docker/conditional-push:
registry: docker.io
image: banzaicloud/crd-updater
tag: latest
condition-steps:
- docker/version-check:
version: ${CIRCLE_TAG//\//_}
- docker/conditional-push:
registry: ghcr.io
image: banzaicloud/crd-updater
tag: latest
condition-steps:
- docker/version-check:
version: ${CIRCLE_TAG//\//_}
filters:
tags:
only: /^v?[0-9]+\.[0-9]+\.[0-9]+(?:-(?:dev|rc|alpha|beta)\.[0-9]+)?$/
branches:
ignore: /.*/
16 changes: 16 additions & 0 deletions .licensei.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
approved = [
"mit",
"apache-2.0",
"bsd-3-clause",
"bsd-2-clause",
"mpl-2.0",
]

ignored = [
"github.com/davecgh/go-spew", # ISC license
"github.com/gogo/protobuf",
"google.golang.org/protobuf",
"github.com/ghodss/yaml",
"sigs.k8s.io/yaml", # Forked from above
"gopkg.in/fsnotify.v1",
]
1 change: 1 addition & 0 deletions deploy/charts

0 comments on commit 9fcc14a

Please sign in to comment.