From f1e6124ee531fdeec9d8820d407ea408d8dab297 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 28 Feb 2024 09:48:58 +0100 Subject: [PATCH] try ci --- .gitea/workflows/action.yml | 63 ++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/action.yml b/.gitea/workflows/action.yml index 4d41a7c..d33e08e 100644 --- a/.gitea/workflows/action.yml +++ b/.gitea/workflows/action.yml @@ -2,8 +2,7 @@ name: Compile LaTeX document on: push: - branches: - - main # or any other branch you want to trigger the workflow + branches: [main, ci] # or any other branch you want to trigger the workflow pull_request: branches: - main @@ -15,9 +14,6 @@ jobs: container: image: leplusorg/latex - - - steps: - name: "Determine prerequisites" id: prereq @@ -51,3 +47,60 @@ jobs: # name: Beitrittserklaerung_RudernDonauLinz.pdf # path: ./main.pdf + + + latex_spellcheck: + runs-on: ubuntu-latest + container: + image: registry.gitlab.com/islandoftex/images/texlive:${{ env.LATEX_SPELLCHECK_TEXLIVE_VERSION }} + options: --entrypoint /bin/bash + env: + LATEX_SPELLCHECK_SOURCE_NAME: main + LATEX_SPELLCHECK_SOURCE_PATH: './' + LATEX_SPELLCHECK_SOURCE_LANGUAGE_DEFAULT: en-US + LATEX_SPELLCHECK_IGNORELIST: spellcheck_custom_words.txt + LATEX_SPELLCHECK_TEXLIVE_VERSION: TL2021-2021-12-12-04-05 + LATEX_SPELLCHECK_TEXLIVE_IMAGE: registry.gitlab.com/islandoftex/images/texlive + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare environment + run: | + cd $LATEX_SPELLCHECK_SOURCE_PATH + export SOURCE_LANGUAGE=$(cat $LATEX_SPELLCHECK_SOURCE_NAME.tex | perl -e ' + $spellcheck_language = $ENV{LATEX_SPELLCHECK_SOURCE_LANGUAGE_DEFAULT}; + while (<>) { + last if !/^%\s+!/; + if (/^%\s+!tex\s+spellcheck\s*=\s*(.+)$/i) { + $lang = "$1"; + $lang =~ s/^\s+|\s+$//g; + $spellcheck_language = $lang; + } + } + $spellcheck_language = $ENV{LATEX_SPELLCHECK_SOURCE_LANGUAGE} if ($ENV{LATEX_SPELLCHECK_SOURCE_LANGUAGE}); + $spellcheck_language =~ s/^([a-zA-Z]{2})([-_]([a-zA-Z]{2}))?.*$/$1/; + $spellcheck_variant = "$3"; + print "${spellcheck_language}-${spellcheck_variant}"; + ') + export LANGUAGE_PREFIX=$(echo $SOURCE_LANGUAGE | head -c2 -) + apt-get update + apt-get -y install python3-pip wget python3-venv + python3 -m venv /tmp/env + source /tmp/env/bin/activate + pip3 install yalafi + wget --directory-prefix=/srv/ https://languagetool.org/download/LanguageTool-stable.zip + unzip /srv/LanguageTool-stable.zip -d /srv/lt/ + mv /srv/lt/* /srv/lt/LanguageTool + sed -i -e '$a\\' /srv/lt/LanguageTool/org/languagetool/resource/$LANGUAGE_PREFIX/hunspell/spelling_custom.txt + test -f "$LATEX_SPELLCHECK_IGNORELIST" && cat ./$LATEX_SPELLCHECK_IGNORELIST >>/srv/lt/LanguageTool/org/languagetool/resource/$LANGUAGE_PREFIX/hunspell/spelling_custom.txt + latexpand $LATEX_SPELLCHECK_SOURCE_NAME.tex >$LATEX_SPELLCHECK_SOURCE_NAME.spellcheck.merged.tmp + sed -i 's/~/ 1/g' $LATEX_SPELLCHECK_SOURCE_NAME.spellcheck.merged.tmp + detex $LATEX_SPELLCHECK_SOURCE_NAME.spellcheck.merged.tmp >$LATEX_SPELLCHECK_SOURCE_NAME.spellcheck.plain.tmp + python3 -m yalafi.shell --lt-directory /srv/lt/LanguageTool --output html --language $SOURCE_LANGUAGE $LATEX_SPELLCHECK_SOURCE_NAME.spellcheck.plain.tmp >$LATEX_SPELLCHECK_SOURCE_NAME.spellcheck.html + + - name: Upload Spellcheck Results + uses: actions/upload-artifact@v2 + with: + name: spellcheck-results + path: ${{ env.LATEX_SPELLCHECK_SOURCE_PATH }}${{ env.LATEX_SPELLCHECK_SOURCE_NAME }}.spellcheck.html