Skip to content

Commit

Permalink
Merge pull request #149 from OkieOth/move2requirements.txt
Browse files Browse the repository at this point in the history
Move2requirements.txt
  • Loading branch information
OkieOth committed Nov 16, 2023
2 parents d1c60b6 + 70a9bf0 commit deb3a3a
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 66 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/__tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv flake8
[[ -d venv ]] || virtualenv venv
source venv/bin/activate
pipenv --python 3.10
pipenv install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --exclude venv --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=15 --max-line-length=127 --statistics --per-file-ignores='yacg/model/*.py:E501 E303 W391'
flake8 . --exclude venv --count --exit-zero --max-complexity=15 --max-line-length=127 --statistics --per-file-ignores='yacg/model/*.py:E501 E303 W391'
- name: Run and stuff from command line
run: |
bin/runGithubActions.sh
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM python:3.10-slim-buster

RUN pip install pipenv

WORKDIR /yacg

Expand All @@ -14,17 +13,15 @@ ADD randomDataServer.py randomDataServer.py
ADD customRandomConstraints.py customRandomConstraints.py
ADD validate.py validate.py
ADD version.txt version.txt
ADD Pipfile Pipfile
ADD Pipfile.lock Pipfile.lock
ADD requirements.txt requirements.txt
COPY yacg yacg/

#RUN cd /yacg && \
# pipenv --python 3.8 && \
# pipenv --three install --system

RUN pipenv requirements > requirements.txt
RUN pip install -r requirements.txt

WORKDIR /yacg

ENTRYPOINT [ "python3", "yacg.py"]
ENTRYPOINT [ "python3", "yacg.py"]
49 changes: 24 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,37 @@ ln -s /bin/pip
```bash
# basic preparation
sudo apt-get install python3-venv
pip install --user pipenv

pipenv --python 3.11
pipenv install
pipenv shell
virtualenv venv
source venv/bin/activate

pip install -r requirements.txt


# in case of errors to create virtual env look here
# https://askubuntu.com/questions/1241993/why-i-cannot-create-pipenv-shell-in-ubuntu-20-04-lts-with-python3-8

# do a demo run ... and create plantuml
pipenv run python3 yacg.py \
python yacg.py \
--models resources/models/json/yacg_config_schema.json \
resources/models/json/yacg_model_schema.json \
--singleFileTemplates plantUml=stdout

pipenv run python3 yacg.py \
python yacg.py \
--models resources/models/json/yacg_config_schema.json \
resources/models/json/yacg_model_schema.json \
--usedFilesOnly

# demo run with protobuf example output
pipenv run python3 yacg.py \
python yacg.py \
--models resources/models/json/yacg_config_schema.json \
resources/models/json/yacg_model_schema.json \
--singleFileTemplates protobuf=stdout


# run a test
pipenv run python3 -m unittest -v tests/model/test_model.py
python -m unittest -v tests/model/test_model.py

# run all tests
pipenv run python3 -m unittest discover tests "test_*.py"
python -m unittest discover tests "test_*.py"
```
## Docker
```bash
Expand Down Expand Up @@ -118,10 +117,10 @@ This project contains also a script to increment model versions. I has the abili
## Usage
```bash
# see the possible parameters of the script
pipenv run python3 incrementVersion.py
python incrementVersion.py

# do an example dry-run
pipenv run python3 incrementVersion.py --model resources/models/json/yacg_model_schema.json --version minor
python incrementVersion.py --model resources/models/json/yacg_model_schema.json --version minor
```


Expand All @@ -131,20 +130,20 @@ This project contains also a script to convert JSON schemas to the yaml format.
## Usage
```bash
# see the possible parameters of the script
pipenv run python3 modelToYaml.py --help
python modelToYaml.py --help

# do an example dry-run
pipenv run python3 modelToYaml.py --model resources/models/json/yacg_model_schema.json --dryRun
python modelToYaml.py --model resources/models/json/yacg_model_schema.json --dryRun

# feed stdin to convert
cat resources/models/json/yacg_model_schema.json | pipenv run python3 modelToYaml.py --stdin --dryRun
cat resources/models/json/yacg_model_schema.json | python modelToYaml.py --stdin --dryRun


# more sophisticated example to create openApi yaml
pipenv run python3 yacg.py \
python yacg.py \
--models tests/resources/models/json/examples/openapi_v3_example_refs.json \
--singleFileTemplates resources/templates/examples/normalizedOpenApiJson.mako=/tmp/test.json && \
pipenv run python3 modelToYaml.py --model /tmp/test.json --destDir /tmp
python modelToYaml.py --model /tmp/test.json --destDir /tmp
```

# Models to JSON
Expand All @@ -153,13 +152,13 @@ This project contains also a script to convert yaml schemas to the JSON format.
## Usage
```bash
# see the possible parameters of the script
pipenv run python3 modelToJson.py --help
python modelToJson.py --help

# do an example dry-run
pipenv run python3 modelToJson.py --model resources/models/yaml/yacg_config_schema.yaml --dryRun
python modelToJson.py --model resources/models/yaml/yacg_config_schema.yaml --dryRun

# feed stdin to convert
cat resources/models/yaml/yacg_config_schema.yaml | pipenv run python3 modelToJson.py \
cat resources/models/yaml/yacg_config_schema.yaml | python modelToJson.py \
--stdin --dryRun
```

Expand All @@ -170,7 +169,7 @@ schema
## Usage
```bash
# python version
pipenv run python3 normalizeSchema.py --model
python normalizeSchema.py --model

