Skip to content

Check from_name in smtp sent emails #801

Check from_name in smtp sent emails

Check from_name in smtp sent emails #801

Workflow file for this run

name: Go
on:
push:
branches: [dev, main]
pull_request:
branches: [dev, main]
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: true
- name: Install dependencies
run: |
go mod download
go get github.com/DATA-DOG/go-sqlmock
- name: Run unit tests and generate coverage
run: |
# Create a test .env file
echo "PASETO_PRIVATE_KEY=UayDa4OMDpm3CvIT+iSC39iDyPlsui0pNQYDEZ1pbo1LsIrO4p/aVuCBWz6LiYvzj9pc+gn0gLwRd0CoHV+nxw==" >> .env.test
echo "PASETO_PUBLIC_KEY=S7CKzuKf2lbggVs+i4mL84/aXPoJ9IC8EXdAqB1fp8c=" >> .env.test
echo "ROOT_EMAIL=admin@example.com" >> .env.test
# Run unit tests (exclude integration tests)
go test -race -coverprofile=coverage-unit.txt -covermode=atomic $(go list ./... | grep -v '/tests/integration') -v
# Copy to repo root for codecov action
cp coverage-unit.txt ../
- name: Upload unit test coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Notifuse/notifuse
files: coverage-unit.txt
fail_ci_if_error: false
verbose: true
name: codecov-unit-tests
flags: unit
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: notifuse_test
POSTGRES_PASSWORD: test_password
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5433:5432
mailhog:
image: mailhog/mailhog:latest
env:
MH_STORAGE: memory
options: >-
--health-cmd "wget --quiet --tries=1 --spider http://localhost:8025/ || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 3
ports:
- 1025:1025
- 8025:8025
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: true
- name: Install dependencies
run: |
go mod download
go get github.com/DATA-DOG/go-sqlmock
- name: Run integration tests and generate coverage
env:
# Enable integration tests
INTEGRATION_TESTS: true
# Test database configuration
TEST_DB_HOST: localhost
TEST_DB_PORT: 5433
TEST_DB_USER: notifuse_test
TEST_DB_PASSWORD: test_password
ENVIRONMENT: test
# Set main database config to use test database
DB_HOST: localhost
DB_PORT: 5433
DB_USER: notifuse_test
DB_PASSWORD: test_password
DB_NAME: notifuse_test_integration
DB_PREFIX: notifuse_test
DB_SSLMODE: disable
run: |
# Create a test .env file for integration tests
echo "PASETO_PRIVATE_KEY=UayDa4OMDpm3CvIT+iSC39iDyPlsui0pNQYDEZ1pbo1LsIrO4p/aVuCBWz6LiYvzj9pc+gn0gLwRd0CoHV+nxw==" >> .env.test
echo "PASETO_PUBLIC_KEY=S7CKzuKf2lbggVs+i4mL84/aXPoJ9IC8EXdAqB1fp8c=" >> .env.test
echo "ROOT_EMAIL=admin@example.com" >> .env.test
echo "DB_HOST=localhost" >> .env.test
echo "DB_PORT=5433" >> .env.test
echo "DB_USER=notifuse_test" >> .env.test
echo "DB_PASSWORD=test_password" >> .env.test
echo "DB_NAME=notifuse_test_integration" >> .env.test
echo "DB_PREFIX=notifuse_test" >> .env.test
echo "DB_SSLMODE=disable" >> .env.test
# Wait for services to be ready
echo "Waiting for PostgreSQL to be ready..."
sleep 10
# Wait for Mailhog to be ready
echo "Waiting for Mailhog to be ready..."
for i in {1..30}; do
if curl -f http://localhost:8025/ > /dev/null 2>&1; then
echo "Mailhog is ready!"
break
fi
echo "Waiting for Mailhog... ($i/30)"
sleep 2
done
# Run integration tests only with more timeout
go test -race -coverprofile=coverage-integration.txt -covermode=atomic -timeout=15m ./tests/integration/... -v
# Copy to repo root for codecov action
cp coverage-integration.txt ../
# - name: Upload integration test coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# slug: Notifuse/notifuse
# file: coverage-integration.txt
# fail_ci_if_error: true
# verbose: true
# name: codecov-integration-tests
# flags: integration