Repository: thomasjahoda/cookiecutter_project_upgrader (language: python)

Issue:
Migrate to GitHub Actions



Discussion / hints:
# [Codecov](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4?src=pr&el=h1) Report
> Merging [#4](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4?src=pr&el=desc) (48a551c) into [master](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/commit/b147ad9db69c63f98c765fda455c78af4b5e3ee0?el=desc) (b147ad9) will **increase** coverage by `0.09%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4/graphs/tree.svg?width=650&height=150&src=pr&token=gX2jVN43UP)](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master       #4      +/-   ##
==========================================
+ Coverage   94.21%   94.30%   +0.09%     
==========================================
  Files           2        3       +1     
  Lines         121      123       +2     
==========================================
+ Hits          114      116       +2     
  Misses          7        7              
```


| [Impacted Files](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [tests/\_\_init\_\_.py](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4/diff?src=pr&el=tree#diff-dGVzdHMvX19pbml0X18ucHk=) | `100.00% <0.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4?src=pr&el=footer). Last update [b147ad9...48a551c](https://codecov.io/gh/thomasjahoda/cookiecutter_project_upgrader/pull/4?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@ddelange I've made you an owner (not just maintainer) of the pypi project and generated an API token with upload-permissions. I've added the API token to https://github.com/thomasjahoda/cookiecutter_project_upgrader/settings/environments/218629185/edit
Thanks for maintaining this repo and sorry for the late answer.
(I didn't really like to enter my PyPI credentials, as they could be extracted using an malicious workflow and an API token should be enough)
Hey @thomasjahoda, don't worry about the late response!

Yes I understand no user/pass credentials of course! As I can't view settings page of this github repo:
- did you add your api token as the PYPI_PASSWORD secret?
- in which case, can you also add `__token__` as the PYPI_USERNAME secret?

If that's what you already did, feel free to merge!

Thanks again

Fix patch:
diff --git a/Makefile b/Makefile
index 56d54b5..593178c 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@ flake8: ## check style with flake8 (lint)
 	flake8 cookiecutter_project_upgrader tests --max-line-length=120
 
 mypy: ## check types with mypy
-	mypy cookiecutter_project_upgrader tests
+	mypy cookiecutter_project_upgrader tests/__init__.py  tests/files.py  tests/test_cli.py  tests/test_logic.py  tests/tmp_files.py
 
 test: ## run all tests with the current python env
 	pytest
diff --git a/README.rst b/README.rst
index 7b3409b..6b2f3d7 100644
--- a/README.rst
+++ b/README.rst
@@ -6,9 +6,9 @@ Cookiecutter Project Upgrader
 .. image:: https://img.shields.io/pypi/v/cookiecutter_project_upgrader.svg
   :target: https://pypi.python.org/pypi/cookiecutter_project_upgrader
 
-.. image:: https://travis-ci.org/thomasjahoda/cookiecutter_project_upgrader.svg?branch=master
-  :target: https://travis-ci.org/thomasjahoda/cookiecutter_project_upgrader
-  :alt: CI Status
+.. image:: https://github.com/thomasjahoda/cookiecutter_project_upgrader/actions/workflows/CI.yml/badge.svg?branch=master
+  :target: https://github.com/thomasjahoda/cookiecutter_project_upgrader/actions/workflows/CI.yml
+  :alt: CI Status - master
 
 .. image:: https://readthedocs.org/projects/cookiecutter-project-upgrader/badge/?version=latest
   :target: https://cookiecutter-project-upgrader.readthedocs.io/en/latest/?badge=latest
@@ -47,8 +47,8 @@ Options:
   -b, --branch TEXT               Default: cookiecutter-template
   -u, --upgrade-branch TEXT       Optional branch name of cookiecutter
                                   template to checkout before upgrading.
-                                  
-  -f, --zip-file TEXT             Zip file Path/URL for Cookiecutter templates.                                  
+
+  -f, --zip-file TEXT             Zip file Path/URL for Cookiecutter templates.
 
   -i, --interactive               Enter interactive mode. Default behaviour:
                                   skip questions, use defaults.
diff --git a/dev-util/initial.py b/dev-util/initial.py
index da6c170..ad850e0 100755
--- a/dev-util/initial.py
+++ b/dev-util/initial.py
@@ -1,17 +1,15 @@
 """
 Script to execute after creating the project.
-- Encrypts the PyPi password to the .travis.yml
 - Updates PyCharm configuration if detected
 -- Sets the test runner to pytest
 -- Excludes cache directories
 """
 
-import configparser
 import subprocess
+import xml.etree.ElementTree as ElementTree
 from dataclasses import dataclass
 from pathlib import Path
-from typing import Tuple, cast, Dict, Optional
-import xml.etree.ElementTree as ElementTree
+from typing import cast, Dict
 
 try:
     import yaml
@@ -24,72 +22,6 @@
         raise Exception(
             "Could not install pyyaml automatically successfully, please install it manually first") from error
 
-TRAVIS_YML_FILE = Path("../.travis.yml").expanduser()
-TRAVIS_YML_ENCRYPTED_PASSWORD_PLACEHOLDER_VALUE = "PLEASE_REPLACE_ME"
-
-
-def encrypt_pypi_password_for_travis_if_necessary():
-    travis_yml_content = yaml.safe_load(TRAVIS_YML_FILE.read_text(encoding="utf-8"))
-    deploy_job = travis_yml_content["jobs"]["include"][-1]
-    if deploy_job["stage"] == "deploy":
-        project_owner_pypi_username = deploy_job["deploy"]["user"]
-        project_owner_pypi_encrypted_password = deploy_job["deploy"]["password"]["secure"]
-        if project_owner_pypi_encrypted_password == TRAVIS_YML_ENCRYPTED_PASSWORD_PLACEHOLDER_VALUE:
-            _encrypt_pypi_password_for_travis(project_owner_pypi_username)
-        else:
-            print(f"Travis password has already been encrypted in {TRAVIS_YML_FILE.name}.")
-    else:
-        print("Travis is not deploying to PyPi, skipping check for PyPi credentials")
-
-
-def _encrypt_pypi_password_for_travis(project_owner_pypi_username: str):
-    pypi_username, pypi_password = _get_pypi_credentials()
-    if pypi_username != project_owner_pypi_username:
-        raise Exception(f"The PyPi password for Travis has not yet been configured but "
-                        f"the local pypi credentials' username ({pypi_username}) "
-                        f"does not match the pypi username stated "
-                        f"in {TRAVIS_YML_FILE.name} ({project_owner_pypi_username}). "
-                        f"Please check your ~/.pypirc file or your keyring properties for pypi.")
-    try:
-        result = subprocess.run(
-            ["travis", "encrypt", "--skip-version-check", "--skip-completion-check", "--no-interactive"],
-            input=bytes(pypi_password, encoding="utf-8"),
-            capture_output=True,
-        )
-    except FileNotFoundError as exception:
-        raise Exception("Command 'travis' needs to be available on path. "
-                        "Please install https://github.com/travis-ci/travis.rb#installation") from exception
-    result.check_returncode()
-    output = str(result.stdout, encoding="utf-8")
-    encrypted_password = output[1:-2]
-
-    travis_yml_text = TRAVIS_YML_FILE.read_text(encoding="utf-8")
-    travis_yml_text = travis_yml_text.replace(TRAVIS_YML_ENCRYPTED_PASSWORD_PLACEHOLDER_VALUE, encrypted_password)
-    TRAVIS_YML_FILE.write_text(travis_yml_text, encoding="utf-8")
-    print(f"Updated {TRAVIS_YML_FILE.name} with encrypted pypi password. Please commit it in Git.")
-
-
-def _get_pypi_credentials() -> Tuple[str, str]:
-    pypirc_file = Path("~/.pypirc").expanduser()
-    if pypirc_file.is_file():
-        config = configparser.ConfigParser()
-        config.read(pypirc_file)
-        pypi_username = config['pypi']['username']
-        pypi_password = config['pypi']['password']
-        print(f"Using pypi credentials found in {pypirc_file}")
-        return pypi_username, pypi_password
-    else:
-        # TODO check keyring if pypi credentials are there in case ~/.pypirc does not exist.
-        #  https://twine.readthedocs.io/en/latest/#id6
-        raise Exception("Please create the file ~/.pypirc with your pypi user credentials as documented at "
-                        "https://packaging.python.org/guides/distributing-packages-using-setuptools/#id78\n"
-                        "Support for the Keyring credentials as documented at "
-                        "https://twine.readthedocs.io/en/latest/#id6 is currently unsupported but contributing "
-                        "is wished.")
-
-
-encrypt_pypi_password_for_travis_if_necessary()
-
 
 def _get_project_name():
     return cast(Path, Path.cwd()).parent.name


Test patch:
diff --git a/tests/test_logic.py b/tests/test_logic.py
index ff20ab2..313b25a 100644
--- a/tests/test_logic.py
+++ b/tests/test_logic.py
@@ -99,7 +99,7 @@ def test_first_run_creates_branch_on_first_commit_and_updates_based_on_template(
     cookiecutter_template_directory.joinpath("{{cookiecutter.project_slug}}", ".file_with_dot.txt") \
         .write_text("updated content")
     new_template_file_with_dot_at_start = cookiecutter_template_directory.joinpath("{{cookiecutter.project_slug}}",
-                                                                                   ".travis.yml")
+                                                                                   "some_new_file")
     new_template_file_with_dot_at_start.touch()
     new_template_file_with_dot_at_start.write_text("new file text")
     subprocess.run(["git", "add", "-A"], cwd=str(cookiecutter_template_directory), check=True)
@@ -115,7 +115,7 @@ def test_first_run_creates_branch_on_first_commit_and_updates_based_on_template(
 
     assert project_directory.joinpath(".file_with_dot.txt").read_text(encoding="utf-8") == "updated content"
 
-    project_new_file = project_directory.joinpath(".travis.yml")
+    project_new_file = project_directory.joinpath("some_new_file")
     assert project_new_file.exists()
     assert project_new_file.read_text(encoding="utf-8") == "new file text"