add new workflows
This commit is contained in:
parent
2383c311ce
commit
e51b03aca2
6 changed files with 247 additions and 0 deletions
38
.gitea/workflows/build_pypackage.yml
Normal file
38
.gitea/workflows/build_pypackage.yml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
name: build pypackage
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
repository:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
description: "package repository"
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
username:
|
||||||
|
required: true
|
||||||
|
description: "repository username"
|
||||||
|
token:
|
||||||
|
required: true
|
||||||
|
description: "repository token/password"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-pypackage:
|
||||||
|
runs-on: python311
|
||||||
|
env:
|
||||||
|
HATCH_INDEX_REPO: ${{ inputs.repository }}
|
||||||
|
HATCH_INDEX_USER: ${{ secrets.username }}
|
||||||
|
HATCH_INDEX_AUTH: ${{ secrets.token }}
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: install hatch
|
||||||
|
run: pip install -U hatch hatchling
|
||||||
|
|
||||||
|
- name: build package
|
||||||
|
run: hatch build --clean
|
||||||
|
|
||||||
|
- name: publish package
|
||||||
|
if: gitea.event_name != 'pull_request'
|
||||||
|
run: hatch publish --yes --no-prompt
|
43
.gitea/workflows/check_python.yml
Normal file
43
.gitea/workflows/check_python.yml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: check/lint python code
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
src-dir:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
description: "source directory"
|
||||||
|
default: "."
|
||||||
|
run-tests:
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
description: "run tests"
|
||||||
|
default: false
|
||||||
|
tests-dir:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
description: "tests directory"
|
||||||
|
default: "tests"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-python:
|
||||||
|
runs-on: python311
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: install requirements
|
||||||
|
run: pip install -U ruff mypy pytest
|
||||||
|
|
||||||
|
- name: test mypy
|
||||||
|
run: mypy --non-interactive --install-types ${{ inputs.src-dir }}
|
||||||
|
|
||||||
|
- name: test ruff check
|
||||||
|
run: ruff check --diff ${{ inputs.src-dir }}
|
||||||
|
|
||||||
|
- name: test ruff format
|
||||||
|
run: ruff format --check --diff ${{ inputs.src-dir }}
|
||||||
|
|
||||||
|
- name: run tests
|
||||||
|
if: ${{ inputs.run-tests == true }}
|
||||||
|
run: pytest --exitfirst --verbose ${{ inputs.tests-dir }}
|
30
.gitea/workflows/check_python_hatch.yml
Normal file
30
.gitea/workflows/check_python_hatch.yml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
name: check/lint python code with hatch
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
run-tests:
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
description: "run tests"
|
||||||
|
default: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-python-hatch:
|
||||||
|
runs-on: python311
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: install hatch
|
||||||
|
run: pip install -U hatch
|
||||||
|
|
||||||
|
- name: test codestyle
|
||||||
|
run: hatch run lint:fmt
|
||||||
|
|
||||||
|
- name: test typing
|
||||||
|
run: hatch run lint:typing
|
||||||
|
|
||||||
|
- name: run tests
|
||||||
|
if: ${{ inputs.run-tests == true }}
|
||||||
|
run: hatch run default:test
|
56
.gitea/workflows/release_pypackage.yml
Normal file
56
.gitea/workflows/release_pypackage.yml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
name: build and release pypackage
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
repository:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
description: "package repository"
|
||||||
|
release-body:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
description: "body of the release"
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
username:
|
||||||
|
required: true
|
||||||
|
description: "repository username"
|
||||||
|
token:
|
||||||
|
required: true
|
||||||
|
description: "repository token/password"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-pypackage:
|
||||||
|
runs-on: python311
|
||||||
|
env:
|
||||||
|
HATCH_INDEX_REPO: ${{ inputs.repository }}
|
||||||
|
HATCH_INDEX_USER: ${{ secrets.username }}
|
||||||
|
HATCH_INDEX_AUTH: ${{ secrets.token }}
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: setup go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '>=1.20'
|
||||||
|
|
||||||
|
- name: install hatch
|
||||||
|
run: pip install -U hatch hatchling
|
||||||
|
|
||||||
|
- name: build package
|
||||||
|
run: hatch build --clean
|
||||||
|
|
||||||
|
- name: publish package
|
||||||
|
if: gitea.event_name != 'pull_request'
|
||||||
|
run: hatch publish --yes --no-prompt
|
||||||
|
|
||||||
|
- name: create gitea release
|
||||||
|
uses: https://gitea.com/actions/release-action@main
|
||||||
|
if: gitea.event_name != 'pull_request'
|
||||||
|
with:
|
||||||
|
title: ${{ gitea.ref_name }}
|
||||||
|
body: ${{ inputs.release-body }}
|
||||||
|
files: |-
|
||||||
|
dist/**
|
50
.gitea/workflows/sonarqube_python.yml
Normal file
50
.gitea/workflows/sonarqube_python.yml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
name: upload code to sonarqube
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
coverage:
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
description: "generate coverage"
|
||||||
|
default: false
|
||||||
|
tests-dir:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
description: "tests directory"
|
||||||
|
default: "tests"
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
sonar-host:
|
||||||
|
required: true
|
||||||
|
description: "sonarqube instance url"
|
||||||
|
sonar-token:
|
||||||
|
required: true
|
||||||
|
description: "sonarqube auth token"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
scan-code:
|
||||||
|
runs-on: python311
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: install requirements
|
||||||
|
if: ${{ inputs.coverage == true }}
|
||||||
|
run: pip install -U pytest coverage
|
||||||
|
|
||||||
|
- name: get coverage
|
||||||
|
if: ${{ inputs.coverage == true }}
|
||||||
|
run: |
|
||||||
|
coverage erase
|
||||||
|
coverage run -m pytest --exitfirst --verbose ${{ inputs.tests-dir }}
|
||||||
|
coverage report
|
||||||
|
coverage xml
|
||||||
|
|
||||||
|
- name: run sonar-scanner
|
||||||
|
uses: sonarsource/sonarqube-scan-action@v2.0.1
|
||||||
|
env:
|
||||||
|
SONAR_HOST_URL: ${{ secrets.sonar-host }}
|
||||||
|
SONAR_TOKEN: ${{ secrets.sonar-token }}
|
30
.gitea/workflows/update_changelog.yml
Normal file
30
.gitea/workflows/update_changelog.yml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
name: generate and update changelog
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-changelog:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: master
|
||||||
|
|
||||||
|
- name: install auto-changelog
|
||||||
|
run: npm install -g auto-changelog
|
||||||
|
|
||||||
|
- name: generate changelog
|
||||||
|
run: >-
|
||||||
|
auto-changelog -t keepachangelog --unreleased
|
||||||
|
--ignore-commit-pattern '(B|b)ump version|update changelog'
|
||||||
|
|
||||||
|
- name: commit changes
|
||||||
|
uses: EndBug/add-and-commit@v9
|
||||||
|
if: gitea.event_name != 'pull_request'
|
||||||
|
with:
|
||||||
|
message: "[bot] update changelog"
|
||||||
|
author_name: actions-bot
|
||||||
|
author_email: actions@bots.44net.ch
|
Reference in a new issue