Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/spec-driven-development.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions SPECS/Spec_DockerfileDatabase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Feature Spec: File Database for Dockerfiles, testing results, etc.

## Goal
- This application provides the ability to store Dockerfiles (or any other kind of text-based file, such as JSONs, YAML, etc) into a database. The database is organized by time and date for easy record keeping.
- By having users able to upload files to the database, incremental steps in testing in a QA environment can be taken into account, seeing every individual iteration of a program being tested.
- E.g. If a new version of the project is created, a Dockerfile can be generated and stored for any other user to generate their own Docker Image from. Notes about a specific build can also be uploaded, making it easier for testers to take note of when bugs happen for what build, and it becomes timestamped.
- Results can be retrieved and viewed from the database as well, keeping a clean, sqlite3 based record of development and testing results/notes/data of any type.

## Scope
- In: A Dockerfile, or any text based file works.
- Out: An entry of the file (organized by timestamp) in a locally created database named `dockerfiles.db`.

## Requirements
- Database must be able to store files given by a user.
- Database must be able to retrieve files given by a user.
- Database must be able to retrieve files by date.

## Acceptance Criteria
- [ ] Database stores a Dockerfile entry into `dockerfiles.db`
- [ ] Dockerfile entries must include a name for the file, date, time, and contents of the file.
- [ ] Database retrieves all Dockerfiles.
- [ ] Database can query for Dockerfiles given on a specific date and retrieve files.
- [ ] Database can query for Dockerfiles given on a specific date and by name.
- [ ] Database can view all dates Dockerfiles have been stored on.
- [ ] Database fails to add Dockerfiles with an empty name.

## Possible areas for expansion
- When Docker Images are able to be built from this generator, the Dockerfile Database should be expanded to support Docker Image uploads and time-based records. For this demonstration, it was requested to run locally. But ideally, the database would be able to send full Docker Images to a service like AWS Elastic Container Registry and be accessible by the entire QA team. The program can be ran multiple times, chaining a container upload, Dockerfile storage, and testing results/notes for a specific build. All of this being timestamped makes record keeping a snap.
- There should be a verbiage change to the given options to indicate that *any* type of file can be added to the database. The reason it is important we indicate this is, that users should be able to upload testing reports/details about a particular build. Like the example above, I'd like an expanded version of this application to be able to upload testing reports and important information to a database, while a Docker Image is pushed to AWS ECS or another registry, making it easier for the QA team to keep track of builds being tested.
23 changes: 23 additions & 0 deletions SPECS/Spec_DockerfileGenerator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Feature Spec: Dockerfile Generation from Python files

## Goal
- Generate a Dockerfile for a python script or a python project.
- This application is meant to ease passing around containerized applications for testing purposes without needing to write your own Dockerfile. The full version of this project is meant to create a Docker Image. However, there are some security concerns/caveats for being able to build an image without the user already having Docker installed and setup (see "Possible areas for expansion").

## Scope
- In: A Python script. This can either include one python file or include other modules with a flag for the cli input.
- Out: A dockerfile, created in the same directory as the original python file is from. This allows users th generate a docker image afterwards.

## Requirements
- Generator must be able to detect the minimum python version necessary for a given python script.
- Generator must be able to detect any extra imports needed for the particular Python script, on request of the user.

## Acceptance Criteria
- [ ] Dockerfile output for one Python script, no imports.
- [ ] Dockerfile output for one Python script, including imports.
- [ ] Dockerfile output for a specialized framework (Django, Flask, etc).

## Possible areas for expansion
- The dockerfile generator currently works with python scripts, as we are able to detect what we need in a given script using the AST module. In the future, we may be able to implement other types of projects as well.
- Dockerfiles are normally used to generate a Docker Image, which is what is normally used to run containerized applications. Ensuring Docker is installed by a user requires them to have WSL (requires admin permissions to install in powershell), so for this demonstration, we use Dockerfiles instead. In the future, our goal is to build Docker Images from this generator as well, automating the entire process rather than just the file.
- When Docker Images are able to be built from this generator, the Dockerfile Database should be expanded to support Docker Image uploads and time records.
199 changes: 199 additions & 0 deletions src/.github_workflows_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
name: Test Suite

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
pip install vermin # Optional but recommended

- name: Run linting
run: |
pip install flake8
flake8 dockerfile_generator_v2.py --max-line-length=100 --ignore=E501,W503

- name: Run type checking (Python 3.9+)
if: matrix.python-version != '3.8'
run: |
pip install mypy
mypy dockerfile_generator_v2.py --ignore-missing-imports || true

- name: Run tests with coverage
run: |
pytest -v \
--cov=dockerfile_generator_v2 \
--cov-report=xml \
--cov-report=term-missing \
--cov-report=html

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

- name: Archive coverage report
if: matrix.python-version == '3.11'
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: htmlcov/

- name: Archive test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.python-version }}
path: |
.pytest_cache/
htmlcov/

test-without-vermin:
name: Test without vermin (fallback mode)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install minimal dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
# Explicitly do NOT install vermin to test fallback

- name: Run tests in fallback mode
run: |
pytest -v -k "not requires_vermin"

- name: Verify fallback detection works
run: |
python dockerfile_generator_v2.py python310_features.py
cat Dockerfile | grep "FROM python:3.10"

integration-test:
name: Integration Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install -r requirements-test.txt
pip install vermin

- name: Run integration tests
run: |
pytest -v -m integration

- name: Test Dockerfile generation for samples
run: |
python dockerfile_generator_v2.py sample_flask_app.py -o Dockerfile.flask
python dockerfile_generator_v2.py python310_features.py -o Dockerfile.py310
python dockerfile_generator_v2.py python38_features.py -o Dockerfile.py38
ls -la Dockerfile.*

- name: Verify generated Dockerfiles
run: |
grep "FROM python:" Dockerfile.flask
grep "EXPOSE 5000" Dockerfile.flask
grep "FROM python:3.10" Dockerfile.py310
grep "FROM python:3.8" Dockerfile.py38

docker-build-test:
name: Test Docker Build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install -r requirements-test.txt

- name: Generate Dockerfile for sample app
run: |
python dockerfile_generator_v2.py sample_flask_app.py

- name: Build Docker image
run: |
docker build -t test-flask-app .

- name: Verify Docker image
run: |
docker images | grep test-flask-app
docker inspect test-flask-app

code-quality:
name: Code Quality Checks
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install quality tools
run: |
pip install black isort flake8 pylint

- name: Check code formatting with black
run: |
black --check dockerfile_generator_v2.py || true

- name: Check import sorting
run: |
isort --check-only dockerfile_generator_v2.py || true

- name: Run pylint
run: |
pylint dockerfile_generator_v2.py --disable=C,R || true
3 changes: 3 additions & 0 deletions src/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/.idea/files2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/DatabaseApp/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/DatabaseApp/.idea/filesdatabase.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/DatabaseApp/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/DatabaseApp/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading