Skip to content

Commit

Permalink
NASA-AMMOS/slim#69 NASA-AMMOS/slim#110: Update publish action to alig…
Browse files Browse the repository at this point in the history
…n with structure of other similar configs; Minor code changes in response to static analysis…
  • Loading branch information
ingyhere committed Mar 15, 2024
1 parent 82f07b9 commit 5442d88
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
29 changes: 20 additions & 9 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# This workflows will upload a Python Package using Twine when a release is created
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# For more information see:
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package
# https://nasa-ammos.github.io/slim/docs/guides/software-lifecycle/application-starter-kits/python-starter-kit/
#
# ******** NOTE ********
# This file publishes to TestPyPi. To enable public PyPi the repository flag
# must be removed from the Twine upload call in the "Publish package" block.
#
name: "Upload Python Package"

on:
release:
types: [published]
branches: [main]
types: [published]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.10'
- name: Upgrade tooling
run: |
python3 -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion slim_sample_project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
from .version import __version__


ignore = True
IGNORE = True
2 changes: 1 addition & 1 deletion slim_sample_project/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Sample code: REPLACE with project code.
ignore = False
IGNORE = False
13 changes: 11 additions & 2 deletions slim_sample_project/api/text_processor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Sample code: REPLACE with project code.
from colorama import Fore, Back, Style
from random import randint

from colorama import Fore, Back, Style


class TextWriter:
"""
Expand Down Expand Up @@ -29,8 +30,16 @@ def out(self, text):
"""
Output writer to apply color settings to terminal text.
:param text: The value to write to a string.
:type text: Any type that supports an internal str reporesentation.
:type text: Any type that supports an internal str representation.
"""
if not text:
text = "Hello World"
print(self.color, self.bg, self.style, str(text), Style.RESET_ALL)

def __str__(self):
"""
Override default str method to return a string representation of the text properties.
@return: str representing class instance text properties
"""
desc = f"color: {self.color}, background: {self.bg}, style: {self.style}"
return desc
4 changes: 2 additions & 2 deletions slim_sample_project/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

from api.text_processor import TextWriter
from version_tooling import version
from version_tooling import VERSION


def main():
Expand All @@ -12,7 +12,7 @@ def main():
"""
w = TextWriter()
w.out("Hello World!")
w.out(version)
w.out(VERSION)
print("EXITING!")
sys.exit(os.EX_OK)

Expand Down
5 changes: 2 additions & 3 deletions slim_sample_project/version_tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import version as v

try:
version = metadata.version(__name__)
VERSION = metadata.version(__name__)
except metadata.PackageNotFoundError:
# package is not installed, try reading from slim_sample_project script
version = v.__version__ if v.__version__ else "unset"
pass
VERSION = v.__version__ if v.__version__ else "unset"

0 comments on commit 5442d88

Please sign in to comment.