Skip to content

Commit

Permalink
Switch to composite action (#4)
Browse files Browse the repository at this point in the history
* switch to composite action
* migrate to pyproject.toml
* add pre-commit config and use it in CI
* add unit testing and type checking
* use windows CI runner for accurate testing
* add .gitattributes & allow crlf in demo test files
  • Loading branch information
2bndy5 authored Sep 29, 2023
1 parent 7c7f5db commit 791b892
Show file tree
Hide file tree
Showing 21 changed files with 265 additions and 143 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Prevent line ending conversions by default to avoid problems with binary files.
* -text

# Known text files should have LF line endings.
*.py text eol=lf
*.rst text eol=lf
*.toml text eol=lf
LICENSE text eol=lf
tests/demo_project/RMSKIN.ini text eol=crlf
38 changes: 25 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Python_pkg:
runs-on: ubuntu-latest
Python:
runs-on: windows-latest
steps:
- name: Checkout this Repo
uses: actions/checkout@v4
Expand All @@ -23,14 +23,29 @@ jobs:
with:
python-version: 3.x

- name: Install Dependencies
- name: Install Workflow Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install --upgrade setuptools wheel twine pylint
python -m pip install build twine pre-commit -r tests/requirements.txt -r requirements.txt
python -m build
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit_${{ hashFiles('.pre-commit-config.yaml') }}

- name: Check formatting
run: pylint rmskin_builder.py
run: pre-commit run --all-files

- name: Get test coverage
run: |
coverage run -m pytest
coverage html
echo "$(coverage report --format markdown)" >> $GITHUB_STEP_SUMMARY
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: twine Check
run: |
Expand All @@ -45,7 +60,8 @@ jobs:
run: twine upload dist/*

Build:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_name == 'master'
runs-on: windows-latest
steps:
- name: Checkout this Repo
uses: actions/checkout@v4
Expand All @@ -55,11 +71,7 @@ jobs:
id: builder
uses: 2bndy5/rmskin-action@master
with:
path: tests

# # print contents of GITHUB_WORKSPACE dir
# - name: verify contents
# run: ls "${{ github.workspace }}"
path: tests/demo_project

# Use the output from the `builder` step
- name: Print the output filename
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ dmypy.json
# Pyre type checker
.pyre/

# ruff linter
.ruff_cache/

# vscode folder
.vscode/

Expand Down
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- id: mixed-line-ending
args: ['--fix=lf']
exclude: "tests/demo_project"
- id: requirements-txt-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
additional_dependencies: ['types-Pillow']
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:alt: latest version on PyPI
.. image:: https://static.pepy.tech/personalized-badge/rmskin-builder?period=total&units=international_system&left_color=grey&right_color=blue&left_text=PyPi%20Downloads
:target: https://pepy.tech/project/rmskin-builder
:alt: pepy stats
:alt: pipy download stats

rmskin-action
=============
Expand All @@ -24,7 +24,7 @@ rmskin-builder Python package

This action's *rmskin-builder.py* is now also available as a Python executable script via PyPI.
However, it is important that your Python installation's *Scripts* folder is found in your
Operating System's environment variable ``PATH``. If you're using a Python virtual envirnment,
Operating System's environment variable ``PATH``. If you're using a Python virtual environment,
then the *Scripts* folder does not need to be in your Operating System's environment variable
``PATH``.

Expand Down
98 changes: 56 additions & 42 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,56 @@
name: rmskin-build
description: packaging tool for Rainmeter User Content

# for the badge
branding:
icon: 'droplet'

inputs:
version: # 'auto'
description: "Version of the Rainmeter rmskin package. Defaults to last 8 digits of SHA from commit or reference tags."
required: false
default: 'auto'
title: # 'repo-name'
description: "Name of the Rainmeter rmskin package. Defaults name of repository."
required: false
default: ${{ github.event.repository.name }}
author: # 'repo-owner'
description: "Account Username maintaining the rmskin package. Defaults to Username that triggered the commit."
required: false
default: ${{ github.repository_owner }}
path: # '.'
description: "Base directory of repo being packaged. Defaults to workflow's workspace path"
required: false
default: "/github/workspace"
dir_out: # '.'
description: "Path to save generated rmskin package. Defaults to workflow's workspace path"
required: false
default: "/github/workspace"

outputs:
arc_name: # path to & name of archive file that was generated
description: "name of rmskin file"

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.path }}
- ${{ inputs.version }}
- ${{ inputs.author }}
- ${{ inputs.title }}
- ${{ inputs.dir_out }}
name: rmskin-build
description: packaging tool for Rainmeter User Content

# for the badge
branding:
icon: 'droplet'

inputs:
version: # 'auto'
description: "Version of the Rainmeter rmskin package. Defaults to last 8 digits of SHA from commit or reference tags."
required: false
default: 'auto'
title: # 'repo-name'
description: "Name of the Rainmeter rmskin package. Defaults name of repository."
required: false
default: ${{ github.event.repository.name }}
author: # 'repo-owner'
description: "Account Username maintaining the rmskin package. Defaults to Username that triggered the commit."
required: false
default: ${{ github.repository_owner }}
path: # '.'
description: "Base directory of repo being packaged. Defaults to workflow's workspace path"
required: false
default: "/github/workspace"
dir_out: # '.'
description: "Path to save generated rmskin package. Defaults to workflow's workspace path"
required: false
default: "/github/workspace"

outputs:
arc_name: # path to & name of archive file that was generated
description: "name of rmskin file"
value: ${{ steps.rmskin-builder.outputs.arc_name }}

runs:
using: 'composite'
steps:
- name: setup-python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.x
update-environment: false
- name: Install rmskin-builder
shell: bash
run: ${{ steps.setup-python.outputs.python-path }} -m pip install rmskin-builder
- name: Run rmskin-builder
id: rmskin-builder
shell: bash
run: >-
rmskin-builder
--path "${{ inputs.path }}"
--version "${{ inputs.version }}"
--author "${{ inputs.author }}"
--title "${{ inputs.title }}"
--dir_out "${{ inputs.dir_out }}"
4 changes: 0 additions & 4 deletions enter_rmskin_builder.sh

This file was deleted.

58 changes: 58 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[build-system]
requires = ["setuptools>=61", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "rmskin-builder"
description = "A script that will attempt to assemble a validating Rainmeter skin package for quick and easy distribution on Github."
readme = "README.rst"
keywords = ["rainmeter", "rainmeter-skin", "packaging"]
license = {text = "MIT License"}
authors = [
{ name = "Brendan Doherty", email = "[email protected]" },
]
classifiers = [
# https://pypi.org/pypi?%3Aaction=list_classifiers
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: System :: Archiving :: Packaging",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
]
dynamic = ["version", "dependencies"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[project.scripts]
rmskin-builder = "rmskin_builder:main"

[project.urls]
source = "https://github.com/2bndy5/rmskin-builder"
tracker = "https://github.com/2bndy5/rmskin-builder/issues"

# ... other project metadata fields as specified in:
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

[tool.setuptools]
py-modules = ["rmskin_builder"]

[tool.setuptools_scm]
# It would be nice to include the commit hash in the version, but that
# can't be done in a PEP 440-compatible way.
version_scheme= "no-guess-dev"
# Test PyPI does not support local versions.
local_scheme = "no-local-version"
fallback_version = "0.0.0"

[tool.mypy]
show_error_codes = true
show_column_numbers = true
ignore_missing_imports = true

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]

[tool.coverage.run]
source = ["rmskin_builder"]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# for detirmining if a .dll file is for 64-bit or 32-bit
pefile
# for verifying header image file and resizing it accordingly
pillow
pillow
Loading

0 comments on commit 791b892

Please sign in to comment.