Skip to content

Instantly share code, notes, and snippets.

@MarwanDebbiche
Last active October 16, 2020 08:15
Show Gist options
  • Save MarwanDebbiche/74068a930fce057740d378a0e5d1685f to your computer and use it in GitHub Desktop.
Save MarwanDebbiche/74068a930fce057740d378a0e5d1685f to your computer and use it in GitHub Desktop.
name: CI/CD # pipeline's name that will appear in Github Actions
on: # events that trigger our pipeline: push on any branch and release creation
push:
release:
types: [created]
jobs: # jobs. We will have two jobs (test and publish) with multiple steps.
test:
# Our test job will run on ubuntu.
# We define matrix strategy for python-version so that
# our tests are run on multiple python versions:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run image # install poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: 1.0.10
- name: Install dependencies # install all dependencies
run: poetry install
- name: Pylint # Run pylint static analysis
run: |
poetry run pylint tsgen
- name: mypy # Run mypy static analysis
run: |
poetry run mypy -p tsgen
- name: Pytest # Run pytest
run: |
poetry run coverage run -m --source=tsgen pytest tests
poetry run coverage report
- name: Coveralls # Send coverage metrics to coveralls.io
run: poetry run coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
publish:
# Our publish job will only run on release creation events,
# and only if the test job has passed
if: github.event_name == 'release' && github.event.action == 'created'
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Run image
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: 1.0.10
- name: Build and publish # publish tsgen to PyPI
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: poetry publish -u $PYPI_USERNAME -p $PYPI_PASSWORD --build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment