mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-11-04 16:45:57 +00:00
27
.github/workflows/pypi-release.yml
vendored
27
.github/workflows/pypi-release.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
|||||||
|
|
||||||
|
|
||||||
test-pypi-package:
|
test-pypi-package:
|
||||||
name: Test the built 📦 package works basically.
|
name: Test the built package works basically.
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
@@ -42,18 +42,39 @@ jobs:
|
|||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
- name: Test that the basic pip built package runs without error
|
- name: Test that the basic pip built package runs without error
|
||||||
run: |
|
run: |
|
||||||
set -ex
|
set -ex
|
||||||
ls -alR
|
ls -alR
|
||||||
|
|
||||||
# Find and install the first .whl file
|
# Install the first wheel found in dist/
|
||||||
find dist -type f -name "*.whl" -exec pip3 install {} \; -quit
|
WHEEL=$(find dist -type f -name "*.whl" -print -quit)
|
||||||
|
echo Installing $WHEEL
|
||||||
|
python3 -m pip install --upgrade pip
|
||||||
|
python3 -m pip install "$WHEEL"
|
||||||
changedetection.io -d /tmp -p 10000 &
|
changedetection.io -d /tmp -p 10000 &
|
||||||
|
|
||||||
sleep 3
|
sleep 3
|
||||||
curl --retry-connrefused --retry 6 http://127.0.0.1:10000/static/styles/pure-min.css >/dev/null
|
curl --retry-connrefused --retry 6 http://127.0.0.1:10000/static/styles/pure-min.css >/dev/null
|
||||||
curl --retry-connrefused --retry 6 http://127.0.0.1:10000/ >/dev/null
|
curl --retry-connrefused --retry 6 http://127.0.0.1:10000/ >/dev/null
|
||||||
|
|
||||||
|
# --- API test ---
|
||||||
|
# This also means that the docs/api-spec.yml was shipped and could be read
|
||||||
|
test -f /tmp/url-watches.json
|
||||||
|
API_KEY=$(jq -r '.. | .api_access_token? // empty' /tmp/url-watches.json)
|
||||||
|
echo Test API KEY is $API_KEY
|
||||||
|
curl -X POST "http://127.0.0.1:10000/api/v1/watch" \
|
||||||
|
-H "x-api-key: ${API_KEY}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
--show-error --fail \
|
||||||
|
--retry 6 --retry-delay 1 --retry-connrefused \
|
||||||
|
-d '{
|
||||||
|
"url": "https://example.com",
|
||||||
|
"title": "Example Site Monitor",
|
||||||
|
"time_between_check": { "hours": 1 }
|
||||||
|
}'
|
||||||
|
|
||||||
killall changedetection.io
|
killall changedetection.io
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ def get_openapi_spec():
|
|||||||
from openapi_core import OpenAPI # Lazy import - saves ~10.7 MB on startup
|
from openapi_core import OpenAPI # Lazy import - saves ~10.7 MB on startup
|
||||||
|
|
||||||
spec_path = os.path.join(os.path.dirname(__file__), '../../docs/api-spec.yaml')
|
spec_path = os.path.join(os.path.dirname(__file__), '../../docs/api-spec.yaml')
|
||||||
|
if not os.path.exists(spec_path):
|
||||||
|
# Possibly for pip3 packages
|
||||||
|
spec_path = os.path.join(os.path.dirname(__file__), '../docs/api-spec.yaml')
|
||||||
|
|
||||||
with open(spec_path, 'r') as f:
|
with open(spec_path, 'r') as f:
|
||||||
spec_dict = yaml.safe_load(f)
|
spec_dict = yaml.safe_load(f)
|
||||||
_openapi_spec = OpenAPI.from_dict(spec_dict)
|
_openapi_spec = OpenAPI.from_dict(spec_dict)
|
||||||
|
|||||||
19
setup.py
19
setup.py
@@ -5,6 +5,8 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
import shutil
|
||||||
|
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
@@ -22,6 +24,20 @@ def find_version(*file_paths):
|
|||||||
raise RuntimeError("Unable to find version string.")
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
|
|
||||||
|
class BuildPyCommand(build_py):
|
||||||
|
"""Custom build command to copy api-spec.yaml to the package."""
|
||||||
|
def run(self):
|
||||||
|
build_py.run(self)
|
||||||
|
# Ensure the docs directory exists in the build output
|
||||||
|
docs_dir = os.path.join(self.build_lib, 'changedetectionio', 'docs')
|
||||||
|
os.makedirs(docs_dir, exist_ok=True)
|
||||||
|
# Copy api-spec.yaml to the package
|
||||||
|
shutil.copy(
|
||||||
|
os.path.join(here, 'docs', 'api-spec.yaml'),
|
||||||
|
os.path.join(docs_dir, 'api-spec.yaml')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
install_requires = open('requirements.txt').readlines()
|
install_requires = open('requirements.txt').readlines()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
@@ -37,9 +53,10 @@ setup(
|
|||||||
scripts=["changedetection.py"],
|
scripts=["changedetection.py"],
|
||||||
author='dgtlmoon',
|
author='dgtlmoon',
|
||||||
url='https://changedetection.io',
|
url='https://changedetection.io',
|
||||||
packages=['changedetectionio'],
|
packages=find_packages(include=['changedetectionio', 'changedetectionio.*']),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
|
cmdclass={'build_py': BuildPyCommand},
|
||||||
license="Apache License 2.0",
|
license="Apache License 2.0",
|
||||||
python_requires=">= 3.10",
|
python_requires=">= 3.10",
|
||||||
classifiers=['Intended Audience :: Customer Service',
|
classifiers=['Intended Audience :: Customer Service',
|
||||||
|
|||||||
Reference in New Issue
Block a user