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

feat: add automatic publishing using version tags, lint, and update workflows #253

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
57b0786
feat: add test_publish.yml file for automatic test publishing with th…
PCain02 Oct 29, 2024
c0ee5aa
feat: add tag_publish.yml file for automatic test publishing with the…
PCain02 Oct 29, 2024
4e8e579
fix: typo in tag publish.yml
PCain02 Oct 29, 2024
e9addeb
test: test-publish
PCain02 Oct 29, 2024
311ac19
fix: add pyyaml to toml to test test-publish
PCain02 Oct 29, 2024
098bc1e
update dependancies and test-publish
PCain02 Oct 29, 2024
64bdae5
update poetry version hoping to fix linting errors
PCain02 Oct 29, 2024
b81312f
update main.yml poetry version and python version
PCain02 Oct 29, 2024
08f1ed3
update toml version for test publish
PCain02 Oct 29, 2024
3693ed8
feat: update coverage process in main.yml
PCain02 Oct 30, 2024
a72cabb
feat: update coverage process to check for xml file
PCain02 Oct 30, 2024
3c64620
feat: update coverage process to check for xml file
PCain02 Oct 30, 2024
7ead445
feat: update toml for coverage
PCain02 Oct 30, 2024
069574c
fix: change coverage workflow
PCain02 Nov 12, 2024
dca7ac7
fix: coverage report
PCain02 Nov 12, 2024
7bd4b67
test: delete upload coverage
PCain02 Nov 12, 2024
c52fdc4
fix add utf-8 to test_orchestrate
PCain02 Nov 12, 2024
89adf89
fix add utf-8 to test_orchestrate
PCain02 Nov 12, 2024
a950eef
fix add utf-8 to test_orchestrate
PCain02 Nov 12, 2024
30ab816
lint: lint code
PCain02 Nov 12, 2024
ffd2fd3
lint: fix newline
PCain02 Nov 12, 2024
fa6fabe
lint files
PCain02 Nov 12, 2024
38c2c81
lint: report and checkers
PCain02 Nov 12, 2024
9cb1bd9
lint: black formating test_orchestrate and report
PCain02 Nov 12, 2024
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
30 changes: 9 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.13
poetry-version: 1.5.1
- name: Setup Poetry
run: |
poetry config virtualenvs.create true
Expand All @@ -38,8 +38,8 @@ jobs:
test:
# Test uses a strategy matrix to ensure that sufficient platform test
# coverage is reached. For this configuration, we run the latest Ubuntu
# image with Python 3.6 and 3.9, while also including MacOS + Python 3.8 and
# Windows + Python 3.7. With this spread, we achieve testing of four
# image with Python 3.8 and 3.10, while also including MacOS + Python 3.9 and
# Windows + Python 3.8. With this spread, we achieve testing of four
# different Python versions and three operating systems without running the
# full twelve possible combinations, greatly reducing load and usage.
name: Test
Expand All @@ -51,7 +51,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.10"]
python-version: ["3.8", "3.10"]
include:
- os: macos-latest
python-version: "3.9"
Expand All @@ -71,27 +71,15 @@ jobs:
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.13
poetry-version: 1.5.1
- name: Setup Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry env info
- name: Install dependencies
run: poetry install --no-interaction --no-ansi
- name: Execute tests
# We need to ensure that the cover-win script is run for Windows, so
# this Action runs different commands based on the runner's operating
# system.
uses: knicknic/os-specific-run@v1
with:
linux: poetry run task cover
macos: poetry run task cover
windows: poetry run task cover-win
- name: Upload coverage
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to find a way to upload coverage properly.

uses: codecov/codecov-action@v1
with:
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
fail_ci_if_error: true
- name: Run Tests and Generate Coverage
run: |
poetry run pytest -s --cov=gator --cov-report xml:coverage.xml
ls -l coverage.xml
57 changes: 57 additions & 0 deletions .github/workflows/tag_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Publishing workflow

name: Publish

