Skip to content

Commit

Permalink
Merge pull request #105 from ispeakc0de/v2.0.0-tracker
Browse files Browse the repository at this point in the history
[cherrypick for 2.0.x]
  • Loading branch information
Shubham Chaudhary authored Aug 5, 2021
2 parents 5ab0af6 + 9a0d683 commit 66e9067
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 96 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build
on:
pull_request:
branches: [master]
branches: [v2.0.x]
types: [opened, synchronize, reopened]

jobs:
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
DOCKER_IMAGE: chaos-exporter
DOCKER_TAG: ci
run: |
make build-chaos-exporter
make build
tests:
runs-on: ubuntu-latest
Expand All @@ -71,18 +71,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v2


#Install and configure a kind cluster
- name: Installing Prerequisites (KinD Cluster)
uses: engineerd/[email protected]
with:
version: "v0.7.0"

- name: Configuring and testing the Installation
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
kubectl cluster-info --context kind-kind
kind get kubeconfig --internal >$HOME/.kube/config
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
mkdir -p $HOME/.kube
cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
kubectl get nodes
- name: Dependency checks
run: |
make deps
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
DNAME: ${{ secrets.DNAME }}
DPASS: ${{ secrets.DPASS }}
run: |
make push-chaos-exporter
make push
tests:
needs: pre-checks
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
DNAME: ${{ secrets.DNAME }}
DPASS: ${{ secrets.DPASS }}
run: |
make push-chaos-exporter
make push
- name: Build & Push Docker Image with latest tag
env:
Expand All @@ -81,7 +81,7 @@ jobs:
DNAME: ${{ secrets.DNAME }}
DPASS: ${{ secrets.DPASS }}
run: |
make push-chaos-exporter
make push
tests:
needs: pre-checks
Expand Down
54 changes: 47 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,28 @@
IS_DOCKER_INSTALLED = $(shell which docker >> /dev/null 2>&1; echo $$?)

# docker info
DOCKER_REGISTRY ?= docker.io
DOCKER_REPO ?= litmuschaos
DOCKER_IMAGE ?= chaos-exporter
DOCKER_TAG ?= ci

.PHONY: help
help:
@echo ""
@echo "Usage:-"
@echo "\tmake deps -- sets up dependencies for image build"
@echo "\tmake build -- builds the chaos-exporter binary & docker multi-arch image"
@echo "\tmake push -- pushes the chaos-exporter multi-arch image"
@echo "\tmake build-amd64 -- builds the chaos-exporter binary & docker amd64 image"
@echo "\tmake push-amd64 -- pushes the chaos-exporter amd64 image"
@echo ""

.PHONY: all
all: deps gotasks build test push

.PHONY: gotasks
gotasks: unused-package-check

.PHONY: unused-package-check
unused-package-check:
@echo "------------------"
Expand All @@ -22,6 +40,7 @@ unused-package-check:
.PHONY: deps
deps: build_check_docker godeps bdddeps

.PHONY: build_check_docker
build_check_docker:
@if [ $(IS_DOCKER_INSTALLED) -eq 1 ]; \
then echo "" \
Expand All @@ -30,13 +49,13 @@ build_check_docker:
&& exit 1; \
fi;

.PHONY: godeps
godeps:
@echo ""
@echo "INFO:\tverifying dependencies for chaos exporter build ..."
@go get -u -v golang.org/x/lint/golint
@go get -u -v golang.org/x/tools/cmd/goimports


.PHONY: bdddeps
bdddeps:
@echo "------------------"
Expand All @@ -55,13 +74,34 @@ test:
@echo "------------------"
@go test ./... -v -count=1

.PHONY: build-chaos-exporter build-chaos-exporter-amd64 push-chaos-exporter

build-chaos-exporter:
.PHONY: build
build:

@echo "-------------------------"
@echo "--> Build go-runner image"
@echo "-------------------------"
@docker buildx build --file Dockerfile --progress plane --no-cache --platform linux/arm64,linux/amd64 --tag $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) .

build-for-amd64:
@docker build -f Dockerfile --no-cache -t $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETPLATFORM="linux/amd64"
.PHONY: push
push:

push-chaos-exporter:
@echo "------------------------------"
@echo "--> Pushing image"
@echo "------------------------------"
@docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/arm64,linux/amd64 --tag $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) .

.PHONY: build-amd64
build-amd64:

@echo "------------------------------"
@echo "--> Build go-runner image"
@echo "-------------------------"
@docker build -f Dockerfile --no-cache -t $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETPLATFORM="linux/amd64"

.PHONY: push-amd64
push-amd64:

@echo "------------------------------"
@echo "--> Pushing image"
@echo "------------------------------"
@sudo docker push $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@ module github.com/litmuschaos/chaos-exporter
go 1.14

require (
github.com/aws/aws-sdk-go v1.34.18
github.com/imdario/mergo v0.3.9 // indirect
github.com/aws/aws-sdk-go v1.36.27
github.com/litmuschaos/chaos-operator v0.0.0-20210415200829-e74fffdeac4c
github.com/litmuschaos/litmus-go v0.0.0-20210517045408-d6d4797d4d0d
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.15.0
github.com/onsi/gomega v1.10.5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.6.0
github.com/sirupsen/logrus v1.4.2
github.com/sirupsen/logrus v1.7.0
github.com/stretchr/testify v1.5.1 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.17.3
k8s.io/apimachinery v0.17.3
k8s.io/client-go v12.0.0+incompatible
k8s.io/utils v0.0.0-20200414100711-2df71ebbae66 // indirect
)

replace (
Expand Down
Loading

0 comments on commit 66e9067

Please sign in to comment.