Skip to content

Commit

Permalink
Merge branch 'release/v20200411'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Apr 11, 2020
2 parents 41d7049 + b5b6a5c commit 02ae3ac
Show file tree
Hide file tree
Showing 13 changed files with 378 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
venv/
.git/
**/.pytest_cache/
*.pyc
**/__pycache__
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GITHUB_TOKEN
COVERALLS_REPO_TOKEN
28 changes: 28 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: push
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1

- name: Unit tests
run: make test

- name: With GITHUB_TOKEN
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: With COVERALLS_REPO_TOKEN
uses: ./
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

- name: With GITHUB_TOKEN and COVERALLS_REPO_TOKEN
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
139 changes: 139 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# 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/
pip-wheel-metadata/
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/
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Container image that runs your code
FROM alpine:3.10
FROM python:3.8

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh
COPY src/ /src/
# TODO: use setup.py
RUN pip install coveralls

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
# Code file to execute when the docker container starts up (`entrypoint.py`)
ENTRYPOINT ["/src/entrypoint.py"]
63 changes: 63 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
VIRTUAL_ENV ?= venv
PYTHON_MAJOR_VERSION=3
PYTHON_MINOR_VERSION=8
PYTHON_VERSION=$(PYTHON_MAJOR_VERSION).$(PYTHON_MINOR_VERSION)
PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
PYTHON=$(VIRTUAL_ENV)/bin/python
PIP=$(VIRTUAL_ENV)/bin/pip
ISORT=$(VIRTUAL_ENV)/bin/isort
FLAKE8=$(VIRTUAL_ENV)/bin/flake8
PYTEST=$(VIRTUAL_ENV)/bin/pytest
COVERAGE=$(VIRTUAL_ENV)/bin/coverage
BLACK=$(VIRTUAL_ENV)/bin/black
SOURCES=src/ tests/
DOCKER_IMAGE_LINUX=andremiras/coveralls-python-action


$(VIRTUAL_ENV):
$(PYTHON_WITH_VERSION) -m venv $(VIRTUAL_ENV)
$(PIP) install --requirement requirements.txt

virtualenv: $(VIRTUAL_ENV)

run: virtualenv
$(PYTHON) src/entrypoint.py

pytest: virtualenv
PYTHONPATH=src/ $(COVERAGE) run --source src/ -m pytest tests/
$(COVERAGE) report -m

test: pytest lint

lint/isort: virtualenv
$(ISORT) --check-only --recursive --diff $(SOURCES)

lint/flake8: virtualenv
$(FLAKE8) $(SOURCES)

lint/black: virtualenv
$(BLACK) --check $(SOURCES)

lint: lint/isort lint/flake8 lint/black

format/isort: virtualenv
$(ISORT) --recursive $(SOURCES)

format/black: virtualenv
$(BLACK) $(SOURCES)

format: format/isort format/black

clean:
rm -rf .pytest_cache/
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type d -name "*.egg-info" -exec rm -r {} +

docker/build:
docker build --tag=$(DOCKER_IMAGE_LINUX) .

docker/run:
docker run -it --rm --env-file .env $(DOCKER_IMAGE_LINUX)

docker/run/shell:
docker run -it --rm --env-file .env --entrypoint /bin/sh $(DOCKER_IMAGE_LINUX)
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
# WIP coveralls-python-action
GitHub Action for Python Coveralls.io

# Hello world docker action

This action prints "Hello World" or "Hello" + the name of a person to greet to the log.

## Inputs
# coveralls-python-action

### `who-to-greet`
[![push](https://github.com/AndreMiras/coveralls-python-action/workflows/push/badge.svg?branch=develop)](https://github.com/AndreMiras/coveralls-python-action/actions?query=workflow%3Apush)

**Required** The name of the person to greet. Default `"World"`.

## Outputs

### `time`
GitHub Action for Python Coveralls.io

The time we greeted you.
## Usage
You simply need to set one of the following two environment variables:
- `GITHUB_TOKEN`
- `COVERALLS_REPO_TOKEN`

## Example usage

uses: actions/hello-world-docker-action@v1
with:
who-to-greet: 'Mona the Octocat'
Assuming you have a `make test` that runs coverage testing.
The following will upload it to coveralls.io.
```yml
name: push
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1

- name: Unit tests
run: make test

- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
14 changes: 2 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
name: 'Hello World'
description: 'Greet someone and record the time'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
name: 'Coveralls'
description: 'Reports to coveralls.io'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who-to-greet }}
5 changes: 0 additions & 5 deletions entrypoint.sh

This file was deleted.

5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
black
coveralls
flake8
isort
pytest
13 changes: 13 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-line-length = 88
extend-ignore = E203

[isort]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88

[coverage:run]
relative_files = True
Loading

0 comments on commit 02ae3ac

Please sign in to comment.