fix(General): fix ci pipeline with forgejo runner
Unit test coverage / pytest (push) Failing after 1m32s
CI for pypl publish / publish-lib (push) Failing after 1m30s

This commit is contained in:
2025-03-27 21:05:41 +08:00
parent 141de355d4
commit 4f5da0460b
16 changed files with 125 additions and 43 deletions
+47
View File
@@ -0,0 +1,47 @@
name: "Unit test coverage"
on:
push:
pull_request:
env:
MIN_COVERAGE_PERCENTAGE: 85
DEBIAN_FRONTEND: noninteractive
TZ: UTC
jobs:
# gradle test for modules
pytest:
runs-on: default
container:
image: ubuntu:24.04
steps:
# need to setup node and git
- run: |
apt-get update
apt-get install -y nodejs git curl
# check out code and set up python
- uses: actions/checkout@v4
- uses: https://github.com/actions/setup-python@v5
with:
python-version: '3.11'
# install dependencies
- run: pip install -e .[dev]
# run pytest with coverage
- run: pytest --cov=amqp --cov-report=xml
# process coverage report
- name: Collect coverage report
id: coverage
run: |
COVERAGE_PERCENTAGE=$(coverage report --format=total)
echo "Code coverage: ${COVERAGE_PERCENTAGE}%"
echo "Minimal coverage: ${MIN_COVERAGE_PERCENTAGE}%"
echo "percentage=${COVERAGE_PERCENTAGE}" >> $GITHUB_OUTPUT
- name: Post coverage to RP
if: github.event_name == 'pull_request'
run: |
curl --fail \
-X POST '${{github.api_url}}/repos/${{github.repository}}/issues/${{github.event.number}}/comments' \
-H "Content-Type: application/json" \
-H "Authorization: token ${{github.token}}" \
-d '{"body":"Coverage for module ${{ matrix.submodule }} is ${{steps.coverage.outputs.percentage}}%"}'
- name: Check coverage rate
run: |
coverage report --fail-under=${MIN_COVERAGE_PERCENTAGE}
+49
View File
@@ -0,0 +1,49 @@
name: "CI for pypl publish"
on:
push:
branches:
- master # publish release on master
- develop # publish snapshot on develop
- "feat/*" # test
workflow_dispatch:
# allow manual trigger
env:
DEBIAN_FRONTEND: noninteractive
TZ: UTC
jobs:
publish-lib:
runs-on: default
container:
image: ubuntu:24.04
steps:
# need to setup node and git
- run: |
apt-get update
apt-get install -y nodejs git
# check out code
- uses: actions/checkout@v4
- uses: https://github.com/actions/setup-python@v5
with:
python-version: '3.11'
# install dependencies
- run: pip install -e .[dev]
# run pytest
- run: pytest
# replace timestamp building dev version
- name: Add timestamp to version
if: github.head_ref != '' && github.head_ref != 'master'
run: |
sed -i -E "s/(version = \"[^\"]+)(-dev)DT\"/\1\2$(date -u +'%Y%m%d%H%M%S')\"/" pyproject.toml
cat pyproject.toml
- name: Build wheel
run: |
python -m build
# publish
- run: |
twine upload --repository-url https://git.cleverthis.com/api/packages/clevermicro/pypi \
--username $CI_REGISTRY_USER \
--password $CI_REGISTRY_PASSWORD \
dist/*
env:
CI_REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
CI_REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
+4
View File
@@ -53,3 +53,7 @@ hs_err_pid*
.venv
.coverage
amq_adapter.egg-info/
build/
coverage.xml
+1 -4
View File
@@ -59,7 +59,4 @@ publish:
script:
# - twine upload --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD dist/*
- twine upload --repository-url https://git.cleverthis.com/api/v4/projects/$PROJECT_ID/packages/pypi --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD dist/*
#only:
# - main # Only publish from the main branch
#rules:
# - if: $CI_COMMIT_BRANCH == "main"
+24 -1
View File
@@ -5,9 +5,19 @@ build-backend = "setuptools.build_meta"
[project]
name = "amq_adapter"
version = "0.2.2"
description = "The Python implementation of the AMQ Adaptor for CleverMicro"
description = "Adapter for RabbitMQ to integrate a CleverThis python-code Service with CleverMicro platform"
readme = "README.md"
authors = [
{ name = "Stanislav Hejny", email = "stanislav.hejny@cleverthis.com" }
]
license = { text = "Apache License 2.0" }
urls = { Homepage = "https://git.cleverthis.com/clevermicro/amq-adapter-python" }
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
requires-python = ">=3.11"
dependencies = [
"aiohttp~=3.11.11",
"pika~=1.3.2",
@@ -18,3 +28,16 @@ dependencies = [
"opentelemetry-exporter-prometheus",
"opentelemetry-instrumentation-pika"
]
[tool.setuptools.packages.find]
where = ["."]
exclude = ["tests*", "docs*"]
[project.optional-dependencies]
dev = [
"pytest>=7.0",
"pytest-cov>=4.0",
"build",
"twine"
]
-8
View File
@@ -1,8 +0,0 @@
aiohttp~=3.11.11
fastapi==0.115.6
pika~=1.3.2
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-otlp
opentelemetry-exporter-prometheus
opentelemetry-instrumentation-pika
-30
View File
@@ -1,30 +0,0 @@
from setuptools import setup, find_packages
setup(
name="amqp",
version="0.2.0",
author="Stanislav Hejny",
author_email="stanislav.hejny@cleverthis.com",
description="Adapter for RabbitMQ to integrate a CleverThis python-code Service with CleverMicro platform",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url="https://git.cleverthis.com/cleverthis/clevermicro/amq-adapter-python",
packages=find_packages(),
install_requires=[
# dependencies here
"aiohttp~=3.11.11",
"fastapi==0.115.6",
"pika~=1.3.2",
"opentelemetry-api",
"opentelemetry-sdk",
"opentelemetry-exporter-otlp",
"opentelemetry-exporter-prometheus",
"opentelemetry-instrumentation-pika"
],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.11",
)