Skip to content

feat: add get /expenses #6

feat: add get /expenses

feat: add get /expenses #6

Workflow file for this run

name: CI and CD for Dev
on:
push:
branches: [ main ]
env:
PROJECT_NAME: workshop-summer-group-2-b2
jobs:
unit-test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21.9
- name: Run Unit Test
run: go test -v ./... -coverprofile=coverage.out
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: ./coverage.out
integration-test:
name: Integration Test
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Run Integration Test
run: make test-it-docker
sonarqube:
name: SonarQube Scan
runs-on: ubuntu-latest
needs: [unit-test, integration-test]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
name: Download coverage file
with:
name: coverage
path: ./
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
with:
projectBaseDir: .
args: >
-Dsonar.go.coverage.reportPaths=coverage.out
-Dsonar.language=go
-Dsonar.sources=.
-Dsonar.tests=.
-Dsonar.test.inclusions=**/*_test.go
-Dsonar.projectKey=${{ env.PROJECT_NAME }}
- uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
build-and-push-docker-image:
name: Build Image and Push to Registry
runs-on: ubuntu-latest
# Fixme: Add needs for sonarqube when it's ready
needs: [ sonarqube ]
steps:
- uses: actions/checkout@v4
- name: Setup SHA
run: echo "GITHUB_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
- name: Login ghcr.io
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/kkgo-software-engineering/workshop-summer-group-2-b2:${{ env.GITHUB_SHA }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
gitops-dev-versioning:
runs-on: ubuntu-latest
needs: build-and-push-docker-image
name: GitOps Dev Versioning
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: config git
run: |
git --version
git config user.name "robot"
git config user.email "[email protected]"
- name: change image tag to deploy dev
if: ${{ github.ref == 'refs/heads/main' }}
run: |
sed -i -E "s/ghcr.io\/kkgo-software-engineering\/workshop-summer-group-2-b2.*$/ghcr.io\/kkgo-software-engineering\/workshop-summer-group-2-b2:${GITHUB_SHA}/" infra/gitops/dev/deployment.yaml
git add infra/gitops/dev/deployment.yaml
git commit -m "[skip actions] 🤖 change dev docker image version to ${GITHUB_SHA}"
git pull --rebase
git push