Changes made to the ci file for production check

This commit is contained in:
Ahmed 2023-10-29 17:47:14 +11:00
commit 08f4900bfb
2 changed files with 3 additions and 87 deletions

View File

@ -114,7 +114,6 @@ jobs:
- name: Bare Metal ${{ matrix.script.name }}
run: sh tests/test_bare.sh ${{ matrix.script.args }}
production-check:
name: "Production check"
runs-on: ubuntu-latest
@ -127,9 +126,8 @@ jobs:
cache: pip
cache-dependency-path: |
requirements.txt
{{cookiecutter.project_slug}}/requirements/base.txt
{{cookiecutter.project_slug}}/requirements/local.txt
{{cookiecutter.project_slug}}/requirements/prod.txt
- name: Install dependencies
run: pip install -r requirements.txt
run: pip install -r {{cookiecutter.project_slug}}/requirements/prod.txt
- name: Production check
run: sh tests/test_production.sh
run: python manage.py check --deploy

View File

@ -1,82 +0,0 @@
import os
import subprocess
def test_production_build():
"""Test production build."""
# Run production build
subprocess.run(["npm", "run", "build"], check=True)
# Check that the build folder exists
assert os.path.isdir("build")
# Check that the build folder contains the index.html file
assert os.path.isfile("build/index.html")
# Check that the build folder contains the static folder
assert os.path.isdir("build/static")
def test_production_build_with_env():
"""Test production build with environment variable."""
# Set environment variable
os.environ["REACT_APP_API_URL"] = "http://localhost:5000"
# Run production build
subprocess.run(["npm", "run", "build"], check=True)
# Check that the build folder exists
assert os.path.isdir("build")
# Check that the build folder contains the index.html file
assert os.path.isfile("build/index.html")
# Check that the build folder contains the static folder
assert os.path.isdir("build/static")
# Unset environment variable
del os.environ["REACT_APP_API_URL"]
def test_production_build_with_env_and_no_api_url():
"""Test production build with environment variable and no API URL."""
# Set environment variable
os.environ["REACT_APP_API_URL"] = ""
# Run production build
subprocess.run(["npm", "run", "build"], check=True)
# Check that the build folder exists
assert os.path.isdir("build")
# Check that the build folder contains the index.html file
assert os.path.isfile("build/index.html")
# Check that the build folder contains the static folder
assert os.path.isdir("build/static")
# Unset environment variable
del os.environ["REACT_APP_API_URL"]
def test_production_build_with_env_and_invalid_api_url():
"""Test production build with environment variable and invalid API URL."""
# Set environment variable
os.environ["REACT_APP_API_URL"] = "invalid"
# Run production build
subprocess.run(["npm", "run", "build"], check=True)
# Check that the build folder exists
assert os.path.isdir("build")
# Check that the build folder contains the index.html file
assert os.path.isfile("build/index.html")
# Check that the build folder contains the static folder
assert os.path.isdir("build/static")
# Unset environment variable
del os.environ["REACT_APP_API_URL"]