Skip to content

Commit

Permalink
Merge pull request #54 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 1.10.4 - reduce error alerts, use GitHub Actions
  • Loading branch information
briskt authored Feb 22, 2024
2 parents 608df79 + 6bf049e commit 34420bf
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 64 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test and Publish

on:
push:

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run unit tests
run: docker-compose -f actions-services.yml run --rm app ./run-tests.sh
- name: Run API tests
run: docker-compose -f actions-services.yml run --rm app ./run-tests-api.sh
- name: Check PSR2
run: docker-compose -f actions-services.yml run --rm app ./check-psr2.sh

build-and-publish:
name: Build and Publish
needs: [unit-tests,api-tests,psr2-check]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKER_ORG }}/email-service
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
28 changes: 28 additions & 0 deletions actions-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '2'
services:
db:
image: mariadb:10
environment:
MYSQL_ROOT_PASSWORD: r00tp@ss!
MYSQL_DATABASE: test
MYSQL_USER: email
MYSQL_PASSWORD: email

app:
build: .
depends_on:
- db
working_dir: /data
environment:
APP_ENV: test
MYSQL_HOST: db
MYSQL_DATABASE: test
MYSQL_USER: email
MYSQL_PASSWORD: email
API_ACCESS_KEYS: abc123
APP_NAME: email-service
MAILER_HOST: test
MAILER_USERNAME: test
MAILER_PASSWORD: test
NOTIFICATION_EMAIL: [email protected]
FROM_EMAIL: [email protected]
11 changes: 11 additions & 0 deletions application/common/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@
],
[
'class' => EmailTarget::class,
'except' => [
'yii\web\HttpException:400',
'yii\web\HttpException:401',
'yii\web\HttpException:403',
'yii\web\HttpException:404',
'yii\web\HttpException:409',
'yii\web\HttpException:410',
'yii\web\HttpException:422',
'yii\web\HttpException:429',
'yii\web\HttpException:503',
],
'categories' => ['application'], // stick to messages from this app, not all of Yii's built-in messaging.
'logVars' => [], // no need for default stuff: http://www.yiiframework.com/doc-2.0/yii-log-target.html#$logVars-detail
'levels' => ['error'],
Expand Down
7 changes: 5 additions & 2 deletions application/frontend/controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
use Yii;
use yii\rest\Controller;
use yii\web\NotFoundHttpException;
use yii\web\ServerErrorHttpException;
use yii\web\HttpException;

class SiteController extends Controller
{
public const HttpExceptionServiceUnavailable = 503;

public function behaviors()
{
$behaviors = parent::behaviors();
Expand All @@ -29,7 +31,8 @@ public function actionStatus()
Yii::$app->db->open();
} catch (Exception $e) {
\Yii::error($e->getMessage());
throw new ServerErrorHttpException(
throw new HttpException(
self::HttpExceptionServiceUnavailable,
'Database connection problem.',
$e->getCode()
);
Expand Down
30 changes: 0 additions & 30 deletions codeship-services.yml

This file was deleted.

30 changes: 0 additions & 30 deletions codeship-steps.yml

This file was deleted.

2 changes: 0 additions & 2 deletions dockercfg.encrypted

This file was deleted.

0 comments on commit 34420bf

Please sign in to comment.