From c4b144da8b6198e339b35bcded312a6470fc0fbd Mon Sep 17 00:00:00 2001 From: Peter Szabo Date: Fri, 16 Sep 2022 09:44:17 +0200 Subject: [PATCH 1/2] ci: move workflows to github actions --- .circleci/config.yml | 61 ----------------------------- .github/dependabot.yaml | 23 +++++++++++ .github/workflows/ci.yml | 34 +++++++++++++++++ .github/workflows/docker.yml | 74 ++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 61 deletions(-) create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/docker.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index f4a4576..e9b788d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,72 +3,11 @@ version: 2.1 orbs: docker: banzaicloud/docker@0.0.7 -jobs: - build: - docker: - - image: cimg/go:1.18 - 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-v1-{{ .Branch }}-{{ checksum "go.sum" }} - - gomod-v1-{{ .Branch }} - - gomod-v1-master - - gomod-v1 - - - run: - name: Download Go module cache - command: go mod download - - - save_cache: - name: Save Go module cache - key: gomod-v1-{{ .Branch }}-{{ checksum "go.sum" }} - paths: - - /home/circleci/go/pkg/mod - - - restore_cache: - name: Restore license cache - keys: - - licensei-v1-{{ .Branch }}-{{ checksum "go.sum" }} - - - run: - name: Download license information for dependencies - command: make license-cache - - - save_cache: - name: Save license cache - key: licensei-v1-{{ .Branch }}-{{ checksum "go.sum" }} - paths: - - .licensei.cache - - - run: - name: Run checks - command: make check - - - 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 ci: jobs: - - build - - docker/build: name: Docker build executor: docker/machine-dlc diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..759a596 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,23 @@ +version: 2 + +updates: + - package-ecosystem: "docker" + directory: "/" + labels: + - "dependencies" + schedule: + interval: "daily" + + - package-ecosystem: "gomod" + directory: "/" + labels: + - "dependencies" + schedule: + interval: "daily" + + - package-ecosystem: "github-actions" + directory: "/" + labels: + - "dependencies" + schedule: + interval: "daily" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ca59da2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download license information for dependencies + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: make license-cache + + - name: Check licenses + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: make license-check + + - name: Run checks + run: | + make check diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..38d55ab --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,74 @@ +name: Docker + +on: + push: + branches: + - master + tags: + - "[0-9]+.[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" + +env: + PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 + +jobs: + docker: + name: Docker + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.ref }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Determine tag or commit + uses: haya14busa/action-cond@v1 + id: refortag + with: + cond: ${{ startsWith(github.ref, 'refs/tags/') }} + if_true: ${{ github.ref }} + if_false: latest + + - name: Determine image tag + id: imagetag + run: echo "::set-output name=value::${TAG_OR_BRANCH##*/}" + env: + TAG_OR_BRANCH: ${{ steps.refortag.outputs.value }} + + - name: Build allspark + uses: docker/build-push-action@v3 + with: + file: Dockerfile + platforms: linux/amd64 + push: true + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + tags: | + ghcr.io/banzaicloud/allspark:${{ steps.imagetag.outputs.value }} + banzaicloud/allspark:${{ steps.imagetag.outputs.value }} From 0b64bfdacb39340c5fcaa8684f04e7ee0af4f114 Mon Sep 17 00:00:00 2001 From: Peter Szabo Date: Fri, 16 Sep 2022 10:19:17 +0200 Subject: [PATCH 2/2] fix(ci): fix license check --- .licensei.toml | 23 +++++++++++++++++++++++ Makefile | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.licensei.toml b/.licensei.toml index 0f69dba..5c1d8d4 100644 --- a/.licensei.toml +++ b/.licensei.toml @@ -7,4 +7,27 @@ approved = [ ] ignored = [ + "google.golang.org/protobuf", ] + +[header] +ignoreFiles = [ + "allspark.pb.go", + "producer.go", + "kafkaProduce.go", + "kafkaConsume.go", + "consumer.go", +] +template = """// Copyright © :YEAR: Banzai Cloud +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License.""" diff --git a/Makefile b/Makefile index c9c595c..f7560e0 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ DOCKER_TAG ?= ${VERSION} # Dependency versions GOLANGCI_VERSION = 1.45.0 GOLANG_VERSION = 1.18 -LICENSEI_VERSION = 0.3.1 +LICENSEI_VERSION = 0.6.1 # Add the ability to override some variables # Use with care @@ -122,7 +122,7 @@ bin/licensei-${LICENSEI_VERSION}: .PHONY: license-check license-check: bin/licensei ## Run license check bin/licensei check - ./scripts/check-header.sh + bin/licensei header .PHONY: license-cache license-cache: bin/licensei ## Generate license cache