Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create docker-image and run tests inside the container - github workflow #92

Merged
merged 51 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
292e5e0
Create docker-image.yml (github-actions)
Taniya-Das Jul 10, 2023
029ed55
Added mysql_server and apiserver run
Taniya-Das Jul 10, 2023
019da19
Added creation of mysql-network
Taniya-Das Jul 10, 2023
b8da9f8
Update docker-image.yml
Taniya-Das Jul 10, 2023
3f03bf0
Update docker-image.yml
Taniya-Das Jul 10, 2023
75069c7
Update docker-image.yml
Taniya-Das Jul 10, 2023
2baeffa
Creating docker image and performing tests nside the container
Taniya-Das Jul 10, 2023
181f484
move to single job
Taniya-Das Jul 10, 2023
76f8428
separating docker built and pytests
Taniya-Das Jul 11, 2023
64d4aee
testing only docker image built
Taniya-Das Jul 11, 2023
6b3fd63
Only built docker image
Taniya-Das Jul 11, 2023
e7c90e0
Only built docker image
Taniya-Das Jul 11, 2023
d770299
built docker image and push to repository
Taniya-Das Jul 11, 2023
5b880f0
built docker image and push to repository
Taniya-Das Jul 11, 2023
10cd97d
push image to repository
Taniya-Das Jul 11, 2023
8d72bf6
push image to repository
Taniya-Das Jul 11, 2023
8298b46
push image to repository
Taniya-Das Jul 11, 2023
ba2483e
push image to repository
Taniya-Das Jul 11, 2023
7e967f6
update of push image to repository
Taniya-Das Jul 11, 2023
7597bb5
update of push image to repository
Taniya-Das Jul 11, 2023
268cb5e
update running test in container - test file
Taniya-Das Jul 11, 2023
448b4c5
revert to only creating docker image
Taniya-Das Jul 11, 2023
1b90cdc
giving write access
Taniya-Das Jul 11, 2023
85e4be5
Test inside container dummy file
Taniya-Das Jul 11, 2023
e074627
Test inside container dummy file
Taniya-Das Jul 11, 2023
a9579e2
Test inside container
Taniya-Das Jul 11, 2023
549f53e
adding root user
Taniya-Das Jul 11, 2023
04afdbc
remove pytest on container
Taniya-Das Jul 11, 2023
642dbe0
building docker and running in the same job env
Taniya-Das Jul 12, 2023
1f555d5
building docker and running in the same job env
Taniya-Das Jul 12, 2023
ccf2bf5
building docker and running in the same job env
Taniya-Das Jul 12, 2023
974cba9
building docker and running in the same job env
Taniya-Das Jul 12, 2023
8447b80
building docker and running in the same job env
Taniya-Das Jul 12, 2023
a81f189
building docker and running in the same job env
Taniya-Das Jul 12, 2023
e12d059
corrections - building docker and running in the same job env
Taniya-Das Jul 12, 2023
9b224e3
corrections - building docker and running in the same job env
Taniya-Das Jul 12, 2023
1de1f6b
corrections - building docker and running in the same job env
Taniya-Das Jul 12, 2023
62c8cd1
corrections - building docker and running in the same job env
Taniya-Das Jul 12, 2023
b7ffc74
added py-modules in pyproject.toml, corrected docker-image.yml
Taniya-Das Jul 12, 2023
36f9bd6
corrected docker-image.yml
Taniya-Das Jul 12, 2023
45e3eac
verbose pytest tests
Taniya-Das Jul 12, 2023
d820a84
print response.json() if tests fail
Taniya-Das Jul 12, 2023
1654752
use test/.env inside docker container
Taniya-Das Jul 12, 2023
8fd304c
use test/.env inside docker container
Taniya-Das Jul 12, 2023
9d05d69
added comments and manual trigger
Taniya-Das Jul 12, 2023
a31d9ac
corrected workflow name
Taniya-Das Jul 12, 2023
1ab90b3
correct description, add more triggers
Taniya-Das Jul 12, 2023
a400b5c
added trigger for change in Dockerfile
Taniya-Das Jul 12, 2023
2c8eb2e
typo corrected
Taniya-Das Jul 12, 2023
8105f5f
description corrected, renamed file
Taniya-Das Jul 13, 2023
b066bf7
description corrected
Taniya-Das Jul 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/dockerized-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Built docker image and run tests

# This workflow will built docker image and run tests inside the container.
# This workflow is only executed when a push is made in "develop", or
# if there is a change in pyproject.toml dependencies, or in Dockerfile, or in docker workflow.

on:
push:
paths:
- '.github/workflows/docker-image.yml'
- 'pyproject.toml'
- 'Dockerfile'
branches:
- "develop"

# allows to manually start a workflow run from the GitHub UI or using the GitHub API.
workflow_dispatch:

jobs:
built:
runs-on: ubuntu-latest
permissions:
packages: write

steps:
- uses: actions/checkout@v2
- name: Build the docker image
run: docker build --tag ai4eu_server_demo:latest -f Dockerfile .

- name: Run docker container and pytest tests
run: |
docker run -e KEYCLOAK_CLIENT_SECRET="mocked_secret" --entrypoint "" ai4eu_server_demo sh -c "pip install \".[dev]\" && pytest tests -s"








5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ dev = [
"starlette==0.27.0"
]

[tool.setuptools]
py-modules = []

[tool.black]
line-length = 100

Expand All @@ -57,3 +60,5 @@ env_files = [
"src/tests/.env"
]



6 changes: 3 additions & 3 deletions src/tests/routers/test_router_case_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock):
}

response = client.post("/case_studies/v0", json=body, headers={"Authorization": "Fake token"})
assert response.status_code == 200
assert response.status_code == 200, response.json()

response = client.get("/case_studies/v0/1")
assert response.status_code == 200
assert response.status_code == 200, response.json()

response_json = response.json()
assert response_json["identifier"] == 1
Expand All @@ -48,4 +48,4 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock):
"technical category 2",
}
response = client.delete("/case_studies/v0/1", headers={"Authorization": "Fake token"})
assert response.status_code == 200
assert response.status_code == 200, response.json()