Skip to content

Commit 29ffada

Browse files
committed
[NEW] Automate Ubuntu and Macos CI builds for the Template Project
2 parents 7d2bdb2 + 937c37a commit 29ffada

File tree

10 files changed

+162
-176
lines changed

10 files changed

+162
-176
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ${{ matrix.platform }}
1717
strategy:
1818
matrix:
19-
platform: [ubuntu-latest]
19+
platform: [ubuntu-latest, macos-latest]
2020
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
2121

2222
steps:

README.rst

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Python Package (pypi) Cookiecutter, with emphasis on CI/CD and automation.
55

66
.. start-badges
77
8-
| |build| |release_version| |wheel| |supported_versions| |commits_since_specific_tag_on_master| |commits_since_latest_release|
8+
| |build| |release_version| |wheel| |supported_versions| |commits_since_specific_tag_on_master| |commits_since_latest_github_release|
99
1010

1111
|
@@ -34,39 +34,22 @@ Python Package (pypi) Cookiecutter, with emphasis on CI/CD and automation.
3434
:alt: Supported Python versions
3535
:target: https://pypi.org/project/cookiecutter_python
3636

37-
.. |supported_versions_old| image:: https://img.shields.io/pypi/pyversions/cookiecutter_python.svg
38-
:alt: Supported Python versions
39-
:target: https://pypi.org/project/cookiecutter_python
40-
41-
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v0.5.4/master?color=blue&logo=github
37+
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v0.6.1/master?color=blue&logo=github
4238
:alt: GitHub commits since tagged version (branch)
43-
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v0.5.4..master
39+
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v0.6.1..master
4440

45-
.. |commits_since_latest_release| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/latest?color=blue&logo=semver&sort=semver
41+
.. |commits_since_latest_github_release| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/latest?color=blue&logo=semver&sort=semver
4642
:alt: GitHub commits since latest release (by SemVer)
47-
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v0.5.4..master
48-
49-
50-
.. |commits_since| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v0.5.4/master?logo=github
51-
:alt: GitHub commits on branch, since tagged version
52-
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v0.5.4..master
53-
54-
5543

56-
.. |circleci| image:: https://circleci.com/gh/boromir674/cookiecutter-python-package/tree/master.svg?style=shield
57-
:alt: CircleCI
58-
:target: https://circleci.com/gh/boromir674/cookiecutter-python-package/tree/master
5944

6045
.. |codecov| image:: https://img.shields.io/codecov/c/github/boromir674/cookiecutter-python-package/master?logo=codecov
6146
:alt: Codecov
6247
:target: https://codecov.io/gh/boromir674/cookiecutter-python-package
6348

64-
6549
.. |better_code_hub| image:: https://bettercodehub.com/edge/badge/boromir674/cookiecutter-python-package?branch=master
6650
:alt: Better Code Hub
6751
:target: https://bettercodehub.com/
6852

69-
7053
.. |sc1| image:: https://img.shields.io/scrutinizer/quality/g/boromir674/cookiecutter-python-package/master?logo=scrutinizer&style=flat
7154
:alt: Scrutinizer code quality
7255
:target: https://scrutinizer-ci.com/g/boromir674/cookiecutter-python-package/?branch=master
@@ -92,11 +75,16 @@ Check the `Cookiecutter documentation`_ pages for more on Cookiecutter.
9275

9376
Usage
9477
=====
78+
79+
Simply, get (clone) the code and generate a Project based on the (downloaded) template.
80+
9581
Open a console/terminal and run:
9682

9783
.. code-block:: sh
9884
99-
cookiecutter gh:boromir674/cookiecutter-python-package
85+
git clone git@github.com:boromir674/cookiecutter-python-package.git
86+
87+
cookiecutter cookiecutter-python-package/src/cookiecutter_python
10088
10189
10290
This will generate a new `Python Package Project` (in the currect dir), using the template from github.

setup.cfg

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[metadata]
22
## Setuptools specific information
33
name = cookiecutter_python
4-
version = 0.5.4
4+
version = 0.6.1
55
# renders on pypi as subtitle
66
description = Yet another modern Python Package (pypi) with emphasis in CI/CD and automation
77
long_description = file: README.rst
88
long_description_content_type = text/x-rst
99
license = AGPLv3
1010
license_files = LICENSE
11-
platforms = All
11+
platforms = Linux, Darwin
1212
author = Konstantinos Lampridis
1313
author_email = k.lampridis@hotmail.com
1414

1515
# represents the web home page of the project
1616
url = https://github.com/boromir674/cookiecutter-python-package
1717

