Skip to content

Commit

Permalink
ci: switch docs to poetry (#10938)
Browse files Browse the repository at this point in the history
* ci: switch to poetry

Signed-off-by: moabu <[email protected]>

* ci: move into docs folder

Signed-off-by: moabu <[email protected]>

* ci: fix running poetry run

Signed-off-by: moabu <[email protected]>

* ci: fix running poetry run

Signed-off-by: moabu <[email protected]>

* ci: fix running poetry run

Signed-off-by: moabu <[email protected]>

* ci: fix running poetry run

Signed-off-by: moabu <[email protected]>

* ci: force checkout and ignore any changes

Signed-off-by: moabu <[email protected]>

---------

Signed-off-by: moabu <[email protected]>
  • Loading branch information
moabu authored Feb 26, 2025
1 parent 371e896 commit 412ef22
Show file tree
Hide file tree
Showing 6 changed files with 1,045 additions and 89 deletions.
58 changes: 19 additions & 39 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ jobs:
with:
python-version: "3.10"
cache: pip
cache-dependency-path: docs/requirements.txt

- name: Install dependencies
run: |
pip install --require-hashes -r docs/requirements.txt
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
cp docs/pyproject.toml docs/poetry.lock ../
poetry install --no-root
cp mkdocs.yml ../
- name: Checkout jans ${{ github.event.inputs.version }}
Expand Down Expand Up @@ -97,7 +99,7 @@ jobs:
git config --global user.name "mo-auto"
git config --global user.email "[email protected]"
git config --global user.signingkey "${{ steps.import_gpg.outputs.keyid }}"
echo "${{ secrets.MOAUTO_WORKFLOW_TOKEN }}" | gh auth login --with-token
echo "${{ secrets.MOAUTO_WORKFLOW_TOKEN }}" | gh auth login --with-token
- name: Generate docs
continue-on-error: true
Expand All @@ -115,45 +117,42 @@ jobs:
git checkout -b cn-jans-update-auto-generated-docs
git pull origin cn-jans-update-auto-generated-docs || echo "Nothing to pull"
echo "Custom work on generating docs can go here."
# Run cn docs
# Run cn docs
sudo bash ./automation/docs/generated-cn-docs.sh . || echo "something went wrong with generating the cn docs"
echo "Generating auto-generated docs and push to main"
sudo bash ./automation/docs/generate-autogenerated-docs.sh . || echo "something went wrong with generating the property docs"
cd docs
git add . || echo "Nothing to add"
git commit -a -S -m "docs: auto-generated property docs" || echo "Nothing to commit"
cd ..
echo "Add jans-config-api Swagger SPECs that are auto-generated via API annotations"
sudo bash ./automation/docs/generate-swagger-specs.sh . || echo "something went wrong with generating the swagger docs"
cd jans-config-api/docs
git add . || echo "Nothing to add"
git commit -a -S -m "docs: auto-generated Swagger SPEC docs" || echo "Nothing to commit"
cd ../..
git push --set-upstream origin cn-jans-update-auto-generated-docs
MESSAGE="fix(docs): autogenerate docs"
PR=$(gh pr create --body "Auto generated docs" --title "${MESSAGE}")
cd ../../
sudo rm -rf temp
- name: mike deploy ${{ github.event.inputs.version }}
if: >-
github.event_name == 'workflow_dispatch'
run: |
mike deploy --push --force ${{ github.event.inputs.version }}
poetry run mike deploy --push --force ${{ github.event.inputs.version }}
# This deploys the current docs into gh-pages/head on merges to main
# The old "main" gets deleted if it exists, head is more descriptive
- name: mike deploy head
if: contains(github.ref, 'refs/heads/main') && github.event_name != 'workflow_dispatch'
run: |
mike deploy --push head
poetry run mike deploy --push head
# If a release has been published, deploy it as a new version
- name: mike deploy new version
if: >-
github.event_name == 'release' &&
Expand All @@ -163,11 +162,9 @@ jobs:
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
mike deploy --push "$VERSION"
poetry run mike deploy --push "$VERSION"
- name: Update mike version aliases
#if: >-
# github.event_name != 'workflow_dispatch'
id: set_versions
run: |
GITHUB_EVENT_RELEASE_TAG_NAME="${{ github.event.release.tag_name }}"
Expand All @@ -178,44 +175,28 @@ jobs:
LATEST='nightly'
fi
echo "Latest is $LATEST and Stable is $STABLE"
# remove below two lines after first release
#LATEST="head"
#STABLE="head"
mike alias -u head main
mike alias -u "${STABLE}" stable
mike set-default --push stable
poetry run mike alias -u head main
poetry run mike alias -u "${STABLE}" stable
poetry run mike set-default --push stable
echo "LATEST=${LATEST}" >> $GITHUB_OUTPUT
echo "STABLE=${STABLE}" >> $GITHUB_OUTPUT
# Ensures the current branch is gh-pages,
# Creates / updates the "stable" and "latest" plain text files with the corresponding versions
# Commits if the files were changed
# Finally pushes if there are unpushed commits
- name: Create version files
#if: >-
# github.event_name != 'workflow_dispatch'
run: |
LATEST=${{ steps.set_versions.outputs.LATEST }}
STABLE=${{ steps.set_versions.outputs.STABLE }}
git checkout gh-pages
git checkout -f gh-pages
git pull origin gh-pages
# move generated chart from a previous step
mv ../janssen-*.tgz ./charts/
cd ./charts
git add janssen-*.tgz && git update-index --refresh
helm repo index .
git add index.yaml && git update-index --refresh
cd ..
# END move generated chart from a previous step
# copy search from nightly to all other versions. This is to ensure that the search index is available for all versions
for folder in v*/; do
cp -r nightly/search "$folder"
git add $folder/search && git update-index --refresh
done
# END copy search from nightly to all other versions
echo "Replacing release number markers with actual release number"
cd ${LATEST}
if [[ "${LATEST}" == "nightly" ]]; then
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-janssen-version-stable/0.0.0-nightly/g"
Expand All @@ -231,7 +212,6 @@ jobs:
git rm -r $folder/admin/reference/javadocs || echo "Nothing to remove"
fi
done
# Replace scarf url
sed -i -e "s/placeholder-scarf-pixel-url/https:\/\/static.scarf.sh\/a.png?x-pxid=2c347abc-a9b4-4c4b-bdc9-2682edbcc0c9/g" ${STABLE}/overrides/main.html
git add ${STABLE}/overrides/main.html && git update-index --refresh
git diff-index --quiet HEAD -- || git commit -S -m "docs: update scarf pixel url"
Expand All @@ -241,4 +221,4 @@ jobs:
echo "${LATEST}" > latest.txt
git add latest.txt && git update-index --refresh
git diff-index --quiet HEAD -- || git commit -S -m "Set latest to ${LATEST}"
git push origin gh-pages
git push origin gh-pages
4 changes: 2 additions & 2 deletions .github/workflows/lint-flak8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=jans-linux-setup/jans_setup/setup_app/pylib,jans-linux-setup/jans_setup/static/extension
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=jans-linux-setup/jans_setup/setup_app/pylib,jans-linux-setup/jans_setup/static/extension
working-directory: ${{ matrix.python-projects }}
Loading

0 comments on commit 412ef22

Please sign in to comment.