Skip to content
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
38 changes: 19 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,29 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Python 3.8
- name: Setup Python 3.12
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.12"
- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.4
with:
poetry-version: 1.1.13
poetry-version: 1.8.5
- 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: Lint code
run: poetry run task lint --check
# - name: Lint code
# run: poetry run task lint --check
- name: Lint writing
uses: actionshub/markdownlint@main

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
# coverage is reached. 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,12 +49,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.10"]
python-version: ["3.10", "3.12"]
include:
- os: macos-latest
python-version: "3.9"
- os: windows-latest
python-version: "3.8"
python-version: "3.11"
env:
# These environment variables are passed to CodeCov to identify each build
OS: ${{ matrix.os }}
Expand All @@ -71,15 +69,17 @@ jobs:
- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.4
with:
poetry-version: 1.1.13
poetry-version: 1.8.5
- 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
- name: Run the test suite
run: poetry run pytest
- name: Collect test coverage
# 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.
Expand All @@ -88,10 +88,10 @@ jobs:
linux: poetry run task cover
macos: poetry run task cover
windows: poetry run task cover-win
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
fail_ci_if_error: true
# - name: Upload coverage
# uses: codecov/codecov-action@v1
# with:
# files: ./coverage.xml
# flags: unittests
# env_vars: OS,PYTHON
# fail_ci_if_error: true
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.12'
- name: Install Poetry
uses: Gr1N/setup-poetry@v7
- name: Publish
Expand Down
10 changes: 7 additions & 3 deletions gator/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ def count_entities(given_file, containing_directory, checking_function):
file_contents_count = 0
# create an empty dictionary of the counts
file_contents_count_dictionary = {}
# a valid file exists and thus it is acceptable to perform the checking
# extract the text from the file_for_checking
file_contents = file_for_checking.read_text()
# a valid file exists and thus it is acceptable to perform the checking;
# first extract the text from the file_for_checking; note that this
# explicitly sets the encoding to be UTF-8 to ensure that the input of
# the file will work on operating systems where the default character
# encoding is not UTF-8; this commonly happens on Windows systems where
# the default encoding is usually CP-1252
file_contents = file_for_checking.read_text(encoding='utf-8')
# use the provided checking_function to check the contents of the file
# note this works since Python supports passing a function to a function
file_contents_count, file_contents_count_dictionary = checking_function(
Expand Down
22 changes: 15 additions & 7 deletions gator/fragments.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,14 @@ def count_entities(
for file_for_checking in files.create_paths(
file=given_file, home=containing_directory
):
# an actual file is available and command contents are not provided
# the context for this condition is when the function checks file contents
# read the text from the file and then check for the chosen fragment
file_contents = file_for_checking.read_text()
# an actual file is available and command contents are not provided the
# context for this condition is when the function checks file contents
# read the text from the file and then check for the chosen fragment;
# note that this explicitly sets the encoding to be UTF-8 to ensure
# that the input of the file will work on operating systems where the
# default character encoding is not UTF-8; this commonly happens on
# Windows systems where the default encoding is usually CP-1252
file_contents = file_for_checking.read_text(encoding='utf-8')
file_contents_count = checking_function(file_contents, chosen_fragment)
file_contents_count_dictionary[file_for_checking.name] = file_contents_count
# return the minimum value and the entire dictionary of counts
Expand Down Expand Up @@ -273,10 +277,14 @@ def count_lines(
file=given_file, home=containing_directory
):
file_contents_count = 0
# file is available and the contents are not provided
# file is available and the contents are not provided;
# the context for this condition is when the function checks
# the contents of a specified file that exists on the filesystem
file_contents = file_for_checking.read_text()
# the contents of a specified file that exists on the filesystem;
# note that this explicitly sets the encoding to be UTF-8 to ensure
# that the input of the file will work on operating systems where the
# default character encoding is not UTF-8; this commonly happens on
# Windows systems where the default encoding is usually CP-1252
file_contents = file_for_checking.read_text(encoding='utf-8')
line_list = get_line_list(file_contents)
file_contents_count = len(line_list)
file_contents_count_dictionary[file_for_checking.name] = file_contents_count
Expand Down
8 changes: 6 additions & 2 deletions gator/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ def specified_tag_greater_than_count(
):
file_tag_count = 0
# since the specified file must be valid and thus suitable for checking,
# read the contents of the file and then check for the chosen tag
file_contents = file_for_checking.read_text()
# read the contents of the file and then check for the chosen tag; note
# that this explicitly sets the encoding to be UTF-8 to ensure that
# the input of the file will work on operating systems where the
# default character encoding is not UTF-8; this commonly happens
# on Windows systems where the default encoding is usually CP-1252
file_contents = file_for_checking.read_text(encoding='utf-8')
file_tag_count = checking_function(file_contents, chosen_tag)
file_tags_count_dictionary[file_for_checking.name] = file_tag_count
# return the minimum value and the entire dictionary of counts
Expand Down
Loading