Skip to content

Commit

Permalink
Merge pull request #15 from banzaicloud/move-to-gha
Browse files Browse the repository at this point in the history
ci: move workflows to github actions
  • Loading branch information
asdwsda authored Sep 16, 2022
2 parents ba19a6d + 0b64bfd commit ed7192b
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 63 deletions.
61 changes: 0 additions & 61 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -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"
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
74 changes: 74 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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 }}
23 changes: 23 additions & 0 deletions .licensei.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed7192b

Please sign in to comment.