-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moves things around for better packaging and testing * Adds mypy linting and prepares for automated testing * Minor grammar fix * Re-ups the lockfile * Starts adding unit tests * Starts working on git tests * Tweaks * Installs pytest order and mock * Migrates fixtures into conftest * Adds tests for the compile route * Adds test for building docker images This is a preliminary test, the docker_actions will need some refactoring to make this a bit less cumbersome * Some extra cleanup * Finishes out docker tests * Adds the github action * oops * Sorts the results for test_build.py * Better naming * Fixes trailing whitespace in readme * Adds linter checks * Corrects the linter checks job * Caching for pre-commit * Bumps the lockfile * Adds the CI badge to the readme * Adds a unit test for more complex compiles * Docker test ordering * Corrects flake8 line-length * Version bump to 0.1.3
- Loading branch information
1 parent
9bf1a68
commit a086836
Showing
31 changed files
with
838 additions
and
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
per-file-ignores = | ||
tests/*:F401,F811 |
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,62 @@ | ||
name: CI | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- master | ||
push: | ||
|
||
jobs: | ||
run_pytest: | ||
name: Run Checks | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Python setup | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install poetry | ||
run: | | ||
python -m pip install -U poetry | ||
- id: cache-poetry | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pypoetry/virtualenvs | ||
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install dependencies | ||
if: steps.cache-poetry.outputs.cache-hit != 'true' | ||
run: | | ||
poetry install | ||
- name: Run tests | ||
run: | | ||
poetry run test -v | ||
run_lints: | ||
name: Run linters | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Python setup | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install poetry | ||
run: | | ||
python -m pip install -U poetry | ||
- id: cache-poetry | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pypoetry/virtualenvs | ||
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install dependencies | ||
if: steps.cache-poetry.outputs.cache-hit != 'true' | ||
run: | | ||
poetry install | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: ${{ runner.os }}-pre_commit-${{ hashFiles('.pre-commit-config.yaml') }} | ||
- name: Pre-commit linters | ||
run: | | ||
poetry run pre-commit run --show-diff-on-failure --color=always --all-files |
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
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,38 @@ | ||
from flask import abort | ||
from flask import Blueprint | ||
from flask import Flask | ||
from flask import jsonify | ||
from flask import request | ||
from flask import Response | ||
|
||
from od_compiler.util.compiler_logger import compile_logger | ||
from od_compiler.util.docker_actions import compileOD | ||
|
||
compile = Blueprint("compile", __name__, url_prefix="/") | ||
|
||
|
||
def create_app(logger_override=None) -> Flask: | ||
app = Flask(__name__) | ||
|
||
if logger_override: | ||
compile_logger.setLevel(logger_override) | ||
|
||
app.register_blueprint(compile) | ||
|
||
return app | ||
|
||
|
||
@compile.route("/compile", methods=["POST"]) | ||
def startCompile() -> Response: | ||
""" | ||
Takes in arbitrary OD/DM code and returns a JSON response containing compiler and server logs | ||
""" | ||
posted_data = request.get_json() | ||
compile_logger.debug(f"Request incoming containing: {posted_data}") | ||
if "code_to_compile" in posted_data: | ||
compile_logger.info("Request received. Attempting to compile...") | ||
args = posted_data["extra_arguments"] if "extra_arguments" in posted_data else None | ||
return jsonify(compileOD(posted_data["code_to_compile"], compile_args=args)) | ||
else: | ||
compile_logger.warning(f"Bad request received:\n{request.get_json()}") | ||
return abort(400) |
Empty file.
File renamed without changes.
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.