18-
download_url = https://github.com/boromir674/cookiecutter-python-package/archive/v0.5.0.tar.gz
18+
download_url = https://github.com/boromir674/cookiecutter-python-package/archive/v0.6.1.tar.gz
1919

2020
## PyPi specific information
2121
project_urls =
@@ -48,6 +48,7 @@ classifiers =
4848

4949

5050
[options]
51+
python_requires = >= 3.6
5152
zip_safe = False
5253
include_package_data = True
5354
package_dir=
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.5.4'
1+
__version__ = '0.6.1'

src/cookiecutter_python/{{ cookiecutter.project_slug }}/.github/workflows/test.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
runs-on: ${{ "{{" }} matrix.platform {{ "}}" }}
1717
strategy:
1818
matrix:
19-
platform: [ubuntu-latest, macos-latest, windows-latest]
20-
python-version: [3.6, 3.7, 3.8]
19+
platform: [ubuntu-latest, macos-latest]
20+
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
2121

2222
steps:
2323
- uses: actions/checkout@v1
@@ -29,8 +29,8 @@ jobs:
2929
run: |
3030
python -m pip install --upgrade pip
3131
python -m pip install tox tox-gh-actions
32-
- name: Do Type Checking
33-
run: tox -e type --skip-missing-interpreters false -vv
32+
- name: Specify current package version to assist build tool
33+
run: echo "PKG_VERSION=$(python scripts/parse_version.py)" >> $GITHUB_ENV
3434
- name: Run Test Suite
3535
run: tox --skip-missing-interpreters false -vv
3636
env:

src/cookiecutter_python/{{ cookiecutter.project_slug }}/README.rst

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,49 @@
44

55
.. start-badges
66
7-
| |circleci| |codecov|
8-
| |release_version| |wheel| |supported_versions| |commits_since|
9-
| |better_code_hub| |sc1|
7+
| |build| |release_version| |wheel| |supported_versions| |commits_since_specific_tag_on_master| |commits_since_latest_github_release|
8+
109

1110
|
1211
| **Source Code:** https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}
12+
| **Pypi Package:** https://pypi.org/project/{{ cookiecutter.pkg_name }}/
1313
|
1414
1515

16+
.. Test Workflow Status on Github Actions for specific branch <branch>
17+
18+
.. |build| image:: https://img.shields.io/github/workflow/status/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/Test%20Python%20Package/master?label=build&logo=github-actions&logoColor=%233392FF
19+
:alt: GitHub Workflow Status (branch)
20+
:target: https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/actions/workflows/test.yaml?query=branch%3Amaster
21+
22+
.. above url to workflow runs, filtered by the specified branch
23+
1624
.. |release_version| image:: https://img.shields.io/pypi/v/{{ cookiecutter.pkg_name }}
1725
:alt: Production Version
1826
:target: https://pypi.org/project/{{ cookiecutter.pkg_name }}/
1927

20-
.. |wheel| image:: https://img.shields.io/pypi/wheel/{{ cookiecutter.pkg_name }}.svg
21-
:alt: Python Wheel
28+
.. |wheel| image:: https://img.shields.io/pypi/wheel/{{ cookiecutter.pkg_name|replace('_', '-') }}?color=green&label=wheel
29+
:alt: PyPI - Wheel
2230
:target: https://pypi.org/project/{{ cookiecutter.pkg_name }}
2331

24-
.. |supported_versions| image:: https://img.shields.io/pypi/pyversions/{{ cookiecutter.pkg_name }}.svg
32+
.. |supported_versions| image:: https://img.shields.io/pypi/pyversions/{{ cookiecutter.pkg_name|replace('_', '-') }}?color=blue&label=python&logo=python&logoColor=%23ccccff
2533
:alt: Supported Python versions
2634
:target: https://pypi.org/project/{{ cookiecutter.pkg_name }}
2735

28-
.. |commits_since| image:: https://img.shields.io/github/commits-since/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/v{{ cookiecutter.version }}/master?logo=github
29-
:alt: GitHub commits on branch, since tagged version
36+
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/v{{ cookiecutter.version }}/master?color=blue&logo=github
37+
:alt: GitHub commits since tagged version (branch)
3038
:target: https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/compare/v{{ cookiecutter.version }}..master
3139

40+
.. |commits_since_latest_github_release| image:: https://img.shields.io/github/commits-since/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/latest?color=blue&logo=semver&sort=semver
41+
:alt: GitHub commits since latest release (by SemVer)
3242

3343

34-
.. |circleci| image:: https://circleci.com/gh/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/tree/master.svg?style=shield
35-
:alt: CircleCI
36-
:target: https://circleci.com/gh/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/tree/master
37-
38-
.. |codecov| image:: https://img.shields.io/codecov/c/github/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/master?logo=codecov
39-
:alt: Codecov
40-
:target: https://codecov.io/gh/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}
41-
42-
43-
.. |better_code_hub| image:: https://bettercodehub.com/edge/badge/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}?branch=master
44-
:alt: Better Code Hub
45-
:target: https://bettercodehub.com/
46-
47-
48-
.. |sc1| image:: https://img.shields.io/scrutinizer/quality/g/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/master?logo=scrutinizer&style=flat
49-
:alt: Scrutinizer code quality
50-
:target: https://scrutinizer-ci.com/g/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/?branch=master
51-
52-
53-
54-
Featuring
44+
Features
45+
========
5546

5647
- TODO-feature 1
5748
- TODO-feature 2
5849

59-
60-
========
61-
Overview
62-
========
63-
64-
* Free software: Affero GNU General Public License v3.0
65-
6650
Prerequisites
6751
=============
6852

@@ -73,9 +57,17 @@ Installation
7357

7458
Using `pip` is the approved way for installing `{{ cookiecutter.pkg_name }}`.
7559

60+
.. code-block:: sh
61+
62+
python3 -m pip install {{ cookiecutter.pkg_name }}
63+
7664
7765
Usage
7866
=====
7967

80-
How it works
81-
============
68+
TODO
69+
70+
License
71+
=======
72+
73+
* Free software: Affero GNU General Public License v3.0
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
3+
4+
import os
5+
import re
6+
import sys
7+
8+
my_dir = os.path.dirname(os.path.realpath(__file__))
9+
10+
SETUP_CFG_FILENAME = 'setup.cfg'
11+
SETUP_CFG = os.path.join(my_dir, '../', SETUP_CFG_FILENAME)
12+
13+
14+
def main():
15+
"""Get the package version string provided that the developer has setup indication how to find it. Reads the
16+
[semantic_release] section found in setup.cfg and then determines where is the actual version string
17+
"""
18+
# Automatically compute package version from the [semantic_release] section in setup.cfg
19+
with open(SETUP_CFG, 'r') as _file:
20+
regex = r"\[semantic_release\][\w\s=/\.:\d]+version_variable[\ \t]*=[\ \t]*([\w\.]+(?:/[\w\.]+)*):(\w+)"
21+
match = re.search(regex, _file.read(), re.MULTILINE)
22+
if match:
23+
file_with_version_string = os.path.join(my_dir, '../', match.group(1))
24+
variable_holding_version_value = match.group(2)
25+
else:
26+
raise RuntimeError(
27+
f"Expected to find the '[semantic_release]' section, in the '{SETUP_CFG}' file, with key "
28+
f"'version_variable'.\nFor example:\n[semantic_release]\nversion_variable = "
29+
f"src/package_name/__init__.py:__version__\n indicated that the version string should be looked up in "
30+
f"the src/package_name/__init__.py file registered under the __version__ 'name'")
31+
32+
# (it does not have to be a.py file)
33+
# to indicate that the version is stored in the '__version__'
34+
if not os.path.isfile(file_with_version_string):
35+
raise FileNotFoundError(
36+
f"Path '{file_with_version_string} does not appear to be valid. Please go to the '{SETUP_CFG}' file, at the"
37+
f" [semantic_release] section and set the 'version_variable' key with a valid file path (to look for the "
38+
f"version string)")
39+
40+
reg_string = r'\s*=\s*[\'\"]([^\'\"]*)[\'\"]'
41+
42+
43+
with open(file_with_version_string, 'r') as _file:
44+
content = _file.read()
45+
reg = f'^{variable_holding_version_value}' + reg_string
46+
match = re.search(reg, content, re.MULTILINE)
47+
if match:
48+
_version = match.group(1)
49+
return _version
50+
raise AttributeError(f"Could not find a match for regex {reg} when applied to:\n{content}")
51+
52+
53+
if __name__ == '__main__':
54+
try:
55+
version_string = main()
56+
print(version_string)
57+
except (RuntimeError, FileNotFoundError, AttributeError) as exception:
58+
print(exception)
59+
sys.exit(1)

src/cookiecutter_python/{{ cookiecutter.project_slug }}/scripts/read_required.py

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

0 commit comments

Comments
 (0)