Skip to content

Commit

Permalink
readthedocs integration
Browse files Browse the repository at this point in the history
  • Loading branch information
biolds committed Apr 29, 2023
1 parent 9654be2 commit 137dab1
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ doc:
- functional_tests
script:
- make _build_doc
- test -n "RTD_TOKEN" && curl -X POST -d "branches=main" -d "token=$RTD_TOKEN" -d "default_branch=main" https://readthedocs.org/api/v2/webhook/sosse/236935/ || true

pip_pkg:
image: biolds/sosse:pip-test
Expand Down
24 changes: 24 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.9"

jobs:
pre_build:
- python3 doc/get_artifacts.py

python:
install:
- requirements: doc/requirements.txt

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: doc/source/conf.py
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
![Gitlab code coverage](https://img.shields.io/gitlab/pipeline-coverage/biolds1/sosse?branch=main&style=flat-square)
![Gitlab pipeline status](https://img.shields.io/gitlab/pipeline-status/biolds1/sosse?branch=main&style=flat-square)
![GitLab](https://img.shields.io/gitlab/license/biolds1/sosse?style=flat-square)
<p>
<img src="https://raw.githubusercontent.com/biolds/sosse/main/se/static/se/logo.svg" width="64" align="right">
<a href="https://gitlab.com/biolds1/sosse/" alt="Gitlab code coverage">
<img src="https://img.shields.io/gitlab/pipeline-coverage/biolds1/sosse?branch=main&style=flat-square">
</a>
<a href="https://gitlab.com/biolds1/sosse/-/pipelines" alt="Gitlab pipeline status">
<img src="https://img.shields.io/gitlab/pipeline-status/biolds1/sosse?branch=main&style=flat-square">
</a>
<a href="https://gitlab.com/biolds1/sosse/-/blob/main/LICENSE" alt="License">
<img src="https://img.shields.io/gitlab/license/biolds1/sosse?style=flat-square">
</a>
<a href="https://sosse.readthedocs.io/en/latest/" alt="Documentation">
<img src="https://img.shields.io/readthedocs/sosse?style=flat-square">
</a>
</p>

SOSSE 🦦
=======
Expand Down
57 changes: 57 additions & 0 deletions doc/get_artifacts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/python3
# Copyright 2022-2023 Laurent Defert
#
# This file is part of SOSSE.
#
# SOSSE is free software: you can redistribute it and/or modify it under the terms of the GNU Affero
# General Public License as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# SOSSE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License along with SOSSE.
# If not, see <https://www.gnu.org/licenses/>.

import os
import gitlab
import requests
from io import BytesIO
from zipfile import ZipFile


PROJECT_ID = 41220530
jobs_name = ['doc_gen', 'functional_tests']

gl = gitlab.Gitlab()
project = gl.projects.get(PROJECT_ID)

commit_hash = os.environ['READTHEDOCS_GIT_COMMIT_HASH']
commit = project.commits.get(commit_hash)
pipeline_id = commit.last_pipeline['id']
print('Pipeline ID %s' % pipeline_id)
pipeline = project.pipelines.get(pipeline_id)

for job in pipeline.jobs.list():
if job.name in jobs_name:
if job.status != 'success':
print('Job %s did not succeed, state: %s' % (job.web_url, job.state))
exit(1)

artifact = job.web_url + '/artifacts/download'

print('Download artifact for %s at %s' % (job.name, artifact))
req = requests.get(artifact)
try:
with ZipFile(BytesIO(req.content)) as zip_file:
zip_file.extractall()
except: # noqa
with open('/tmp/artifact', 'wb') as f:
f.write(req.content)
raise
jobs_name.remove(job.name)

if len(jobs_name):
print('Job(s) %s not found' % (', '.join(jobs_name)))
exit(1)
2 changes: 2 additions & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python-gitlab
requests
2 changes: 1 addition & 1 deletion doc/source/screenshots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Screenshots
:class: sosse-screenshot
:scale: 50%

:doc:`Realtime crawling status <crawl/status>`
:doc:`Real-time crawling status <crawl/status>`

.. figure:: ../../tests/robotframework/screenshots/crawl_policy_decision_no_hilight.png
:class: sosse-screenshot
Expand Down
2 changes: 1 addition & 1 deletion docker/doc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ ARG PIP_TRUSTED_HOST=
RUN test -z "$APT_PROXY" || (echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf)
RUN apt update
RUN apt upgrade -y
RUN apt install -y jq python3-sphinx
RUN apt install -y jq python3-sphinx curl
RUN test -z "$APT_PROXY" || rm /etc/apt/apt.conf.d/proxy.conf
4 changes: 2 additions & 2 deletions se/management/commands/load_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Command(BaseCommand):
'''

def add_arguments(self, parser):
parser.add_argument('url', nargs=1, type=str, help='OpenSearch Description formatted XML file.')
parser.add_argument('opensearch_file', nargs=1, type=str, help='OpenSearch Description formatted XML file.')

def handle(self, *args, **options):
SearchEngine.parse_xml_file(options['url'][0])
SearchEngine.parse_xml_file(options['opensearch_file'][0])

0 comments on commit 137dab1

Please sign in to comment.