mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 03:24:20 +00:00
Update GitHub Actions with the latest from Steffo99/template-poetry
This commit is contained in:
parent
3229d9edac
commit
c06185ca1a
4 changed files with 252 additions and 166 deletions
29
.github/workflows/analysis.yml
vendored
Normal file
29
.github/workflows/analysis.yml
vendored
Normal 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
|
134
.github/workflows/release.yml
vendored
Normal file
134
.github/workflows/release.yml
vendored
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
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@v0.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 }}
|
||||||
|
|
||||||
|
publish-docker:
|
||||||
|
name: "🐳 Build and publish Docker image on ghcr.io"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- "tests"
|
||||||
|
- "build-package"
|
||||||
|
steps:
|
||||||
|
- name: "Checkout repository"
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: "❓ Find the release semantic version"
|
||||||
|
id: semver
|
||||||
|
uses: Steffo99/actions-semver@v0.3.4
|
||||||
|
with:
|
||||||
|
string: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: "🔨 Setup Buildx"
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: "🔑 Login to GitHub Containers"
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: "🔽 Find the lowercase name of the repository"
|
||||||
|
id: reponame
|
||||||
|
uses: ASzc/change-string-case-action@v2
|
||||||
|
with:
|
||||||
|
string: ${{ github.repository }}
|
||||||
|
|
||||||
|
- name: "🏗 Build and push the Docker image"
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
target: "entrypoint"
|
||||||
|
tags: >-
|
||||||
|
ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.precedence }},
|
||||||
|
ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.core }},
|
||||||
|
ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.pair }},
|
||||||
|
ghcr.io/${{ steps.reponame.outputs.lowercase }}:${{ steps.semver.outputs.major }},
|
||||||
|
ghcr.io/${{ steps.reponame.outputs.lowercase }}:latest
|
||||||
|
push: true
|
||||||
|
|
166
.github/workflows/stefflow.yml
vendored
166
.github/workflows/stefflow.yml
vendored
|
@ -1,166 +0,0 @@
|
||||||
name: "🔨 Steffo's Python Poetry Workflow"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
schedule:
|
|
||||||
- cron: "11 10 * * 1" # Every monday at 10:11 AM
|
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- published
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
analyze-codeql:
|
|
||||||
name: "🔍 Perform CodeQL analysis"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
security-events: write
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "⬇️ Checkout repository"
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: "🔨 Initialize CodeQL"
|
|
||||||
uses: github/codeql-action/init@v1
|
|
||||||
with:
|
|
||||||
languages: python
|
|
||||||
|
|
||||||
- name: "🔍 Perform CodeQL analysis"
|
|
||||||
uses: github/codeql-action/analyze@v1
|
|
||||||
|
|
||||||
analyze-pytest:
|
|
||||||
name: "🧪 Test package"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
|
|
||||||
|
|
||||||
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.3
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
build-package:
|
|
||||||
name: "📦 Build and publish Python package"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
|
|
||||||
|
|
||||||
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.3
|
|
||||||
|
|
||||||
- name: "🏗 Build package with Poetry"
|
|
||||||
run: poetry build --no-interaction
|
|
||||||
|
|
||||||
- name: "⬆️ Upload code package as artifact"
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: "package.tar.gz"
|
|
||||||
path: dist/*.tar.gz
|
|
||||||
|
|
||||||
- name: "⬆️ Upload wheel package as artifact"
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: "package.whl"
|
|
||||||
path: dist/*.whl
|
|
||||||
|
|
||||||
- name: "Publish Poetry package"
|
|
||||||
run: poetry publish --no-interaction
|
|
||||||
env:
|
|
||||||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
|
|
||||||
|
|
||||||
build-docs:
|
|
||||||
name: "📔 Build and publish documentation"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build-package
|
|
||||||
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
|
|
||||||
|
|
||||||
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.3
|
|
||||||
|
|
||||||
- name: "🏗 Build HTML documentation with Sphinx"
|
|
||||||
working-directory: docs/
|
|
||||||
run: |
|
|
||||||
source ${{ steps.pyenv.outputs.pyenv }}/activate
|
|
||||||
make html
|
|
||||||
|
|
||||||
- name: "⬆️ Upload docs artifact"
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: "documentation"
|
|
||||||
path: "docs/build/html/"
|
|
||||||
|
|
||||||
- name: "🌐️ Publish build to GitHub Pages"
|
|
||||||
uses: peaceiris/actions-gh-pages@v3.8.0
|
|
||||||
with:
|
|
||||||
github_token: "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
publish_dir: "docs/build/html/"
|
|
||||||
enable_jekyll: false
|
|
89
.github/workflows/tests.yml
vendored
Normal file
89
.github/workflows/tests.yml
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
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 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@v0.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: "Coverage"
|
||||||
|
path: htmlcov
|
||||||
|
|
||||||
|
# If you do not want to use unit testing
|
||||||
|
# syntax:
|
||||||
|
# name: "🧪 Check the package's syntax"
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
#
|
||||||
|
# steps:
|
||||||
|
# - name: "⬇️ Checkout repository"
|
||||||
|
# uses: actions/checkout@v3
|
||||||
|
#
|
||||||
|
# - name: "🔨 Setup Python"
|
||||||
|
# uses: actions/setup-python@v3
|
||||||
|
# with:
|
||||||
|
# python-version: '3.8'
|
||||||
|
#
|
||||||
|
# - name: "🔨 Setup Poetry"
|
||||||
|
# uses: abatilo/actions-poetry@v2.1.4
|
||||||
|
#
|
||||||
|
# - name: "🔨 Setup Poetry Python environment"
|
||||||
|
# id: pyenv
|
||||||
|
# uses: Steffo99/actions-poetry-deps@v0.2.4
|
||||||
|
#
|
||||||
|
# - name: "🧪 Run check"
|
||||||
|
# run: |
|
||||||
|
# source ${{ steps.pyenv.outputs.pyenv }}/activate
|
||||||
|
# python -m compileall thorunimore
|
Loading…
Reference in a new issue