Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI/CD #3

Merged
merged 10 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Checks
on:
push:

jobs:
run-checks:
name: Run checks 🧪
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python:
- '3.7'
- '3.8'
- '3.9'
env:
PYTHON_VERSION: ${{ matrix.python }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2

- name: Set up Python 🐍
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache Poetry virtualenv 💾
uses: actions/cache@v1
id: poetry-cache
with:
path: .venv
key: poetry-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry 📖
run: |
pip install poetry
poetry config virtualenvs.in-project true
- name: Install dependencies 📌
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
poetry install
idmitrievsky marked this conversation as resolved.
Show resolved Hide resolved
- name: Run checks 🧪
run: |
poetry run scripts/test.sh
108 changes: 108 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Docs
on:
push:
branches:
- master
pull_request:

env:
PYTHON_VERSION: 3.9

jobs:
build-docs:
name: Build docs 🏗
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2

- name: Set up Python 🐍
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache Poetry virtualenv 💾
uses: actions/cache@v1
id: poetry-cache
with:
path: .venv
key: poetry-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry 📖
run: |
pip install poetry
poetry config virtualenvs.in-project true
- name: Install dependencies 📌
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
poetry install
- name: Build docs 🏗
run: |
poetry run scripts/docs-build.sh
- name: Upload build to artifact ☁️
uses: actions/upload-artifact@v2
with:
name: mkdocs-build
path: site
if-no-files-found: error

deploy-docs-prod:
name: Deploy docs to Pages 🧐
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs:
- build-docs
steps:
- name: Download build from artifact 🌨
uses: actions/download-artifact@v1
with:
name: mkdocs-build

- name: Deploy docs to Pages 🧐
uses: JamesIves/github-pages-deploy-action@4.1.1
with:
branch: gh-pages
folder: mkdocs-build


deploy-docs-preview:
name: Deploy docs to Surge 🧐 [preview]
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs:
- build-docs
steps:
- name: Download build from artifact 🌨
uses: actions/download-artifact@v1
with:
name: mkdocs-build

- name: Publish to Surge 🧐 [preview]
id: publish-preview
env:
SURGE_LOGIN: dev@eventual.com
SURGE_TOKEN: 5ed7fcac90fac92170a28e638c01219b
run: |
pr_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
deploy_host="${pr_number}-eventual-review.surge.sh"
npx surge mkdocs-build $deploy_host
echo "::set-output name=deploy-url::https://$deploy_host"
- name: Find existing comment 🔎
id: find-comment
uses: peter-evans/find-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: preview version of docs

- name: Comment PR ✨
if: steps.find-comment.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
This is a preview version of docs: ${{ steps.publish-preview.outputs.deploy-url }}
56 changes: 56 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release

on:
release:
types:
- 'published'

env:
PYTHON_VERSION: 3.9

jobs:
build-and-publish:
name: Build and publish package 📦
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2

- name: Set up Python 🐍
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache Poetry virtualenv 💾
uses: actions/cache@v1
id: poetry-cache
with:
path: .venv
key: poetry-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry 📖
run: |
pip install poetry
poetry config virtualenvs.in-project true
- name: Install dependencies 📌
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
poetry install
- name: Build package 📦
run: |
poetry run scripts/build.sh
- name: Upload package build to artifacts ☁️
uses: actions/upload-artifact@v2
with:
name: package
path: dist
if-no-files-found: error

- name: Publish package ⬆️
run: |
poetry run scripts/publish.sh
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
1 change: 0 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
set -x

poetry build
mkdocs build
2 changes: 1 addition & 1 deletion scripts/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -x

coverage report --show-missing --skip-covered --fail-under=100
coverage report
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А ты убрал, потому что оно без тестов падает?

5 changes: 5 additions & 0 deletions scripts/docs-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -e

set -x

mkdocs build
File renamed without changes.
5 changes: 5 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -e

set -x

poetry publish
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -ex

scripts/check.sh
coverage run -m pytest
coverage run -m pytest tests
scripts/coverage.sh
9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ max-line-length = 120
[mypy]
disallow_untyped_defs = True
ignore_missing_imports = True

[coverage:run]
source = eventual
branch = True

[coverage:report]
precision = 2
show_missing = True
skip_covered = True