Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Version '1.12.2' into 'master' Branch #166

Merged
merged 7 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[run]
source =
cookiecutter_python
tests

[report]
show_missing = true
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/auto-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ jobs:
run: git commit -am "${{ steps.rc_msg.outputs.RC_MSG }}"

## Trigger (gitops) Release Candidate 'Stress Tests' ##
- name: Push '${{ env.RELEASE }}' Branch, to sync RC Sem Ver in Remote
run: git push

- name: "Trigger Release Candidate - Stress Tests"
env:
rc_tag: 'v${{ steps.rc_sem_ver.outputs.RC_VER }}'
run: |
echo "[STEP]: Tag Commit: ${rc_tag}"
git tag -d "$rc_tag"; git push --delete origin "$rc_tag"; git tag "$rc_tag" && git push origin "$rc_tag"
echo "[STEP]: Tag Local: ${rc_tag}"
git tag -d "$rc_tag" || echo "Ensured Local Tag $rc_tag does not exist"
git tag "$rc_tag"
echo
echo "[STEP]: Tag Remote: ${rc_tag}"
git push --delete origin "$rc_tag" || echo "Ensured Remote Tag $rc_tag does not exist"
git push origin "$rc_tag"
echo
echo " -> Pushed tag $rc_tag"
echo
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/load-to-rt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# export tt='board-rt'
# OR
# export tt='boarding-n-auto-release'
# export tt='boarding-auto'
# for Automatically merging Release Train in Release

# git tag -d "$tt"; git push --delete origin "$tt"; git tag "$tt" && git push origin "$tt"
Expand All @@ -26,13 +26,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TRAIN: 'release-train'
BOARDING: ${{ github.event.ref == 'refs/tags/auto-release' && 'boarding-n-auto-release' || 'boarding' }}
BOARDING: ${{ github.event.ref == 'refs/tags/auto-release' && 'boarding-auto' || 'boarding' }}
MAIN_BRANCH: 'master'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 0 indicates all history for all branches and tags.
set-safe-directory: '' # `git config --global --add safe.directory <path>`
# GH_TOKEN should be a PAT, that allows to trigger Actions Workflow (default GITHUB_TOKEN cannot invoke Worklflows!)
token: '${{ secrets.GH_TOKEN }}'

- run: git log --graph --decorate --color --all --stat
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/merge-rt-in-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,47 @@
# 2. Test
# 3. Merge

# Tested to Trigger when a developer merges PR from github UI
# to test if triggers on programmatic merge: `gh pr merge boarding-auto --auto --delete-branch --squash`

name: Merge RT in Release
# Release Train (RT) has All changes needed for Release
# We Test RT, and do auto merge if CI Checks Pass

on:
pull_request:
# When a pull request merges, the pull request is automatically closed.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges
types: [closed]
# push:
# tags:
# - merge-rt-in-release
branches: # ALLOWED Base Branches
- release-train

jobs:
# RUN Job when 'boarding-auto --> 'release-train' PR is merged
merge_rt_in_release:
# When 'boarding-n-auto-release --> 'release-train' PR is merged
if: ${{ github.event.pull_request.merged == true &&
github.event.pull_request.head.ref == 'boarding-n-auto-release' && \
github.event.pull_request.base.ref == 'release-train' }}
# ALLOWED Head Branches
# if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'boarding-auto')
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true

runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TRAIN: 'release-train'
RELEASE_BR: 'release'
MAIN_BR: 'master'
steps:
- run: "echo \"[DEBUG] HEAD: '${{ github.head_ref }}', should be 'boarding-auto'\""
- run: "echo \"[DEBUG] BASE: '${{ github.base_ref }}', should be 'release-train'\""

- uses: actions/checkout@v4
with:
fetch-depth: 0 # 0 indicates all history for all branches and tags.
set-safe-directory: '' # `git config --global --add safe.directory <path>`
token: '${{ secrets.GH_TOKEN }}'

# Track the remote branches
- run: git branch --track "${{ env.TRAIN }}" "origin/${{ env.TRAIN }}"
- run: git branch --track "${{ env.RELEASE_BR }}" "origin/${{ env.RELEASE_BR }}"
- run: git branch --track "${{ env.TRAIN }}" "origin/${{ env.TRAIN }}" || echo "Branch '${{ env.TRAIN }}' already exists"
- run: git branch --track "${{ env.RELEASE_BR }}" "origin/${{ env.RELEASE_BR }}" || echo "Branch '${{ env.RELEASE_BR }}' already exists"

############## PR ##############
- name: "Create PR 'head': ${{ env.TRAIN }} --> 'base': ${{ env.RELEASE_BR }}"
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ Changelog
=========


1.12.2 (2024-02-07)
===================

**Regression and Backwards Compatibility - Tests**

This Release features the addition of Automated Regression Test for 'Generator Docs Default Settings'.
By Default Generator v2.x promises that upon invocation, the generated Project with be configured for
| Doc Builds with Sphinx and RTD Python3.8.

The Test will fail if Defaults change.
If Test is fixed, by updating assertion in Test Code, then then this is evidence that if we release these future changes,
they possibly introduce "breaking changes".

Also, we add a new Test on the Dialog Prompts to verify that they prompt the User for each and every one of the Cookiecutter Tempalte Variables.
If this test fails, then the Dialog System and the Cookiecutter Tempalte Vars are out of Sync, which should be addressed, preventing a Bug from shipping Code with the 2 components being NOT synced.

