Skip to content

Commit

Permalink
Chore(refactor): Modify Chaos CI Lib use actions, remove vendors, ref…
Browse files Browse the repository at this point in the history
…actor code (#10)

* Chore(refactor): Modify Chaos CI Lib use actions, remove vendors, refactor code

Signed-off-by: uditgaurav <[email protected]>

* Inital commit to the repo

Signed-off-by: uditgaurav <[email protected]>
  • Loading branch information
uditgaurav committed May 27, 2021
1 parent 07859ce commit c970021
Show file tree
Hide file tree
Showing 2,133 changed files with 2,752 additions and 909,064 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Build
on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened]

env:
REPONAME: litmuschaos
IMAGENAME: chaos-ci-lib
IMAGETAG: ci

jobs:
pre-checks:
runs-on: ubuntu-latest
steps:
# Install golang
- uses: actions/setup-go@v2
with:
go-version: 1.14

# Checkout to the latest commit
# On specific directory/path
- name: Checkout
uses: actions/checkout@v2

- name: gofmt check
run: |
if [ "$(gofmt -s -l . | wc -l)" -ne 0 ]
then
echo "The following files were found to be not go formatted:"
gofmt -s -l .
exit 1
fi
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1

build:
runs-on: ubuntu-latest
steps:

# Install golang
- uses: actions/setup-go@v2
with:
go-version: 1.14

# Checkout to the latest commit
# On specific directory/path
- uses: actions/checkout@v2

- name: Build Docker Image
env:
DOCKER_REPO: ${{ env.REPONAME }}
DOCKER_IMAGE: ${{ env.IMAGENAME }}
DOCKER_TAG: ${{ env.IMAGETAG }}
run: |
make build
security-scan:
runs-on: ubuntu-latest
steps:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'docker.io/${{ env.REPONAME }}/${{ env.IMAGENAME }}:${{ env.IMAGETAG }}'
format: 'table'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
81 changes: 81 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
name: Push
on:
push:
branches:
- master
tags-ignore:
- '**'

env:
REPONAME: litmuschaos
IMAGENAME: chaos-ci-lib
IMAGETAG: ci

jobs:
pre-checks:
runs-on: ubuntu-latest
steps:
# Install golang
- uses: actions/setup-go@v2
with:
go-version: 1.14

# Checkout to the latest commit
# On specific directory/path
- name: Checkout
uses: actions/checkout@v2

- name: gofmt check
run: |
if [ "$(gofmt -s -l . | wc -l)" -ne 0 ]
then
echo "The following files were found to be not go formatted:"
gofmt -s -l .
exit 1
fi
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1

push:
runs-on: ubuntu-latest
steps:

# Install golang
- uses: actions/setup-go@v2
with:
go-version: 1.14

- uses: actions/checkout@v2

- name: Login to GitHub Container Registry
run: echo ${{ secrets.DPASS }} | docker login -u ${{ secrets.DNAME }} --password-stdin

- name: Build Docker Image
env:
DOCKER_REPO: ${{ env.REPONAME }}
DOCKER_IMAGE: go-runner
DOCKER_TAG: ${{ env.IMAGETAG }}
run: |
make build
- name: Push Docker Image
env:
DOCKER_REPO: ${{ env.REPONAME }}
DOCKER_IMAGE: go-runner
DOCKER_TAG: ${{ env.IMAGETAG }}
run: |
make push
security-scan:
runs-on: ubuntu-latest
steps:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'docker.io/${{ env.REPONAME }}/${{ env.IMAGENAME }}:${{ env.IMAGETAG }}'
format: 'table'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release
on:
create:
tags:
- '**'
env:
REPONAME: litmuschaos
IMAGENAME: chaos-ci-lib
IMAGETAG: ci

jobs:
pre-checks:
runs-on: ubuntu-latest
steps:
# Install golang
- uses: actions/setup-go@v2
with:
go-version: 1.14

# Checkout to the latest commit
# On specific directory/path
- name: Checkout
uses: actions/checkout@v2

- name: gofmt check
run: |
if [ "$(gofmt -s -l . | wc -l)" -ne 0 ]
then
echo "The following files were found to be not go formatted:"
gofmt -s -l .
exit 1
fi
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1

image-build:
runs-on: ubuntu-latest
needs: pre-checks
steps:
# Checkout to the latest commit
# On specific directory/path
- name: Checkout
uses: actions/checkout@v2

- name: login to GitHub Container Registry
run: echo ${{ secrets.DPASS }} | docker login -u ${{ secrets.DNAME }} --password-stdin

- name: Set Tag
run: |
TAG="${GITHUB_REF#refs/*/}"
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
- name: Build & Push Docker Image with version tag
env:
DOCKER_REPO: ${{ env.REPONAME }}
DOCKER_IMAGE: ${{ env.IMAGENAME }}
DOCKER_TAG: ${RELEASE_TAG}
DNAME: ${{ secrets.DNAME }}
DPASS: ${{ secrets.DPASS }}
run: |
make push
- name: Build & Push Docker Image with latest tag
env:
DOCKER_REPO: ${{ env.REPONAME }}
DOCKER_IMAGE: ${{ env.IMAGENAME }}
DOCKER_TAG: latest
DNAME: ${{ secrets.DNAME }}
DPASS: ${{ secrets.DPASS }}
run: |
make push
security-scan:
runs-on: ubuntu-latest
steps:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'docker.io/${{ env.REPONAME }}/${{ env.IMAGENAME }}:${{ env.IMAGETAG }}'
format: 'table'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

