Skip to content

Commit

Permalink
Add GH Actions CI Workflow (#1355)
Browse files Browse the repository at this point in the history
Add GH Actions CI workflow
Add GitHub Actions status badge to README

Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
Co-authored-by: Julio Lopez <1953782+julio-lopez@users.noreply.github.com>
  • Loading branch information
ihcsim and julio-lopez committed Apr 8, 2022
1 parent 075dbef commit 4e590f0
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 5 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
gomod:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: make gomod
- run: make go-mod-download
- run: tar -cvf ./src.tar.gz ./ # preserve file permissions
- uses: actions/upload-artifact@v3
with:
name: src
path: ./src.tar.gz
lint:
runs-on: ubuntu-20.04
needs: gomod
steps:
- uses: actions/download-artifact@v3
with:
name: src
- run: tar -xvf ./src.tar.gz
- run: make golint
test:
runs-on: ubuntu-20.04
needs: [gomod, lint]
strategy:
fail-fast: false
matrix:
testSuite: [test, integration-test, helm-test]
steps:
- uses: actions/download-artifact@v3
with:
name: src
- uses: AbsaOSS/k3d-action@v2
with:
cluster-name: "kanister-run-${{ matrix.testSuite }}"
args: >-
--agents 3
--no-lb
--k3s-arg "--no-deploy=traefik,servicelb@server:*"
- run: tar -xvf ./src.tar.gz
- run: |
make install-csi-hostpath-driver
make install-minio
if: matrix.testSuite == 'integration-test' || matrix.testSuite == 'helm-test'
- run: make ${{ matrix.testSuite }}
build:
runs-on: ubuntu-20.04
needs: [gomod, lint, test]
strategy:
matrix:
bin: [controller, kanctl, kando]
steps:
- uses: actions/download-artifact@v3
with:
name: src
- run: tar -xvf ./src.tar.gz
- run: make build BIN=${{ matrix.bin }}
docs:
runs-on: ubuntu-20.04
needs: gomod
steps:
- uses: actions/download-artifact@v3
with:
name: src
- run: tar -xvf ./src.tar.gz
- run: make docs
release:
runs-on: ubuntu-20.04
needs: [test, build]
if: github.ref_name == 'master' || startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v3
with:
name: src
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- run: tar -xvf ./src.tar.gz
- run: make release-snapshot
- run: ./build/push_images.sh
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ bin/$(ARCH)/$(BIN):
GOARCH=$(ARCH) \
VERSION=$(VERSION) \
PKG=$(PKG) \
BIN=$(BIN) \
./build/build.sh \
"'
# Example: make shell CMD="-c 'date > datefile'"
Expand Down Expand Up @@ -285,3 +286,6 @@ stop-kind:

check:
@./build/check.sh

gomod:
@$(MAKE) run CMD='-c "./build/gomod.sh"'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Kanister

[![Go Report Card](https://goreportcard.com/badge/github.com/kanisterio/kanister)](https://goreportcard.com/report/github.com/kanisterio/kanister)
[![GitHub Actions](https://github.com/kanisterio/actions/kanister/workflows/main.yaml/badge.svg)](https://github.com/kanisterio/kanister/actions)
[![Build Status](https://travis-ci.com/kanisterio/kanister.svg?branch=master)](https://travis-ci.com/kanisterio/kanister)


A framework for data management in Kubernetes. It allows domain experts to
define application-specific data management workflows through Kubernetes API
extensions. Kanister makes it easy to integrate your application's data with
Expand Down
6 changes: 3 additions & 3 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

# Copyright 2019 The Kanister Authors.
#
#
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -29,7 +29,7 @@ if [ -z "${VERSION}" ]; then
fi

export CGO_ENABLED=0
go install -v \
go build -v \
-installsuffix "static" \
-ldflags "-X ${PKG}/pkg/version.VERSION=${VERSION}" \
./cmd/...
./cmd/${BIN}/...
5 changes: 4 additions & 1 deletion build/golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ set -o errexit
set -o nounset

SKIP_DIR_REGEX="pkg/client"
TIMEOUT="5m"
TIMEOUT="10m"

echo "Running golangci-lint..."

golangci-lint run --timeout ${TIMEOUT} --skip-dirs ${SKIP_DIR_REGEX} -E maligned,whitespace,gocognit,unparam -e '`ctx` is unused'

echo "PASS"
echo

echo "PASS"
echo
27 changes: 27 additions & 0 deletions build/gomod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# Copyright 2019 The Kanister Authors.
#
# Copyright 2016 The Kubernetes Authors.
#
# 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.

set -o errexit
set -o nounset

go mod tidy
status=`git status --porcelain go.mod go.sum`
if [ ! -z "$status" ]; then
echo 'stale go.mod and go.sum: please run `go mod tidy`'
exit 1
fi
1 change: 1 addition & 0 deletions build/local_kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ install_csi_hostpath_driver() {
cd /tmp
git clone https://github.com/kubernetes-csi/csi-driver-host-path.git
cd csi-driver-host-path
sed -i 's/mountPropagation: Bidirectional/\#mountPropagation: Bidirectional/g' deploy/kubernetes-1.21/hostpath/csi-hostpath-plugin.yaml
./deploy/kubernetes-1.21/deploy.sh

# Create StorageClass
Expand Down

0 comments on commit 4e590f0

Please sign in to comment.