Skip to content

Commit

Permalink
Merge pull request #20 from John-Robbins/semver-hah
Browse files Browse the repository at this point in the history
Upload action breaking change and skipping docs directory

- Added fix for actions/upload-artifact@v4 breaking change of not uploading hidden files. Closes #19.
- Added skipping docs directory for pushes and PRs. Closes #15.
- Also used a formatter extension in VS Code for YAML files.
  • Loading branch information
John-Robbins committed Sep 3, 2024
2 parents 717a8ae + 4e6b361 commit d36dad7
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 56 deletions.
119 changes: 63 additions & 56 deletions .github/workflows/Code-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ name: Code CI
on:
push:
branches: ["main"]
paths-ignore:
- docs/**
pull_request:
branches: ["main"]
paths-ignore:
- docs/**
# Allows you to run this workflow manually from the Actions tab, which is
# kind of important for developing this action as well as testing on any
# branch.
Expand All @@ -25,27 +29,27 @@ jobs:
name: "Type and Lint Checks"
runs-on: ubuntu-latest
steps:
# You have to love copying and pasting the same 11 lines into each job.
# I tried to make these a reusable job, but GitHub Actions wants to
# force you to ARY: Always Repeat Yourself. 😹😹
- name: "Checkout Code"
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: "Install Dependencies"
run: |
python -m pip install --upgrade pip
python -m pip install .[dev]
# The unique part starts here.
- name: "Check Types"
run: mypy --config-file pyproject.toml src/ tests/
- name: Ruff Lint
run: ruff check --config ./pyproject.toml src/ tests/
- name: Pylint Lint
run: pylint --rcfile pyproject.toml src/ tests/
# You have to love copying and pasting the same 11 lines into each job.
# I tried to make these a reusable job, but GitHub Actions wants to
# force you to ARY: Always Repeat Yourself. 😹😹
- name: "Checkout Code"
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: "Install Dependencies"
run: |
python -m pip install --upgrade pip
python -m pip install .[dev]
# The unique part starts here.
- name: "Check Types"
run: mypy --config-file pyproject.toml src/ tests/
- name: Ruff Lint
run: ruff check --config ./pyproject.toml src/ tests/
- name: Pylint Lint
run: pylint --rcfile pyproject.toml src/ tests/


test-cov-job:
Expand All @@ -71,46 +75,49 @@ jobs:
python -m pip install .[dev]
# The unique part of this job.
- name: "Test and Coverage"
# Generate the coverage data for this operating system.
# The default name for the file is ".coverage", which is the same for
# all operating systems and makes combining them later a little hard.
# This uses the COVERAGE_FILE environment variable to give each their
# own name.
# Generate the coverage data for this operating system.
# The default name for the file is ".coverage", which is the same for
# all operating systems and makes combining them later a little hard.
# This uses the COVERAGE_FILE environment variable to give each their
# own name.
env:
COVERAGE_FILE: ".coverage.${{ matrix.os }}"
run: |
coverage run -m pytest --maxfail=1 -console_output_style=classic --junit-xml=.test-results.xml
- name: "Count Unit Tests"
# Count the number of unit tests for the badge.
# Note, I had no idea bash could not handle spaces arounf the '=' in
# the export command.
# Count the number of unit tests for the badge.
# Note, I had no idea bash could not handle spaces around the '=' in
# the export command.
if: runner.os == 'Linux'
run: |
export TOTAL_UNIT_TESTS=$(python ./tools/num_pytest_tests.py .test-results.xml)
echo "total_unit_tests=$TOTAL_UNIT_TESTS" >> $GITHUB_ENV
echo "## Total Unit Tests: :trophy: ${TOTAL_UNIT_TESTS} :1st_place_medal:" >> $GITHUB_STEP_SUMMARY
- name: "Make Unit Tests Badge"
# The unit test badge is only updated on tbp and for the main branch.
# The unit test badge is only updated on tbp and for the main branch.
if: runner.os == 'Linux' && (github.repository == 'John-Robbins/tbp') && (github.ref == 'refs/heads/main')
# https://gist.github.com/John-Robbins/bd5e145f62ac1cf199a458977b8e1f16
# https://gist.github.com/John-Robbins/bd5e145f62ac1cf199a458977b8e1f16
uses: schneegans/dynamic-badges-action@v1.7.0
with:
# GIST_BADGES_SECRET is a GitHub personal access token with scope "gist".
auth: ${{ secrets.GIST_BADGES_SECRET }}
gistID: bd5e145f62ac1cf199a458977b8e1f16
filename: unittestsbadge.json
label: Unit Tests
message: ${{ env.total_unit_tests }}
minColorRange: 200
maxColorRange: 290
valColorRange: ${{ env.total_unit_tests }}
style: "flat-square"
# GIST_BADGES_SECRET is a GitHub personal access token with scope "gist".
auth: ${{ secrets.GIST_BADGES_SECRET }}
gistID: bd5e145f62ac1cf199a458977b8e1f16
filename: unittestsbadge.json
label: Unit Tests
message: ${{ env.total_unit_tests }}
minColorRange: 200
maxColorRange: 290
valColorRange: ${{ env.total_unit_tests }}
style: "flat-square"
- name: "Upload Coverage Data"
# Upload the coverage data for the coverage-job
# Upload the coverage data for the coverage-job
uses: actions/upload-artifact@v4
with:
name: covdata-${{ matrix.os }}
path: .coverage*
# Loved the breaking change on 2024/09/02 without a major update.
# https://github.com/actions/upload-artifact/issues/602
include-hidden-files: true


cov-report-job:
Expand All @@ -132,13 +139,13 @@ jobs:
python -m pip install .[dev]
# The unique part of this job.
- name: "Download Coverage Data"
# Gather all those operating system coverage files.
# Gather all those operating system coverage files.
uses: actions/download-artifact@v4
with:
pattern: covdata-*
merge-multiple: true
- name: "Combine and Report"
# Get the code coverage data.
# Get the code coverage data.
run: |
coverage combine
coverage report --precision=2 --show-missing --sort=Cover --skip-covered
Expand All @@ -147,19 +154,19 @@ jobs:
echo "total_coverage=$TOTAL_COVERAGE" >> $GITHUB_ENV
echo "## Total coverage: :fire: ${TOTAL_COVERAGE}% :fireworks:" >> $GITHUB_STEP_SUMMARY
- name: "Make Coverage Badge"
# Code coverage is only updated on tbp and the main branch.
# Code coverage is only updated on tbp and the main branch.
if: (github.repository == 'John-Robbins/tbp') && (github.ref == 'refs/heads/main')
# https://gist.github.com/John-Robbins/bd5e145f62ac1cf199a458977b8e1f16
# https://gist.github.com/John-Robbins/bd5e145f62ac1cf199a458977b8e1f16
uses: schneegans/dynamic-badges-action@v1.7.0
with:
# GIST_BADGES_SECRET is a GitHub personal access token with scope "gist".
auth: ${{ secrets.GIST_BADGES_SECRET }}
gistID: bd5e145f62ac1cf199a458977b8e1f16
filename: covbadge.json
label: Coverage
message: ${{ env.total_coverage }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total_coverage }}
style: "flat-square"
# GIST_BADGES_SECRET is a GitHub personal access token with scope "gist".
auth: ${{ secrets.GIST_BADGES_SECRET }}
gistID: bd5e145f62ac1cf199a458977b8e1f16
filename: covbadge.json
label: Coverage
message: ${{ env.total_coverage }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total_coverage }}
style: "flat-square"

6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"areg",
"astprinter",
"Bachchan",
"Batchelder",
"Belenko",
"callstack",
"capsys",
Expand All @@ -43,6 +44,8 @@
"clearend",
"clearendgotogosubifinputletlistprintprreturnrunthenrndusr",
"Comaneci",
"covbadge",
"covdata",
"Cruzeiero",
"democracia",
"Diffie",
Expand Down Expand Up @@ -95,6 +98,8 @@
"Rodovia",
"Sagarmath",
"savefile",
"schneegans",
"scriv",
"Shavarsh",
"SHORTHELP",
"somefile",
Expand All @@ -103,6 +108,7 @@
"Thorbjörn",
"TICTACTOE",
"transición",
"unittestsbadge",
"VARESIO",
"Viktor",
"Wran",
Expand Down

0 comments on commit d36dad7

Please sign in to comment.