# Use more columns for terminal output
env:
COLUMNS: 120
PYTHONIOENCODING: utf8

# trigger the publishing of the
# gatorgrader package to PyPI
# with any tag starting with 'v'
on:
push:
tags:
- 'v*'

# Create one single job
# that publishes the package
# to PyPI using Poetry

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
poetry install
- name: Configure Poetry for PyPI
run: |
poetry config repositories.pypi https://upload.pypi.org/legacy/
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
- name: Publish package to PyPI
run: |
poetry publish --repository pypi --build
- name: Check for Successful Publication
run: |
version=$(poetry version --short)
echo "Checking if package gatorgrader version $version is available on PyPI..."
response=$(curl -s "https://pypi.org/pypi/gatorgrader/$version/json")
if echo "$response" | grep -q "$version"; then
echo "Package gatorgrader version $version is successfully published on PyPI."
else
echo "Package gatorgrader version $version was not found on PyPI."
exit 1
fi

60 changes: 60 additions & 0 deletions .github/workflows/test_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Test Publishing workflow
name: Test Publish

# Use more columns for terminal output
env:
COLUMNS: 120
PYTHONIOENCODING: utf8

# trigger the test publishing of the
# gatorgrader package to PyPI
# with any tag starting with 't'
on:
push:
tags:
- 't*'

# Create one single job
# that test publishes the package
# to PyPI using Poetry
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '^3.11' # Use the Python version compatible with your project

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry install

- name: Configure Poetry for TestPyPI
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }}

- name: Publish package to TestPyPI
run: |
poetry publish --repository testpypi --build

- name: Check for Successful Publication
run: |
version=$(poetry version --short)
echo "Checking if package gatorgrader version $version is available on TestPyPI..."
response=$(curl -s "https://test.pypi.org/pypi/gatorgrader/$version/json")
if echo "$response" | grep -q "$version"; then
echo "Package gatorgrader version $version is successfully published on TestPyPI."
else
echo "Package gatorgrader version $version was not found on TestPyPI."
exit 1
fi
3 changes: 1 addition & 2 deletions gator/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ def load_check(checker_source, check_file):
"""Load the specified check from the source."""
if is_internal_check(check_file):
return importlib.import_module(checks.__name__ + "." + check_file)
else:
return checker_source.load_plugin(check_file)
return checker_source.load_plugin(check_file)


def get_source(checker_paths=[]):
Expand Down
2 changes: 1 addition & 1 deletion gator/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def set_result(description, outcome, diagnostic):
def get_result():
"""Return the result dictionary."""
# pylint: disable=global-statement
global result
global result # pylint: disable=W0602
return result


Expand Down
6 changes: 3 additions & 3 deletions gator/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def get_word_diagnostic(word_count_dictionary, equals_count=constants.markers.In
return paragraph_number_as_word_phrase, filename_for_paragraph_number_details
# --> Case: the equals_count is not invalid, so look "deeply" for the first value
# that is not equal to the provided value stored in equals_count
elif word_count_dictionary and equals_count is not constants.markers.Invalid:
if word_count_dictionary and equals_count is not constants.markers.Invalid:
paragraph_number_details_list = get_first_not_equal_value_deep(
word_count_dictionary, equals_count
)
Expand Down Expand Up @@ -295,10 +295,10 @@ def get_file_diagnostic_deep_exact(file_count_dictionary, value):
# this was a "non-deep" dictionary or there are no matching values. Try a non-deep
# search which will return (0, 0) when nothing is also found, thereby signalling
# that, in fact, there are no exact matches in the data set.
if file_details == {}:
if file_details in ({}, (0, 0)):
file_details = get_first_not_equal_value(file_count_dictionary, value)
# there is some type of exact match in the data set, so extract and return it
if file_details != {} and file_details != (0, 0):
if file_details not in ({}, (0, 0)):
file_name = file_details[0]
file_count = file_details[1][1]
file_name_phrase = (
Expand Down
Loading