Skip to content

chore(deps): bump actions/checkout from 3 to 4 #229

chore(deps): bump actions/checkout from 3 to 4

chore(deps): bump actions/checkout from 3 to 4 #229

Workflow file for this run

name: Tests 🛠️
on:
pull_request:
push:
branches:
- main
paths:
- '**/*.go'
- '**/*.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
applications-test-units:
name: "GoLang test units"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goVersion: [ '1.18', '1.19', '1.20' ]
env:
REDIS_HOST: '127.0.0.1'
REDIS_PORT: '6379'
REDIS_PASSWORD: ''
RABBITMQ_HOST: '127.0.0.1'
RABBITMQ_PORT: '5672'
RABBITMQ_USER: 'rabbitmq'
RABBITMQ_PASSWORD: 'rabbitmq'
POSTGRES_HOST: '127.0.0.1'
POSTGRES_PORT: '5432'
POSTGRES_USER: 'postgres'
POSTGRES_PASSWORD: 'postgres'
POSTGRES_DB: 'postgres'
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: 6
- name: Setup RabbitMQ
uses: getong/[email protected]
with:
rabbitmq version: '3.8.2-management-alpine'
host port: 5672
rabbitmq user: 'rabbitmq'
rabbitmq password: 'rabbitmq'
- name: Setup PostgreSQL
uses: harmon758/postgresql-action@v1
with:
postgresql version: '11'
postgresql db: postgres
postgresql user: postgres
postgresql password: postgres
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goVersion }}
check-latest: true
- name: golangci-lint
uses: golangci/[email protected]
with:
version: latest
- name: Run Unit tests
run: |
go test ./... -coverprofile coverage.out -covermode count
go tool cover -func coverage.out
- name: Quality Gate - Test coverage shall be above threshold
env:
TESTCOVERAGE_THRESHOLD: 90
run: |
echo "Quality Gate: checking test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "OK"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Failed"
exit 1
fi
- uses: codecov/codecov-action@v3
- name: Run Go Build
run: |
go build -o /tmp/applications-test-units
integration-tests:
name: "Integration tests"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goVersion: [ '1.18', '1.19', '1.20' ]
env:
REDIS_HOST: '127.0.0.1'
REDIS_PORT: '6379'
REDIS_PASSWORD: ''
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: 6
- name: Install k6
run: |
curl https://github.com/grafana/k6/releases/download/v0.45.0/k6-v0.45.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1
- name: Run Integration tests
run: |
go run main.go serve --config tests/integrations/webhooked_config.integration.yaml >/dev/null 2>&1 &
until $(curl --output /dev/null --silent --head --fail http://localhost:8080/metrics); do
printf '.'
sleep 1
done
./k6 run tests/integrations/scenarios.js