Skip to content

Commit

Permalink
Test Github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAxelander committed Sep 4, 2024
1 parent b5371e9 commit f0ddc7a
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 8 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/docker-image-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ jobs:
MARIADB_PASSWORD: openbudgeteer

steps:
- name: Wait for MariaDB to be ready
run: |
docker ps
while ! docker exec -i $(docker ps -q -f ancestor=mariadb:latest) mariadb -u openbudgeteer -p openbudgeteer -e "SHOW DATABASES"; do
echo "Waiting for MariaDB..."
sleep 3
done
- name: Check out repo
uses: actions/checkout@v3

Expand All @@ -37,16 +45,9 @@ jobs:
- name: Build Blazor
run: dotnet build OpenBudgeteer.Blazor --configuration Release --no-restore

- name: Wait for MariaDB to be ready
run: |
docker ps
while ! docker exec -i $(docker ps -q -f ancestor=mariadb:latest) mariadb -u openbudgeteer -p openbudgeteer -e "SHOW DATABASES"; do
echo "Waiting for MariaDB..."
sleep 3
done
- name: Run Core Test Cases
env:
CONNECTION_PROVIDER: mariadb
CONNECTION_SERVER: mariadb
CONNECTION_PORT: 3306
CONNECTION_USER: openbudgeteer
Expand Down
113 changes: 113 additions & 0 deletions .github/workflows/docker-image-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Docker Image (pre-release)

on:
push:
branches: [ github-actions-test ]

env:
DOTNET_VERSION: '8.0.100' # The .NET SDK version to use

jobs:
test:
runs-on: ubuntu-latest
name: Run Test Cases

services:
mariadb:
image: mariadb:latest
ports:
- 3306:3306
env:
MARIADB_DATABASE: openbudgeteer
MARIADB_USER: openbudgeteer
MARIADB_PASSWORD: openbudgeteer

steps:
- name: Wait for MariaDB to be ready
run: |
docker ps
while ! docker exec -i $(docker ps -q -f ancestor=mariadb:latest) mariadb -u openbudgeteer -p openbudgeteer -e "SHOW DATABASES"; do
echo "Waiting for MariaDB..."
sleep 3
done
- name: Check out repo
uses: actions/checkout@v3

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Install Blazor dependencies
run: dotnet restore OpenBudgeteer.Blazor

- name: Build Blazor
run: dotnet build OpenBudgeteer.Blazor --configuration Release --no-restore

- name: Run Core Test Cases
env:
CONNECTION_PROVIDER: mariadb
CONNECTION_SERVER: mariadb
CONNECTION_PORT: 3306
CONNECTION_USER: openbudgeteer
CONNECTION_PASSWORD: openbudgeteer
CONNECTION_DATABASE: openbudgeteer
run: dotnet test OpenBudgeteer.Core.Test
deploy-docker-app:
runs-on: ubuntu-latest
name: Build and Push Docker Image (App)
needs: test
if: success()
steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: axelander/openbudgeteer:pre-release
platforms: linux/arm64,linux/amd64
deploy-docker-api:
runs-on: ubuntu-latest
name: Build and Push Docker Image (API)
needs: test
if: success()
steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: axelander/openbudgeteer-api:pre-release
file: API.Dockerfile
platforms: linux/arm64,linux/amd64
3 changes: 3 additions & 0 deletions OpenBudgeteer.Core.Data/DbContextOptionsFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -69,6 +70,8 @@ private static void SetupMariaDbConnection(DbContextOptionsBuilder optionsBuilde
Password = configuration.GetValue(ConfigurationKeyConstants.CONNECTION_PASSWORD, userName),
ConnectionProtocol = MySqlConnectionProtocol.Tcp
};

Console.WriteLine(builder.ConnectionString);

var serverVersion = ServerVersion.AutoDetect(builder.ConnectionString);
optionsBuilder.UseMySql(
Expand Down

0 comments on commit f0ddc7a

Please sign in to comment.