1
Fork 0
mirror of https://github.com/Steffo99/cfig.git synced 2024-10-16 14:27:38 +00:00

🔨 Import workflows from Steffo99/template-poetry

This commit is contained in:
Steffo 2022-04-26 17:39:20 +02:00
parent fe25092f5a
commit 2d6935317c
Signed by: steffo
GPG key ID: 6965406171929D01
3 changed files with 182 additions and 0 deletions

29
.github/workflows/analysis.yml vendored Normal file
View file

@ -0,0 +1,29 @@
name: "Periodic analysis"
on:
schedule:
# Change this in your project to a random time.
# Every monday at 06:09 UTC
- cron: "9 6 * * 1"
jobs:
codeql:
name: "🔍 Perform CodeQL analysis"
runs-on: ubuntu-latest
permissions:
security-events: write
actions: read
contents: read
steps:
- name: "⬇️ Checkout repository"
uses: actions/checkout@v3
- name: "🔨 Initialize CodeQL"
uses: github/codeql-action/init@v2
with:
languages: python
- name: "🔍 Perform CodeQL analysis"
uses: github/codeql-action/analyze@v2

89
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,89 @@
name: "Automated release"
on:
push:
tags:
- "v*"
defaults:
run:
shell: bash
jobs:
tests:
uses: "./.github/workflows/tests.yml"
build-package:
name: "📦 Build Python package"
runs-on: ubuntu-latest
steps:
- name: "⬇️ Checkout repository"
uses: actions/checkout@v3
- name: "🔨 Setup Python"
uses: actions/setup-python@v3
- name: "🔨 Setup Poetry"
uses: abatilo/actions-poetry@v2.1.4
- name: "🔨 Setup Poetry Python environment"
uses: Steffo99/actions-poetry-deps@0.2.4
- name: "🏗 Build package with Poetry"
run: poetry build --no-interaction
- name: "⬆️ Upload code package to artifacts"
uses: actions/upload-artifact@v3
with:
name: "Build"
path: dist/*.tar.gz
if-no-files-found: error
- name: "⬆️ Upload wheel package to artifacts"
uses: actions/upload-artifact@v3
with:
name: "Build"
path: dist/*.whl
if-no-files-found: warn
publish-github:
name: "🌐 Publish release on GitHub"
needs:
- "tests"
- "build-package"
runs-on: ubuntu-latest
steps:
- name: "⬇️ Download built packages from artifacts"
uses: actions/download-artifact@v3
with:
name: "Build"
path: dist/
- name: "🌐 Create release"
uses: ncipollo/release-action@v1.10.0
with:
artifactErrorsFailBuild: true
artifacts: dist/**
draft: true
generateReleaseNotes: true
publish-pypi:
name: "🌐 Publish release on PyPI"
needs:
- "tests"
- "build-package"
runs-on: ubuntu-latest
steps:
- name: "⬇️ Download built packages from artifacts"
uses: actions/download-artifact@v3
with:
name: "Build"
path: dist/
- name: "🌐 Upload package"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: "__token__"
password: ${{ secrets.PYPI_TOKEN }}

64
.github/workflows/tests.yml vendored Normal file
View file

@ -0,0 +1,64 @@
name: "Test suite"
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
workflow_call:
defaults:
run:
shell: bash
jobs:
pytest:
name: "🧪 Test package using pytest"
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
# If you need a database to perform your tests
# services:
# postgres:
# image: postgres
# env:
# POSTGRES_USER: username
# POSTGRES_PASSWORD: password
# POSTGRES_DB: db
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# ports:
# - "5432:5432"
steps:
- name: "⬇️ Checkout repository"
uses: actions/checkout@v3
- name: "🔨 Setup Python"
uses: actions/setup-python@v3
- name: "🔨 Setup Poetry"
uses: abatilo/actions-poetry@v2.1.4
- name: "🔨 Setup Poetry Python environment"
id: pyenv
uses: Steffo99/actions-poetry-deps@0.2.4
- name: "🧪 Run tests"
run: |
source ${{ steps.pyenv.outputs.pyenv }}/activate
pytest --verbose --cov=. --cov-report=html
- name: "⬆️ Upload coverage"
uses: actions/upload-artifact@v3
with:
name: "code-coverage-report"
path: htmlcov