Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
k2bd committed Dec 4, 2021
0 parents commit f7099f4
Show file tree
Hide file tree
Showing 17 changed files with 991 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 88
extend-ignore = E203, W503
per-file-ignores = __init__.py:F401
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI
on: [push]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9"]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/[email protected]
with:
poetry-version: 1.1.4
- name: Install project
run: poetry install
- name: Lint
run: poetry run poe lint
- name: Test
run: poetry run poe test
- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: true
12 changes: 12 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Test action
on:
workflow_dispatch:

jobs:
action-python-poetry:
runs-on: ubuntu-latest
steps:
- uses: ./ # Test against the repo's copy of the action
with:
helloName: k2bd
repeats: 3
13 changes: 13 additions & 0 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Keep the versions up-to-date

on:
release:
types: [published, edited]

jobs:
actions-tagger:
runs-on: windows-latest
steps:
- uses: Actions-R-Us/actions-tagger@latest
with:
publish_latest_tag: true
146 changes: 146 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
node_modules
.serverless

.vscode/
.devcontainer

*.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
2 changes: 2 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.9

ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1

RUN pip install "poetry==1.1.11"

COPY poetry.lock pyproject.toml ./
RUN poetry install --no-dev

COPY . .
RUN poetry build && pip install dist/*.whl

CMD ["python", "-m", "action_python_poetry"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Kevin Duff ([k2bd](https://github.com/k2bd))

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Python + Poetry GitHub Action Template

## Getting started from the template
1. Globally replace instances of `action-python-poetry` and `action_python_poetry` with your project and package name.
1. Rename the package in `src/action_python_poetry` and update imports.
1. Setup your repo on [CodeCov](https://app.codecov.io/) and add a codecov token to your repo under the `CODECOV_TOKEN` secret.
1. Create and test your action. `__main__.py` will be executed when the action is run.
1. Update `action.yml`, `README.md`, and `.github/workflows/test-action.yml` to reflect the action's specification.
1. Remove this section from `README.md`.
1. Update the copyright notice and permissions stuff in `LICENSE`, making sure to retain the original text of both in your distribution according to the MIT license that this template is distributed under.
1. Happy hacking!

### Like this template?
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/purple_img.png)](https://www.buymeacoffee.com/k2bd)

## Quickstart

```yml
name: Run Action
on:
workflow_dispatch:

jobs:
do-thing:
runs-on: ubuntu-latest
steps:
- uses: k2bd/action-python-poetry@v1
with:
helloName: k2bd
repeats: 3
```
## Action Specification
### `helloName`

**Required**

The name of the person to say hello to

### `repeats`

*Optional* - default 1

Number of times to say hello to this person

## Developing

Install [Poetry](https://python-poetry.org/) and `poetry install` the project

### Useful Commands

Note: if Poetry is managing a virtual environment for you, you may need to use `poetry run poe` instead of `poe`

- `poe autoformat` - Autoformat code
- `poe lint` - Linting
- `poe test` - Run Tests

### Testing the action

The action can be tested locally by building the Dockerfile, e.g. `docker run -e INPUT_HELLONAME=k2bd -e INPUT_REPEATS=2 $(docker build -q .)`

Additionally, there is a manual invocation action on the repo called "Test Action" that can be used to invoke the repo's version of the action from the Actions tab of the repo.

### Releasing

Release a new version by creating a new annotated semver tag e.g. `git tag -a v1.2.3 -m "Release version 1.2.3"` and pushing it (`git push --tags`). Then create a new release from that tag in GitHub.

There is an autoversioning action that keeps major version tags (`v1`, `v2`, ...) and `latest` up-to-date when a new release is published.
20 changes: 20 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "action-python-poetry"
author: your-name
description: >
A template action that says hello to you, potentially multiple times.
runs:
using: docker
image: Dockerfile
inputs:
helloName:
description: >
AoC user ID. See the README for instructions on getting this.
required: true
repeats:
description: >
Number of times to say hello
required: false
default: 1
branding:
icon: "gift"
color: "purple"
Loading

0 comments on commit f7099f4

Please sign in to comment.