-
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactor tests to use env vars and push dated tags (#15)
- Loading branch information
Showing
24 changed files
with
250 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
|
||
BUILD_PUSH=1 python scripts/process_all.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -x | ||
|
||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
use_tag="tiangolo/uvicorn-gunicorn:$NAME" | ||
use_dated_tag="${use_tag}-$(date -I)" | ||
|
||
docker-compose -f docker-compose.build.yml build | ||
docker build -t "$use_tag" "$BUILD_PATH" | ||
|
||
docker-compose -f docker-compose.build.yml push | ||
docker tag "$use_tag" "$use_dated_tag" | ||
|
||
docker push "$use_tag" | ||
docker push "$use_dated_tag" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
set -e | ||
set -x | ||
|
||
bash scripts/build-push.sh | ||
bash scripts/build-push-all.sh | ||
|
||
bash scripts/trigger-children.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
environments = [ | ||
{ | ||
"NAME": "latest", | ||
"BUILD_PATH": "python3.7", | ||
"TEST_STR1": "Hello world! From Uvicorn with Gunicorn. Using Python 3.7", | ||
"TEST_STR2": "Test app. From Uvicorn with Gunicorn. Using Python 3.7", | ||
}, | ||
{ | ||
"NAME": "python3.7", | ||
"BUILD_PATH": "python3.7", | ||
"TEST_STR1": "Hello world! From Uvicorn with Gunicorn. Using Python 3.7", | ||
"TEST_STR2": "Test app. From Uvicorn with Gunicorn. Using Python 3.7", | ||
}, | ||
{ | ||
"NAME": "python3.6", | ||
"BUILD_PATH": "python3.6", | ||
"TEST_STR1": "Hello world! From Uvicorn with Gunicorn. Using Python 3.6", | ||
"TEST_STR2": "Test app. From Uvicorn with Gunicorn. Using Python 3.6", | ||
}, | ||
{ | ||
"NAME": "python3.7-alpine3.8", | ||
"BUILD_PATH": "python3.7-alpine3.8", | ||
"TEST_STR1": "Hello world! From Uvicorn with Gunicorn in Alpine. Using Python 3.7", | ||
"TEST_STR2": "Test app. From Uvicorn with Gunicorn. Using Python 3.7", | ||
}, | ||
{ | ||
"NAME": "python3.6-alpine3.8", | ||
"BUILD_PATH": "python3.6-alpine3.8", | ||
"TEST_STR1": "Hello world! From Uvicorn with Gunicorn in Alpine. Using Python 3.6", | ||
"TEST_STR2": "Test app. From Uvicorn with Gunicorn. Using Python 3.6", | ||
}, | ||
] | ||
|
||
start_with = os.environ.get("START_WITH") | ||
build_push = os.environ.get("BUILD_PUSH") | ||
|
||
|
||
def process_tag(*, env: dict): | ||
use_env = {**os.environ, **env} | ||
script = "scripts/test.sh" | ||
if build_push: | ||
script = "scripts/build-push.sh" | ||
return_code = subprocess.call(["bash", script], env=use_env) | ||
if return_code != 0: | ||
sys.exit(return_code) | ||
|
||
|
||
def print_version_envs(): | ||
env_lines = [] | ||
for env in environments: | ||
env_vars = [] | ||
for key, value in env.items(): | ||
env_vars.append(f"{key}='{value}'") | ||
env_lines.append(" ".join(env_vars)) | ||
for line in env_lines: | ||
print(line) | ||
|
||
|
||
def main(): | ||
start_at = 0 | ||
if start_with: | ||
start_at = [ | ||
i for i, env in enumerate((environments)) if env["NAME"] == start_with | ||
][0] | ||
for i, env in enumerate(environments[start_at:]): | ||
print(f"Processing tag: {env['NAME']}") | ||
process_tag(env=env) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) > 1: | ||
print_version_envs() | ||
else: | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
python scripts/process_all.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
docker-compose -f docker-compose.build.yml build | ||
use_tag="tiangolo/uvicorn-gunicorn:$NAME" | ||
|
||
docker build -t "$use_tag" "$BUILD_PATH" | ||
pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.