Skip to content

Commit e45dc5d

Browse files
dolfim-ibmvagenas
andauthored
ci: Add Github Actions (docling-project#4)
* add Github Actions Signed-off-by: Michele Dolfi <[email protected]> * apply styling Signed-off-by: Michele Dolfi <[email protected]> * Update .github/actions/setup-poetry/action.yml Co-authored-by: Panos Vagenas <[email protected]> Signed-off-by: Michele Dolfi <[email protected]> * add semantic-release config Signed-off-by: Panos Vagenas <[email protected]> --------- Signed-off-by: Michele Dolfi <[email protected]> Signed-off-by: Michele Dolfi <[email protected]> Signed-off-by: Panos Vagenas <[email protected]> Co-authored-by: Panos Vagenas <[email protected]>
1 parent b9dc892 commit e45dc5d

File tree

9 files changed

+197
-4
lines changed

9 files changed

+197
-4
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Set up Poetry and install'
2+
description: 'Set up a specific version of Poetry and install dependencies using caching.'
3+
inputs:
4+
python-version:
5+
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax."
6+
default: '3.11'
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Install poetry
11+
run: pipx install poetry==1.8.3
12+
shell: bash
13+
- uses: actions/setup-python@v4
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
cache: 'poetry'
17+
- name: Install dependencies
18+
run: poetry install --all-extras
19+
shell: bash

.github/scripts/release.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -e # trigger failure on error - do not remove!
4+
set -x # display command on output
5+
6+
if [ -z "${TARGET_VERSION}" ]; then
7+
>&2 echo "No TARGET_VERSION specified"
8+
exit 1
9+
fi
10+
CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}"
11+
12+
# update package version
13+
poetry version "${TARGET_VERSION}"
14+
15+
# collect release notes
16+
REL_NOTES=$(mktemp)
17+
poetry run semantic-release changelog --unreleased >> "${REL_NOTES}"
18+
19+
# update changelog
20+
TMP_CHGLOG=$(mktemp)
21+
TARGET_TAG_NAME="v${TARGET_VERSION}"
22+
RELEASE_URL="$(gh repo view --json url -q ".url")/releases/tag/${TARGET_TAG_NAME}"
23+
printf "## [${TARGET_TAG_NAME}](${RELEASE_URL}) - $(date -Idate)\n\n" >> "${TMP_CHGLOG}"
24+
cat "${REL_NOTES}" >> "${TMP_CHGLOG}"
25+
if [ -f "${CHGLOG_FILE}" ]; then
26+
printf "\n" | cat - "${CHGLOG_FILE}" >> "${TMP_CHGLOG}"
27+
fi
28+
mv "${TMP_CHGLOG}" "${CHGLOG_FILE}"
29+
30+
# push changes
31+
git config --global user.name 'github-actions[bot]'
32+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
33+
git add pyproject.toml "${CHGLOG_FILE}"
34+
COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]"
35+
git commit -m "${COMMIT_MSG}"
36+
git push origin main
37+
38+
# create GitHub release (incl. Git tag)
39+
gh release create "${TARGET_TAG_NAME}" -F "${REL_NOTES}"

