-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first working draft of library for (de-)serialization to/from J…
…SON and XML Signed-off-by: Paul Horton <paul.horton@owasp.org>
- Loading branch information
Showing
38 changed files
with
2,588 additions
and
0 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,72 @@ | ||
# encoding: utf-8 | ||
|
||
# This file is part of py-serializable | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) Paul Horton. All Rights Reserved. | ||
|
||
name: Manual Pre Release Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_candidate_suffix: | ||
description: 'RC Suffix e.g. rc0, beta1, alpha2. Do not include a leading hyphen.' | ||
required: true | ||
type: string | ||
|
||
env: | ||
REPORTS_DIR: CI_reports | ||
DIST_DIR: dist | ||
DIST_ARTIFACT: python-dist | ||
PYTHON_VERISON: "3.10" | ||
POETRY_VERSION: "1.1.11" | ||
|
||
jobs: | ||
release_candidate: | ||
runs-on: ubuntu-latest | ||
concurrency: release_candidate | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERISON }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install poetry=="$POETRY_VERSION" --upgrade pip | ||
poetry config virtualenvs.create false | ||
poetry install | ||
python -m pip install python-semantic-release | ||
- name: Apply Pre Release Version | ||
run: | | ||
RC_VERSION="$(semantic-release --noop --major print-version)-${{ github.event.inputs.release_candidate_suffix }}" | ||
echo "RC Version will be: ${RC_VERSION}" | ||
poetry version ${RC_VERSION} | ||
poetry build | ||
- name: Artifact python dist | ||
# see https://github.com/actions/upload-artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.DIST_ARTIFACT }} | ||
path: ${{ env.DIST_DIR }}/ | ||
if-no-files-found: error | ||
- name: Publish Pre Release 📦 to PyPI | ||
# see https://github.com/pypa/gh-action-pypi-publish | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} |
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,150 @@ | ||
# encoding: utf-8 | ||
|
||
# This file is part of py-serializable | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) Paul Horton. All Rights Reserved. | ||
|
||
name: Python CI | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches-ignore: ['dependabot/**'] | ||
push: | ||
tags: [ 'v*.*.*' ] # run again on release tags to have tools mark them | ||
branches: [ 'main' ] | ||
|
||
env: | ||
REPORTS_DIR: CI_reports | ||
PYTHON_VERSION_DEFAULT: "3.10" | ||
POETRY_VERSION: "1.1.11" | ||
|
||
jobs: | ||
coding-standards: | ||
name: Linting & Coding Standards | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
# see https://github.com/actions/checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Python Environment | ||
# see https://github.com/actions/setup-python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION_DEFAULT }} | ||
architecture: 'x64' | ||
- name: Install poetry | ||
# see https://github.com/marketplace/actions/setup-poetry | ||
uses: Gr1N/setup-poetry@v7 | ||
with: | ||
poetry-version: ${{ env.POETRY_VERSION }} | ||
- name: Install dependencies | ||
run: poetry install | ||
- name: Run tox | ||
run: poetry run tox -e flake8 -s false | ||
|
||
static-code-analysis: | ||
name: Static Coding Analysis (py${{ matrix.python-version}} ${{ matrix.toxenv-factor }}) | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- # test with the locked dependencies | ||
python-version: '3.10' | ||
toxenv-factor: 'locked' | ||
- # test with the lowest dependencies | ||
python-version: '3.7' | ||
toxenv-factor: 'lowest' | ||
steps: | ||
- name: Checkout | ||
# see https://github.com/actions/checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Python Environment | ||
# see https://github.com/actions/setup-python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION_DEFAULT }} | ||
architecture: 'x64' | ||
- name: Install poetry | ||
# see https://github.com/marketplace/actions/setup-poetry | ||
uses: Gr1N/setup-poetry@v7 | ||
with: | ||
poetry-version: ${{ env.POETRY_VERSION }} | ||
- name: Install dependencies | ||
run: poetry install | ||
- name: Run tox | ||
run: poetry run tox -e mypy-${{ matrix.toxenv-factor }} -s false | ||
|
||
build-and-test: | ||
name: Test (${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.toxenv-factor }}) | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 10 | ||
env: | ||
REPORTS_ARTIFACT: tests-reports | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: | ||
- "3.10" # highest supported | ||
- "3.9" | ||
- "3.8" | ||
- "3.7" # lowest supported | ||
toxenv-factor: ['locked'] | ||
include: | ||
- # test with the lowest dependencies | ||
os: 'ubuntu-latest' | ||
python-version: '3.7' | ||
toxenv-factor: 'lowest' | ||
steps: | ||
- name: Checkout | ||
# see https://github.com/actions/checkout | ||
uses: actions/checkout@v3 | ||
- name: Create reports directory | ||
run: mkdir ${{ env.REPORTS_DIR }} | ||
- name: Setup Python Environment | ||
# see https://github.com/actions/setup-python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
architecture: 'x64' | ||
- name: Install poetry | ||
# see https://github.com/marketplace/actions/setup-poetry | ||
uses: Gr1N/setup-poetry@v7 | ||
with: | ||
poetry-version: ${{ env.POETRY_VERSION }} | ||
- name: Install dependencies | ||
run: poetry install | ||
- name: Ensure build successful | ||
run: poetry build | ||
- name: Run tox | ||
run: poetry run tox -e py-${{ matrix.toxenv-factor }} -s false | ||
- name: Generate coverage reports | ||
run: > | ||
poetry run coverage report && | ||
poetry run coverage xml -o ${{ env.REPORTS_DIR }}/coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.toxenv-factor }}.xml && | ||
poetry run coverage html -d ${{ env.REPORTS_DIR }} | ||
- name: Artifact reports | ||
if: ${{ ! cancelled() }} | ||
# see https://github.com/actions/upload-artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.REPORTS_ARTIFACT }} | ||
path: ${{ env.REPORTS_DIR }} | ||
if-no-files-found: error |
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,61 @@ | ||
# encoding: utf-8 | ||
|
||
# This file is part of py-serializable | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) Paul Horton. All Rights Reserved. | ||
|
||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release: | ||
# https://github.community/t/how-do-i-specify-job-dependency-running-in-another-workflow/16482 | ||
# limit this to being run on regular commits, not the commits that semantic-release will create | ||
if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):') | ||
runs-on: ubuntu-latest | ||
concurrency: release | ||
steps: | ||
- name: Checkout code | ||
# see https://github.com/actions/checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup python | ||
# see https://github.com/actions/setup-python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install poetry --upgrade pip | ||
poetry config virtualenvs.create false | ||
poetry install | ||
- name: View poetry version | ||
run: poetry --version | ||
- name: Python Semantic Release | ||
# see https://python-semantic-release.readthedocs.io/en/latest/automatic-releases/github-actions.html | ||
# see https://github.com/relekang/python-semantic-release | ||
uses: relekang/python-semantic-release@v7.31.2 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
repository_username: __token__ | ||
repository_password: ${{ secrets.PYPI_TOKEN }} | ||
pypi_token: ${{ secrets.PYPI_TOKEN }} |
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,44 @@ | ||
# encoding: utf-8 | ||
|
||
# This file is part of py-serializable | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) Paul Horton. All Rights Reserved. | ||
|
||
# Exlude python build & distribution directories | ||
build/ | ||
dist/ | ||
*.egg-info* | ||
|
||
# Exlude *.pyc | ||
*.pyc | ||
|
||
# Exclude test-related items | ||
.tox/* | ||
|
||
# Exclude coverage | ||
.coverage | ||
test-reports | ||
|
||
# Exclude Python Virtual Environment | ||
venv/ | ||
.venv/ | ||
|
||
# Exlude IDE related files | ||
.idea/* | ||
.vscode/* | ||
|
||
# Exclude generated docs | ||
docs/_build |
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,36 @@ | ||
# encoding: utf-8 | ||
|
||
# This file is part of py-serializable | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) Paul Horton. All Rights Reserved. | ||
|
||
[settings] | ||
## read the docs: https://pycqa.github.io/isort/docs/configuration/options.html | ||
## keep in sync with flake8 config - in `tox.ini` file | ||
known_first_party = serializable | ||
skip_gitignore = true | ||
skip_glob = | ||
build/*,dist/*,__pycache__,.eggs,*.egg-info*, | ||
*_cache,*.cache, | ||
.git/*,.tox/*,.venv/*,venv/* | ||
_OLD/*,_TEST/*, | ||
docs/* | ||
combine_as_imports = true | ||
default_section = THIRDPARTY | ||
ensure_newline_before_comments = true | ||
include_trailing_comma = true | ||
line_length = 120 | ||
multi_line_output = 3 |
Oops, something went wrong.