Skip to content

Commit 03c6297

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # .github/workflows/build.yml # requirements.txt
2 parents d3831b8 + b382ad0 commit 03c6297

File tree

8 files changed

+226
-66
lines changed

8 files changed

+226
-66
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,98 @@
1+
#
2+
# How to build this
3+
14
name: Build
25

6+
#
7+
# Operational Variables
8+
9+
env:
10+
MAJOR: 0
11+
MINOR: 0
12+
PYTHON_VERSION: 3.9.6
13+
14+
#
15+
# Establish when the workflow is run
16+
# We do build on every push except when we push onto main (which we ought to be subject to branch protection)
17+
# We do build whenever a PR onto main is closed (see on) and the code is actually merged (see release job if)
18+
# Why is that okay?
19+
# Since we're making a PR, we know from the previous workflow run on push that the repo is okay and the PR
20+
# shows that to us. A PR itself doesn't cause a build, except when it is closed and the changes were merged.
21+
322
on:
4-
pull_request:
5-
branches: [ main ]
23+
push:
24+
branches-ignore:
25+
- main
26+
pull_request_target:
27+
branches:
28+
- main
29+
types:
30+
- closed
31+
32+
#
33+
# Workflow
634

735
jobs:
8-
build:
936

37+
build:
1038
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
python-version: [3.9]
14-
1539
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Python ${{ matrix.python-version }}
40+
41+
- name: Checkout out our code
42+
uses: actions/checkout@v2
43+
44+
- name: Calculate Build Context
45+
run: |
46+
MRMAT_VERSION="${MAJOR}.${MINOR}.${GITHUB_RUN_NUMBER}"
47+
if [ "$GITHUB_EVENT_NAME" == 'pull_request_target' ]; then
48+
MRMAT_IS_RELEASE=true
49+
echo "::warning ::Building release ${MRMAT_VERSION}"
50+
echo "MRMAT_IS_RELEASE=true" >> $GITHUB_ENV
51+
else
52+
MRMAT_VERSION="${MRMAT_VERSION}.dev0"
53+
echo "::warning ::Building version ${MRMAT_VERSION}"
54+
fi
55+
echo "MRMAT_VERSION=${MRMAT_VERSION}" >> $GITHUB_ENV
56+
57+
- name: Set up Python ${{ env.PYTHON_VERSION }}
1858
uses: actions/setup-python@v2
1959
with:
20-
python-version: ${{ matrix.python-version }}
60+
python-version: ${{ env.PYTHON_VERSION }}
61+
62+
- name: Establish a cache for dependencies
63+
uses: actions/cache@v2
64+
with:
65+
path: ~/.local
66+
key: ${{ runner.os }}
67+
2168
- name: Install dependencies
2269
run: |
2370
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
25-
pip install -r test-requirements.txt
26-
- name: Lint with flake8
27-
run: |
28-
# stop the build if there are Python syntax errors or undefined names
29-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
30-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
31-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
32-
- name: Lint with pylint
71+
pip install --user wheel
72+
pip install --user -r requirements.txt
73+
pip install --user -r test-requirements.txt
74+
75+
- name: Test
3376
run: |
77+
flake8 --statistics
3478
pylint mrmat_python_api_flask
35-
- name: Install locally
36-
run: |
3779
python ./setup.py install
38-
- name: Test with pytest
39-
run: |
40-
python -m pytest --junitxml=build/test-results-${{ matrix.python-version }}.xml
41-
- name: Upload pytest test results
80+
python -m pytest
81+
82+
- name: Upload test results
4283
uses: actions/upload-artifact@v2
43-
with:
44-
name: pytest-results-${{ matrix.python-version }}
45-
path: build/test-results-${{ matrix.python-version }}.xml
46-
# Use always() to always run this step to publish test results when there are test failures
4784
if: ${{ always() }}
48-
- name: Upload coverage
49-
uses: actions/upload-artifact@v2
5085
with:
51-
name: coverage
52-
path: build/coverage.xml
86+
name: Test and Coverage
87+
path: |
88+
build/junit.xml
89+
build/coverage.xml
90+
91+
- name: Conditional Release
92+
uses: marvinpinto/action-automatic-releases@latest
93+
if: github.event.pull_request.merged == true
94+
with:
95+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
96+
automatic_release_tag: "${{ env.MRMAT_VERSION }}"
97+
prerelease: false
98+
title: "Release ${{ env.MRMAT_VERSION }}"

.github/workflows/sast.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contributing to this repository
2+
3+
This is reasonably small for you to just fork and raise a PR. Have fun.

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
Boilerplate code for a Python Flask API
44

55
[![Build](https://github.com/MrMatOrg/mrmat-python-api-flask/actions/workflows/build.yml/badge.svg)](https://github.com/MrMatOrg/mrmat-python-api-flask/actions/workflows/build.yml)
6-
[![SAST](https://github.com/MrMatOrg/mrmat-python-api-flask/actions/workflows/sast.yml/badge.svg)](https://github.com/MrMatOrg/mrmat-python-api-flask/actions/workflows/sast.yml)
76

87
This variant of a Python Flask API is code-first and using native Flask
9-
10-
Features:
8+
9+
## Features
1110

1211
* Code-first
1312
* Pluggable APIs and multiple API versions
@@ -17,6 +16,12 @@ Features:
1716
* No TLS, because this is intended to run behind a reverse proxy
1817
* Healthz
1918

19+
## How to build this
20+
21+
Use the standard `python ./setup.py install` to build. By default, the version built will be `0.0.0.dev0`,
22+
unless the `MRMAT_VERSION` environment variable is set by the build orchestrator (e.g. GitHub Actions). The
23+
version and whether a release is built is consequently controlled exlusively by the build orchestrator.
24+
2025
## How to run this
2126

2227
You have the choice of running this

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[pytest]
66
testpaths = tests
7-
#addopts = --cov=mrmat_python_api_flask --cov-report=term --cov-report=xml:build/coverage.xml --junit-xml=build/junit.xml
7+
addopts = --cov=mrmat_python_api_flask --cov-report=term --cov-report=xml:build/coverage.xml --junit-xml=build/junit.xml
88
junit_family = xunit2
99
log_cli = 1
1010
log_cli_level = INFO

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23+
import os
2324
from setuptools import setup, find_packages
2425

2526
setup(
2627
name='mrmat-python-api-flask',
27-
version='0.0.3',
28+
version=os.environ['MRMAT_VERSION'] if 'MRMAT_VERSION' in os.environ else '0.0.0.dev0',
2829
packages=find_packages(),
2930
license='MIT',
3031
author='MrMat',

0 commit comments

Comments
 (0)