.github/workflows/cd.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "Run CD"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
10+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
11+
12+
jobs:
13+
docs:
14+
permissions:
15+
contents: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: ./.github/actions/setup-poetry
20+
- name: Build and push docs
21+
run: poetry run mkdocs gh-deploy --force
22+
code-checks:
23+
uses: ./.github/workflows/checks.yml
24+
pre-release-check:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }}
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0 # for fetching tags, required for semantic-release
32+
- uses: ./.github/actions/setup-poetry
33+
- name: Check version of potential release
34+
id: version_check
35+
run: |
36+
TRGT_VERSION=$(poetry run semantic-release print-version)
37+
echo "TRGT_VERSION=${TRGT_VERSION}" >> $GITHUB_OUTPUT
38+
echo "${TRGT_VERSION}"
39+
- name: Check notes of potential release
40+
run: poetry run semantic-release changelog --unreleased
41+
release:
42+
needs: [code-checks, pre-release-check]
43+
if: needs.pre-release-check.outputs.TARGET_TAG_V != ''
44+
environment: auto-release
45+
runs-on: ubuntu-latest
46+
concurrency: release
47+
steps:
48+
- uses: actions/checkout@v3
49+
with:
50+
token: ${{ secrets.GH_PAT }}
51+
fetch-depth: 0 # for fetching tags, required for semantic-release
52+
- uses: ./.github/actions/setup-poetry
53+
- name: Run release script
54+
env:
55+
GH_TOKEN: ${{ secrets.GH_PAT }}
56+
TARGET_VERSION: ${{ needs.pre-release-check.outputs.TARGET_TAG_V }}
57+
CHGLOG_FILE: CHANGELOG.md
58+
run: ./.github/scripts/release.sh
59+
shell: bash

.github/workflows/checks.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
run-checks:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
python-version: ['3.11']
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: ./.github/actions/setup-poetry
13+
with:
14+
python-version: ${{ matrix.python-version }}
15+
- name: Run styling check
16+
run: poetry run pre-commit run --all-files

.github/workflows/ci.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Run CI"
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, ready_for_review]
6+
push:
7+
branches:
8+
- "**"
9+
- "!main"
10+
- "!gh-pages"
11+
12+
env:
13+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
14+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
15+
16+
jobs:
17+
code-checks:
18+
uses: ./.github/workflows/checks.yml
19+
20+
# To enable when we add the ./docs
21+
# build-docs:
22+
# runs-on: ubuntu-latest
23+
# steps:
24+
# - uses: actions/checkout@v3
25+
# - uses: ./.github/actions/setup-poetry
26+
# - name: Build docs
27+
# run: poetry run mkdocs build --verbose --clean
28+

.github/workflows/pypi.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Build and publish package"
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
12+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
13+
14+
jobs:
15+
build-and-publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: ./.github/actions/setup-poetry
20+
- name: Build and publish
21+
run: poetry publish --build --no-interaction --username=__token__ --password=${{ secrets.PYPI_TOKEN }}

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ tags
413413
[Ll]ib
414414
[Ll]ib64
415415
[Ll]ocal
416-
[Ss]cripts
417416
pyvenv.cfg
418417
pip-selfcheck.json
419418

docling/datamodel/base_models.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ class TableStructurePrediction(BaseModel):
180180
table_map: Dict[int, TableElement] = {}
181181

182182

183-
class TextElement(BasePageElement):
184-
...
183+
class TextElement(BasePageElement): ...
185184

186185

187186
class FigureData(BaseModel):

pyproject.toml

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "docling"
3-
version = "0.1.2"
3+
version = "0.1.2" # DO NOT EDIT, updated automatically
44
description = "Docling PDF conversion package"
55
authors = ["Christoph Auer <[email protected]>", "Michele Dolfi <[email protected]>", "Maxim Lysak <[email protected]>", "Nikos Livathinos <[email protected]>", "Ahmed Nassar <[email protected]>", "Peter Staar <[email protected]>"]
66
license = "MIT"
@@ -72,3 +72,16 @@ python_version = "3.11"
7272
[tool.flake8]
7373
max-line-length = 88
7474
extend-ignore = ["E203", "E501"]
75+
76+
[tool.semantic_release]
77+
# for default values check:
78+
# https://github.com/python-semantic-release/python-semantic-release/blob/v7.32.2/semantic_release/defaults.cfg
79+
80+
version_source = "tag_only"
81+
branch = "main"
82+
83+
# configure types which should trigger minor and patch version bumps respectively
84+
# (note that they must be a subset of the configured allowed types):
85+
parser_angular_allowed_types = "build,chore,ci,docs,feat,fix,perf,style,refactor,test"
86+
parser_angular_minor_types = "feat"
87+
parser_angular_patch_types = "fix,perf"

0 commit comments

Comments
 (0)