Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MH321Productions committed Mar 6, 2024
1 parent a3034f2 commit 06120da
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
91 changes: 91 additions & 0 deletions .ci/integrationTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/python3

import sys
import subprocess

POSTGRES_PARTS = [
"docker",
"compose",
"-f",
"./.ci/docker-compose.test.yml",
"-f",
"./.ci/docker-compose.test.postgres.yml"
]

SQLSERVER_PARTS = [
"docker",
"compose",
"-f",
"./.ci/docker-compose.test.yml",
"-f",
"./.ci/docker-compose.test.sqlserver.yml"
]

RESTORE_PARTS = [
"dotnet",
"restore",
"Backbone.sln"
]

BUILD_PARTS = [
"dotnet",
"build",
"--no-restore",
"Backbone.sln"
]

TEST_PARTS = [
"dotnet",
"test",
"--no-restore",
"--no-build",
"--filter",
"Category=Integration&TestCategory!~ignore",
"--logger",
"GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true",
"Backbone.sln"
]

def runCmd(args: list[str]) -> int:
return subprocess.run(args).returncode

def docker_compose_postgres(args: list[str]) -> int:
parts = POSTGRES_PARTS.copy()

for a in args:
parts.append(a)

return runCmd(parts)

def docker_compose_sqlserver(args: list[str]) -> int:
parts = SQLSERVER_PARTS.copy()

for a in args:
parts.append(a)

return runCmd(parts)

def build_and_run_tests() -> int:
ret = runCmd(RESTORE_PARTS)

if ret != 0:
ret = runCmd(BUILD_PARTS)
if ret != 0:
ret = runCmd(TEST_PARTS)

return ret


if __name__ == "__main__":
ret = 1

if len(sys.argv) < 2:
print("No arguments", file=sys.stderr)
elif sys.argv[1] == "postgres":
ret = docker_compose_postgres(sys.argv[2:])
elif sys.argv[1] == "sqlserver":
ret = docker_compose_sqlserver(sys.argv[2:])
elif sys.argv[1] == "build":
ret = build_and_run_tests()

exit(ret)
5 changes: 4 additions & 1 deletion .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: npm install --prefix ./.ci

- name: Clear Docker Container
run: ./.ci/integrationTest.sh postgres down
run: python .ci/integrationTest.py postgres down

- name: Build Docker
uses: docker/build-push-action@v5
Expand All @@ -53,6 +53,9 @@ jobs:
push: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Run Tests
run: python .ci/integrationTest.py build

- # Temp fix
# https://github.com/docker/build-push-action/issues/252
Expand Down

0 comments on commit 06120da

Please sign in to comment.