Merge pull request #11 from LBPUnion/actions

Github Actions
This commit is contained in:
jvyden 2021-10-17 17:06:52 -04:00 committed by GitHub
commit d089cdc60a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 93 additions and 8 deletions

85
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,85 @@
on: [push, pull_request]
name: Continuous Integration
# Inspired by osu! lazer's CI
# https://github.com/ppy/osu/blob/e12249f1270a22cf5811a8bb7a9ee44f2c0250db/.github/workflows/ci.yml
jobs:
test:
name: Build & Test
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ${{matrix.os.fullName}}
strategy:
fail-fast: false
matrix:
os:
- { prettyName: Windows, fullName: windows-latest, database: false }
- { prettyName: macOS, fullName: macos-latest, database: true }
- { prettyName: Linux, fullName: ubuntu-latest, database: true }
timeout-minutes: 10
env:
DB_DATABASE: lighthouse
DB_USER: root
DB_PASSWORD: lighthouse
steps:
- name: Cancel previous runs of this workflow
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2
- name: Install .NET 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
include-prerelease: true
- name: Install .NET 6.0 Preview
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"
include-prerelease: true
- name: Compile
run: dotnet build -c Debug
- name: Start MySQL
if: ${{ matrix.os.database }}
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: '8.0'
root-password: ${{ env.DB_PASSWORD }}
- name: Run database migrations
if: ${{ matrix.os.database }}
run: |
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -h127.0.0.1
mysql --batch -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -h127.0.0.1 ${{ env.DB_DATABASE }} < <(cat DatabaseMigrations/*.sql)
- name: Test
continue-on-error: true
run: dotnet test --logger "trx;LogFileName=${{github.workspace}}/TestResults-${{matrix.os.prettyName}}.trx"
# Attempt to upload results even if test fails.
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#always
- name: Upload Test Results
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: lighthouse-test-results-${{matrix.os.prettyName}}
path: ${{github.workspace}}/TestResults-${{matrix.os.prettyName}}.trx
- name: Process Test Results
if: ${{ always() }}
uses: im-open/process-dotnet-test-results@v2.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check Test Results
if: steps.process-trx.outputs.test-outcome == 'Failed'
run: |
echo "There were test failures."
exit 1

View file

@ -3,6 +3,7 @@
<component name="UserContentModel"> <component name="UserContentModel">
<attachedFolders /> <attachedFolders />
<explicitIncludes> <explicitIncludes>
<Path>.github</Path>
<Path>.gitignore</Path> <Path>.gitignore</Path>
<Path>.idea</Path> <Path>.idea</Path>
<Path>DatabaseMigrations</Path> <Path>DatabaseMigrations</Path>

View file

@ -11,13 +11,13 @@ namespace ProjectLighthouse {
Console.WriteLine("Welcome to Project Lighthouse!"); Console.WriteLine("Welcome to Project Lighthouse!");
Console.WriteLine(ServerSettings.DbConnected ? "Connected to the database." : "Database unavailable. Starting in stateless mode."); Console.WriteLine(ServerSettings.DbConnected ? "Connected to the database." : "Database unavailable. Starting in stateless mode.");
IHostBuilder builder = Host.CreateDefaultBuilder(args); CreateHostBuilder(args).Build().Run();
builder.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseStartup<Startup>();
});
builder.Build().Run();
} }
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseStartup<Startup>();
});
} }
} }

View file

@ -10,7 +10,6 @@
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.11" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.11" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.11" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.2" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>