Skip to content

Commit

Permalink
test job: optional .env and separate restore, build, and test steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Dalet committed Mar 8, 2023
1 parent 9ac48f7 commit f0164cd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
- name: Create .env file
run: cp example.env .env
- name: Spin up containers
run: docker compose up -d
- name: Run Tests on In Memory Database
run: ApplicationContext__UseInMemoryDb=true dotnet test LeaderboardBackend.Test
- name: Run Tests on Test Postgres Database
run: ApplicationContext__UseInMemoryDb=false dotnet test LeaderboardBackend.Test
- name: Restore NuGet packages
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Run tests
run: dotnet test LeaderboardBackend.Test --no-restore
2 changes: 1 addition & 1 deletion LeaderboardBackend.Jobs/LeaderboardBackend.Jobs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<None Include="../.env">
<None Include="../.env" Condition="Exists('../.env')">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion LeaderboardBackend.Test/LeaderboardBackend.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

<ItemGroup>
<None Include="../.env">
<None Include="../.env" Condition="Exists('../.env')">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion LeaderboardBackend/LeaderboardBackend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</ItemGroup>

<ItemGroup>
<None Include="../.env">
<None Include="../.env" Condition="Exists('../.env')">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down

0 comments on commit f0164cd

Please sign in to comment.