From this Relase onward, we also start measuring Code Coverage only on Production Code.
We only measure the 'src' dir, and stop measuring Test Code, in 'tests' dir.

Changes
^^^^^^^

test
""""
- verify Gen Project configured with Sphinx and RTD Py3.8, as advertised Defaults
- verify prompts user for each and everyone of Cookiecutter Template Variables

release
"""""""
- bump version to 1.12.2


1.12.1 (2024-01-29)
===================

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ Free/Libre and Open Source Software (FLOSS)

.. Github Releases & Tags

.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v1.12.1/master?color=blue&logo=github
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v1.12.2/master?color=blue&logo=github
:alt: GitHub commits since tagged version (branch)
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v1.12.1..master
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v1.12.2..master

.. |commits_since_latest_github_release| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/latest?color=blue&logo=semver&sort=semver
:alt: GitHub commits since latest release (by SemVer)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
author = 'Konstantinos Lampridis'

# The full version, including alpha/beta/rc tags
release = '1.12.1'
release = '1.12.2'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build-backend = "poetry.core.masonry.api"
## Also renders on pypi as 'subtitle'
[tool.poetry]
name = "cookiecutter_python"
version = "1.12.1"
version = "1.12.2"
description = "1-click Generator of Python Project, from Template with streamlined \"DevOps\" using a powerful CI/CD Pipeline."
authors = ["Konstantinos Lampridis <[email protected]>"]
maintainers = ["Konstantinos Lampridis <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion src/cookiecutter_python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '1.12.1'
__version__ = '1.12.2'

from . import _logging # noqa
39 changes: 0 additions & 39 deletions src/cookiecutter_python/handle/dialogs/lib/interpreters_dialog.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/cookiecutter_python/handle/dialogs/lib/project_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@InteractiveDialog.register_as_subclass('project-name')
class ProjectNameDialog:
def dialog(self, cookie_vars) -> Mapping[str, str]:
print(f"\n\n---- {cookie_vars['rtd_python_version']}")

return prompt(
[
{
Expand Down
19 changes: 0 additions & 19 deletions src/cookiecutter_python/handle/interactive_cli_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,6 @@ class InteractiveDialogsPipeline:

dialogs = [
'project-name',
# 'project_type',
# 'project_slug',
# 'pkg_name',
# 'repo_name',
# 'readthedocs_project_slug',
# 'docker_image',
# 'full_name',
# 'author',
# 'author_email',
# 'github_username',
# 'project_short_description',
# 'pypi_subtitle',
# 'release_date',
# 'year',
# 'version',
# 'initialize_git_repo',
# 'interpreters',
# 'docs_builder',
# 'rtd_python_version',
]

def process(self, request):
Expand Down
31 changes: 0 additions & 31 deletions src/cookiecutter_python/handle/interpreters_support.py

This file was deleted.

63 changes: 63 additions & 0 deletions tests/test_dialog_system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import typing as t
from pathlib import Path


def test_dialog_prompts_for_all_cookiecutter_variables(get_object, distro_loc):
"""Test Interactive Mode, prompts for all Cookiecutter Variables.

Verifies that when User runs Generator in Interactive Mode, they will be
prompted for all Cookiecutter Variables.

If any Cookiecutter Variable is not prompted for, the test will fail.
"""

# GIVEN the Cookiecutter Variables
cookie_json_file: Path = distro_loc / "cookiecutter.json"
assert cookie_json_file.exists(), f"File Not Found: {cookie_json_file}"
assert cookie_json_file.is_file(), f"Not a File: {cookie_json_file}"
import json

_cookie_vars: t.Iterable[str] = json.loads(cookie_json_file.read_text()).keys()

# GIVEN how the Interactive Dialogs produce the Context Variable Values
from cookiecutter_python.backend.pre_main import pre_main
from cookiecutter_python.backend.request import Request

# WHEN Context is created in Interactive Mode
def emulated_prompt(questionary_data: t.List[t.Mapping[str, t.Any]]):
"""Emulate the Dialog Prompt, and return the Context."""
# THEN Context contains all Cookiecutter Variables
assert {x['name'] for x in questionary_data} == (
set(_cookie_vars) - {'interpreters'}
).union(set(['supported-interpreters'])), (
f"Missing: {_cookie_vars - runtime_content.keys()}.\n"
"Dialog Prompts must be kept in sync with Cookiecutter Variables!\n\n"
"If missing variables from Dialog Prompts, this means that cookiecutter.json\n"
"got added new Variables, and the Dialogs need to be updated, to stay in sync.\n\n"
"Make sure Variables in src/cookiecutter_python/cookiecutter.json all have a"
"corresponding element (name), found in the dialog list passed in the prompt"
"of src/cookiecutter_python/handle/dialogs/lib/project_name.py.\n\n"
)
return {'supported-interpreters': []}

# Dynamic Import of dialogs.lib.project_name module and MonkeyPatch prompt
get_object(
'prompt',
'cookiecutter_python.handle.dialogs.lib.project_name',
overrides={'prompt': lambda: emulated_prompt},
)

context_res = pre_main(
Request(
config_file=None,
default_config=False,
web_servers=['pypi', 'readthedocs'],
no_input=False,
extra_context=None,
)
)

runtime_content = context_res.extra_context
assert runtime_content == {
'interpreters': {'supported-interpreters': []}
}, "Emulated function removed, but assertion was not updated. Update this line or emulated function to fix test logic."
Loading
Loading