Skip to content

Commit

Permalink
feat: Use composite action to install poetry (#34)
Browse files Browse the repository at this point in the history
* feat!: Use composite action to install poetry

The pattern of usage for GitHub Actions has moved towards setting up
everything you need by installing it on the runner. This ends up being
significantly faster to run and easier to reason about for a lot of
pepole since they don't have to think about all of these independent
workspaces/volumes.

Since there's already a `setup-python` action offered directly by
GitHub, and with the release of composite actions, seems like we could
vastly simplify how this action works since all it actually needs to do
is install poetry. We can assume that you've setup Python on your own in
some other way.

* Add lint pr workflow

BREAKING CHANGE: This changes the input and usage of the action
  • Loading branch information
abatilo committed Aug 22, 2020
1 parent c9df681 commit 7798bf8
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 141 deletions.
22 changes: 0 additions & 22 deletions .dependabot/config.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .dockerignore

This file was deleted.

42 changes: 26 additions & 16 deletions .github/workflows/ci.yml
@@ -1,27 +1,37 @@
name: CI
on: [push, pull_request]
on:
push:
branches:
- master
pull_request:

jobs:
ci:
strategy:
fail-fast: false
matrix:
python_version: [3.5, 3.6, 3.7, 3.8]
poetry_version: [1.0]
runs-on: ubuntu-latest
python-version: [3.6, 3.7, 3.8]
poetry-version: [1.0, 1.0.10]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Run image
uses: ./
with:
python_version: ${{ matrix.python_version }}
poetry_version: ${{ matrix.poetry_version }}
working_directory: '.'
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: ./
with:
poetry-version: ${{ matrix.poetry-version }}
- name: View poetry --help
run: poetry --help
release:
if: github.event_name == 'push'
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Generate release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- uses: actions/checkout@master
- name: Generate release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
15 changes: 15 additions & 0 deletions .github/workflows/lint-pr.yml
@@ -0,0 +1,15 @@
name: "Lint PR"
on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v1.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 0 additions & 37 deletions Dockerfile

This file was deleted.

46 changes: 26 additions & 20 deletions README.md
Expand Up @@ -10,31 +10,37 @@ GitHub Actions for Python projects using poetry

## Getting started

### Breaking changes for v2
We've drastically simplified this GitHub Action for v2. This is no longer a
Docker action that runs as its own container, it's just a simplified way for
you to install poetry. This action now makes an assumption that you've already
setup Python via `setup-python` or some other way. Since we're installing poetry directly to your environment, this also means that you can cache your dependencies more easily since everything is running on the host runner instead of an isolated container environment.

### Create your workflow
```yaml
name: Run Tests
on: push
name: CI
on: pull_request

jobs:
pytest:
name: pytest
runs-on: ubuntu-latest
ci:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]
poetry-version: [1.0, 1.0.10]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Install
uses: abatilo/actions-poetry@v1.5.0
with:
python_version: 3.8.0
poetry_version: 1.0
working_directory: ./working_dir # Optional, defaults to '.'
args: install
- name: Run pytest
uses: abatilo/actions-poetry@v1.5.0
with:
python_version: 3.8.0
poetry_version: 1.0
working_directory: ./working_dir
args: run python -m pytest --cov=src --cov-branch --cov-fail-under=100 tests/
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
- name: View poetry --help
run: poetry --help
```

## License
Expand Down
33 changes: 14 additions & 19 deletions action.yml
@@ -1,22 +1,17 @@
name: 'Python Poetry Action'
author: '@abatilo'
description: 'An action to run https://github.com/python-poetry/poetry'
runs:
using: 'docker'
image: 'Dockerfile'
name: "Python Poetry Action"
author: "@abatilo"
description: "An action to run https://github.com/python-poetry/poetry"
branding:
icon: 'truck'
color: 'gray-dark'
icon: "truck"
color: "gray-dark"
inputs:
python_version:
description: 'The version of python to install'
required: true
default: '3.8'
poetry_version:
description: 'The version of poetry to install'
poetry-version:
description: "The version of poetry to install"
required: true
default: '1.0'
working_directory:
description: 'The directory to run poetry commands in.'
required: false
default: '.'
default: "1.0"
runs:
using: "composite"
steps:
- run: |
pip install poetry==${{ inputs.poetry-version }}
shell: bash
22 changes: 0 additions & 22 deletions entrypoint.sh

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

0 comments on commit 7798bf8

Please sign in to comment.