39 changes: 21 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DOCKER_IMAGE ?= chaos-ci-lib
DOCKER_TAG ?= ci

.PHONY: all
all: format lint deps build test security-checks push
all: format lint deps build test trivy-check push

.PHONY: help
help:
Expand Down Expand Up @@ -57,27 +57,20 @@ godeps:


PHONY: build
build: docker-build
build: go-binary-build docker-build

PHONY: go-binary-build
go-binary-build:
@echo "---------------------------"
@echo "--> Building Go Test Binary"
@echo "---------------------------"
@sh build/generate_go_binary

docker-build:
@echo "----------------------------"
@echo "--> Build chaos-ci-lib image"
@echo "----------------------------"
# Dockerfile available in the repo root
sudo docker build . -f build/Dockerfile -t $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)


PHONY: go-build
go-build: test-go-binary

test-go-binary:
@echo "------------------------"
@echo "--> Build test go binary"
@echo "------------------------"
@sh build/generate_go_binary

.PHONY: security-checks
security-checks: trivy-security-check
@docker build . -f build/Dockerfile -t $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)

.PHONY: push
push: docker-push
Expand All @@ -86,4 +79,14 @@ docker-push:
@echo "---------------------------"
@echo "--> Push chaos-ci-lib image"
@echo "---------------------------"
REPONAME="litmuschaos" IMGNAME="chaos-ci-lib" IMGTAG="ci" ./build/push
@docker push $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)


.PHONY: trivy-check
trivy-check:

@echo "------------------------"
@echo "---> Running Trivy Check"
@echo "------------------------"
@./trivy --exit-code 0 --severity HIGH --no-progress $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
@./trivy --exit-code 0 --severity CRITICAL --no-progress $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
8 changes: 4 additions & 4 deletions app/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ metadata:
annotations:
litmuschaos.io/chaos: "true"
labels:
run: nginx
app: nginx
spec:
replicas: 3
selector:
matchLabels:
run: nginx
app: nginx
template:
metadata:
labels:
run: nginx
app: nginx
spec:
containers:
- name: nginx
image: nginx:alpine
image: nginx:latest
ports:
- containerPort: 80
resources:
Expand Down
22 changes: 11 additions & 11 deletions build/generate_go_binary
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ go test -o build/_output/install-litmus -c litmus/install-litmus_test.go -v -cou
go test -o build/_output/uninstall-litmus -c litmus/uninstall-litmus_test.go -v -count=1

#Creating go binary for pod-delete test
go test -o build/_output/pod-delete -c tests/pod-delete_test.go -v -count=1
go test -o build/_output/pod-delete -c experiments/pod-delete_test.go -v -count=1
#Creating go binary for container-kill test
go test -o build/_output/container-kill -c tests/container-kill_test.go -v -count=1
go test -o build/_output/container-kill -c experiments/container-kill_test.go -v -count=1
#Creating go binary for pod-cpu-hog test
go test -o build/_output/pod-cpu-hog -c tests/pod-cpu-hog_test.go -v -count=1
go test -o build/_output/pod-cpu-hog -c experiments/pod-cpu-hog_test.go -v -count=1
#Creating go binary for pod-memory-hog test
go test -o build/_output/pod-memory-hog -c tests/pod-memory-hog_test.go -v -count=1
go test -o build/_output/pod-memory-hog -c experiments/pod-memory-hog_test.go -v -count=1
#Creating go binary for node-cpu-hog test
go test -o build/_output/node-cpu-hog -c tests/node-cpu-hog_test.go -v -count=1
go test -o build/_output/node-cpu-hog -c experiments/node-cpu-hog_test.go -v -count=1
#Creating go binary for node-memory-hog test
go test -o build/_output/node-memory-hog -c tests/node-memory-hog_test.go -v -count=1
go test -o build/_output/node-memory-hog -c experiments/node-memory-hog_test.go -v -count=1
#Creating go binary for pod-network-corruption test
go test -o build/_output/pod-network-corruption -c tests/pod-network-corruption_test.go -v -count=1
go test -o build/_output/pod-network-corruption -c experiments/pod-network-corruption_test.go -v -count=1
#Creating go binary for pod-network-latency test
go test -o build/_output/pod-network-latency -c tests/pod-network-latency_test.go -v -count=1
go test -o build/_output/pod-network-latency -c experiments/pod-network-latency_test.go -v -count=1
#Creating go binary for pod-network-loss test
go test -o build/_output/pod-network-loss -c tests/pod-network-loss_test.go -v -count=1
go test -o build/_output/pod-network-loss -c experiments/pod-network-loss_test.go -v -count=1
#Creating go binary for disk-fill test
go test -o build/_output/disk-fill -c tests/disk-fill_test.go -v -count=1
go test -o build/_output/disk-fill -c experiments/disk-fill_test.go -v -count=1

#Creating go binary for all the tests
cd tests && go test -o ../build/_output/all-experiments -c -v -count=1
cd experiments && go test -o ../build/_output/all-experiments -c -v -count=1
Loading

0 comments on commit c970021

Please sign in to comment.