Skip to content

Commit

Permalink
Fail tests when code coverage is reduced. Start documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
DvDty committed Jan 28, 2024
1 parent 93e0a0b commit 6a0ca35
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main-branch-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ jobs:
id: coverage
working-directory: ./application
run: |
XDEBUG_MODE=coverage php artisan test --coverage | grep -oP 'Total: \K\d+\.\d+' > code_coverage.txt
current_coverage = $(cat code_coverage.txt)
floor = $(php -r "echo floor($current_coverage) - 1;")
XDEBUG_MODE=coverage php artisan test --coverage --min=$floor | grep -oP 'Total: \K\d+\.\d+' > code_coverage.txt
- name: Commit code_coverage.txt
id: auto-commit-action
Expand Down
36 changes: 24 additions & 12 deletions .github/workflows/pull-requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:

linter:
runs-on: ubuntu-latest
needs: [ security ]
permissions:
contents: write
steps:
Expand Down Expand Up @@ -64,6 +65,7 @@ jobs:

tests:
runs-on: ubuntu-latest
needs: [ security ]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -100,6 +102,7 @@ jobs:

static-analysis:
runs-on: ubuntu-latest
needs: [ security ]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -141,6 +144,7 @@ jobs:

database:
runs-on: ubuntu-latest
needs: [ security ]
services:
mysql-service:
image: mysql:8
Expand Down Expand Up @@ -204,7 +208,7 @@ jobs:
defaults:
run:
working-directory: ./application
needs: [ security ]
needs: [ security, linter, tests, static-analysis, SonarCloud, database]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -232,15 +236,23 @@ jobs:
vuln-type: 'os,library'
severity: 'CRITICAL'

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Deploy to minikube
uses: medyagh/setup-minikube@master

- name: Push
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:application"
push: true
tags: dvdty/branch-deploy-application:${{ github.head_ref || github.ref_name }}
- name: Deploy to minikube
working-directory: ./application
run:
kubectl apply -f k8s/

- name: Wait for Deployment
run: |
kubectl rollout status deployment branch-deploy-application
- name: Expose Service
run: |
minikube service list
curl $(minikube service branch-deploy-application-service --url)
- name: Stop Minikube
run: |
minikube stop
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
# Branch deploy

This repository holds two code bases:
- Application, developed by a software team
- Control plane, that allows easy deployments of the application

## Application

Main focus is to provide the development team strong CI:
- Secure
- Flexible
- Highly automated
- Fast

| | Push to main | Push on other branches | Pull requests |
|--------------------------------------------------------------------------------------------------------------|--------------|------------------------|---------------|
| [Gitleaks](https://github.com/DvDty/branch-deploy/blob/main/.github/workflows/main-branch-build.yaml#L8-L26) ||||
| [Code linter](https://github.com/DvDty/branch-deploy/blob/main/.github/workflows/main-branch-build.yaml#L28-L64) | | ||
| Build docker image ||||
| Push image to Docker Hub ||| |
| Scan image before pushing || ||
| Unit tests || ||
| Feature tests || ||
| Static code analysis || ||
| Sonar Cloud analysis || ||
| Database migrations || ||
| Check code coverage || ||
| Store code coverage report || | |
| Deploy to minikube || ||


### Gitleaks
Example with leaked api key:

![img.png](img.png)

Notification in slack:

![img_1.png](img_1.png)

### Code linter
![img_2.png](img_2.png)

![img_3.png](img_3.png)

![img_3.png](img_3.png)

![img_4.png](img_4.png)
Binary file added img_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6a0ca35

Please sign in to comment.