# docker version
docker run -u $(id -u ${USER}):$(id -g ${USER}) \
Expand All @@ -193,7 +192,7 @@ from the schema input and tries the validation without it.
## Usage
```bash
# bash version
pipenv run python3 validate.py --schema resources/models/json/yacg_config_schema.json \
python validate.py --schema resources/models/json/yacg_config_schema.json \
--inputFile resources/configurations/conf_with_vars.json \
--draft07hack # used because json-spec has currently not draft07 support

Expand All @@ -215,7 +214,7 @@ For further configurations see [here](docs/random_data_creation.md)

```bash
# creates in the tmp folder a file Job.json with 10 random objects of the Job type
pipenv run python3 createRandomData.py --model resources/models/json/yacg_config_schema.json \
python createRandomData.py --model resources/models/json/yacg_config_schema.json \
--type Job \
--defaultElemCount 10
--outputDir ./tmp
Expand All @@ -229,7 +228,7 @@ with that script.

```bash
# will start a simple http server on port 8080 that provides random data for a given type
pipenv run python3 randomDataServer.py --model resources/models/json/yacg_config_schema.json
python randomDataServer.py --model resources/models/json/yacg_config_schema.json

# reading one random data set of the type 'Job'
curl 'http://localhost:8080/job'
Expand Down
4 changes: 2 additions & 2 deletions bin/demoGenerateCodeForYacg_configFile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ scriptPos=${0%/*}
pushd $scriptPos/.. > /dev/null

echo "create yacg demo code based on a config file ..."
if ! pipenv run python3 yacg.py --config resources/configurations/gen_yacg_code.json; then
if ! python yacg.py --config resources/configurations/gen_yacg_code.json; then
echo " ERROR while create the stuff :-/"
exit 1
fi

popd > /dev/null
popd > /dev/null
2 changes: 1 addition & 1 deletion bin/demoMultiFileGenerator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ scriptPos=${0%/*}
pushd $scriptPos/.. > /dev/null

echo "create meta model cconfiglasses ..."
if ! pipenv run python3 yacg.py --models \
if ! python yacg.py --models \
resources/models/json/yacg_model_schema.json \
--multiFileTemplates ${scriptPos}/../resources/templates/examples/javaBeans.mako=${scriptPos}/../tmp/cmdJavaBeans/de/test/model \
--templateParameters modelPackage=de.test.model \
Expand Down
14 changes: 7 additions & 7 deletions bin/generateCodeForYacg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ scriptPos=${0%/*}
pushd $scriptPos/.. > /dev/null

echo "create meta model classes ..."
if ! pipenv run python3 yacg.py --models \
if ! python yacg.py --models \
resources/models/json/yacg_model_schema.json \
--singleFileTemplates pythonBeans=${scriptPos}/../yacg/model/model.py \
pythonBeansTests=${scriptPos}/../tests/model/test_model.py \
Expand All @@ -25,7 +25,7 @@ if ! pipenv run python3 yacg.py --models \
fi

echo "create config model classes ..."
if ! pipenv run python3 yacg.py --models \
if ! python yacg.py --models \
resources/models/json/yacg_config_schema.json \
--singleFileTemplates pythonBeans=${scriptPos}/../yacg/model/config.py \
pythonBeansTests=${scriptPos}/../tests/model/test_config.py \
Expand All @@ -39,7 +39,7 @@ if ! pipenv run python3 yacg.py --models \
fi

echo "create random config model classes ..."
if ! pipenv run python3 yacg.py --models \
if ! python yacg.py --models \
resources/models/json/yacg_random_data_types.json \
--singleFileTemplates pythonBeans=${scriptPos}/../yacg/model/random_config.py \
pythonBeansTests=${scriptPos}/../tests/model/test_random_config.py \
Expand All @@ -53,7 +53,7 @@ if ! pipenv run python3 yacg.py --models \
fi

echo "create shared model classes ..."
if ! pipenv run python3 yacg.py --models \
if ! python yacg.py --models \
resources/models/json/shared/info.json \
--singleFileTemplates pythonBeans=${scriptPos}/../yacg/model/shared/info.py \
--protocolFile logs/gen_shared_info.log \
Expand All @@ -66,7 +66,7 @@ fi


echo "create openapi model classes ..."
if ! pipenv run python3 yacg.py --models \
if ! python yacg.py --models \
resources/models/json/yacg_openapi_paths.json \
--singleFileTemplates pythonBeans=${scriptPos}/../yacg/model/openapi.py \
pythonBeansTests=${scriptPos}/../tests/model/test_openapi.py \
Expand All @@ -81,7 +81,7 @@ if ! pipenv run python3 yacg.py --models \
fi

echo "create asyncapi model classes ..."
if ! pipenv run python3 yacg.py --models \
if ! python yacg.py --models \
resources/models/json/yacg_asyncapi_types.json \
--singleFileTemplates pythonBeans=${scriptPos}/../yacg/model/asyncapi.py \
pythonBeansTests=${scriptPos}/../tests/model/test_asyncapi.py \
Expand All @@ -96,4 +96,4 @@ if ! pipenv run python3 yacg.py --models \
fi


popd > /dev/null
popd > /dev/null
6 changes: 3 additions & 3 deletions bin/generateNormalizedOpenApi_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ scriptPos=${0%/*}

pushd $scriptPos/.. > /dev/null

if ! pipenv run python3 yacg.py \
if ! python yacg.py \
--noLogs \
--models tests/resources/models/json/examples/openapi_v3_example_refs.json \
--singleFileTemplates resources/templates/examples/normalizedOpenApiJson.mako=stdout \
| pipenv run python3 modelToYaml.py --stdin --dryRun
| python modelToYaml.py --stdin --dryRun
then
echo " ERROR while create the stuff :-/"
exit 1
fi

popd > /dev/null
popd > /dev/null

0 comments on commit deb3a3a

Please sign in to comment.