Skip to content

Commit

Permalink
setup automated tests on build.
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed Jul 6, 2023
1 parent 0d1f591 commit caaeed1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ jobs:
echo "Version $versionHeader is still incorrect after waiting"
exit 1
- uses: actions/checkout@v3
- name: Install dependencies
run: dotnet restore
- name: Build dotnet
run: dotnet build
- name: Ensure browsers are installed
run: pwsh /backend/Testing/bin/Debug/net7.0/playwright.ps1 install --with-deps
- name: Integration Test
env:
TEST_SERVER_HOSTNAME: staging.languagedepot.org
Expand Down
46 changes: 36 additions & 10 deletions .github/workflows/lexbox-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,49 @@ jobs:
outputs:
version: ${{ steps.setVersion.outputs.VERSION }}

# postgres db is for automated tests
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_PASSWORD: 972b722e63f549938d07bd8c4ee5086c
POSTGRES_DB: lexbox-tests
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5433:5432

env:
# https://docs.docker.com/develop/develop-images/build_enhancements/
DOCKER_BUILDKIT: 1

steps:
-
uses: actions/checkout@v3
-
name: Set Version
- uses: actions/checkout@v3
- name: Set Version
id: setVersion
# set version to date in vYYYY-MM-DD format
run: |
shortSha=$(echo ${{ github.sha }} | cut -c1-8)
echo "VERSION=v$(date --rfc-3339=date):$shortSha" >> ${GITHUB_ENV}
echo "VERSION=v$(date --rfc-3339=date):$shortSha" >> ${GITHUB_OUTPUT}
-
name: Docker meta
- name: Dotnet build
run: dotnet build
- name: Unit tests
run: dotnet test --logger xunit --results-directory ./testresults --filter "Category!=Integration"
- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: Integration Test
files: ./testresults/*.xml

- name: Docker meta
id: meta
if: ${{ !env.ACT }}
uses: docker/metadata-action@v4
Expand All @@ -59,16 +85,16 @@ jobs:
type=ref,event=pr
type=raw,enable=${{ env.PROD_RELEASE }},value=latest
type=raw,enable=${{ env.PROD_RELEASE }},value=${{ env.VERSION }}
-
name: ghcr.io login
- name: ghcr.io login
uses: docker/login-action@v2
if: ${{ !env.ACT }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
uses: docker/build-push-action@v4

- uses: docker/build-push-action@v4
with:
context: backend
build-args: |
Expand Down
1 change: 1 addition & 0 deletions backend/Testing/Browser/ManagerPageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Testing.Browser;

[Trait("Category", "Integration")]
public class ManagerPageTest: PageTest
{
private string _host = "staging.languagedepot.org";
Expand Down
1 change: 1 addition & 0 deletions backend/Testing/Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="XunitXml.TestLogger" Version="3.0.78" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit caaeed1

Please sign in to comment.