Skip to content

[pre-commit.ci] pre-commit autoupdate #587

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #587

name: XML Database Creation
on:
push:
pull_request_target:
jobs:
Create_database:
name: Create XML database
runs-on: ubuntu-latest
steps:
- name: Checkout repo content
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install -r requirements.txt
sudo apt-get install libxml2-utils
- name: Reconfigure locales
run: |
sudo locale-gen it_IT.UTF-8
sudo locale-gen en_GB.UTF-8
sudo locale-gen nl_NL.UTF-8
- name: Execute ci_script_check_making_database
continue-on-error: true
run: |
python3 python/ci_script_check_making_database.py 2> outputs/STDERR 1> outputs/STDOUT
- name: Set STDERR variable
id: STDERR
run: |
if [ $(wc -l < outputs/STDERR) -ge 2 ]
then
echo ::set-output name=full::true
else
echo ::set-output name=empty::true
fi
- name: Set XMLERR variable
id: XMLERR
run: |
if [ $(wc -l < outputs/xml_errors) -gt 0 ]
then
echo ::set-output name=full::true
else
echo ::set-output name=empty::true
fi
# Create error commit comment
- name: Get error comment body
id: get-comment-body-error
if: ${{ steps.STDERR.outputs.full }}
run: |
body=$(cat outputs/STDERR)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Create errors commit comment
if: ${{ steps.STDERR.outputs.full }}
uses: peter-evans/commit-comment@v3
with:
body: |
**An error occurred when trying to create the database!**
The following was the error, contact Daniël if the error is not clear:
```python
${{ steps.get-comment-body-error.outputs.body }}
```
# Create XML DTD comment
- name: Get XML-DTD comment body
if: ${{ steps.XMLERR.outputs.full }}
id: get-xml-dtd-errors
run: |
body=$(cat outputs/xml_errors)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Create XML-DTD commit comment
if: ${{ steps.XMLERR.outputs.full }}
uses: peter-evans/commit-comment@v3
with:
body: |
**An error occurred when trying to create the database!**
<details>
<summary>
Found the following erros in the created XML database.
</summary>
Standard errors include:
- `element dao: validity error : ID xxx already defined` means that that file ID xxx occurs multiple times
```python
${{ steps.get-xml-dtd-errors.outputs.body }}
```
</details>
# Get input for commit comment
- name: Get titles comment body
id: get-comment-body-titles
if: ${{ steps.STDERR.outputs.empty && steps.XMLERR.outputs.empty }}
run: |
body=$(cat outputs/missing_titles)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Get translations comment body
id: get-comment-body-translations
if: ${{ steps.STDERR.outputs.empty && steps.XMLERR.outputs.empty }}
run: |
body=$(cat outputs/missing_translations)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Get title errors comment body
id: get-title-errors-body-translations
if: ${{ steps.STDERR.outputs.empty && steps.XMLERR.outputs.empty }}
run: |
body=$(cat outputs/title_errors)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
# Create commit comment
- name: Create commit comment
if: ${{ steps.STDERR.outputs.empty && steps.XMLERR.outputs.empty }}
uses: peter-evans/commit-comment@v3
with:
body: |
<details>
<summary>
These are the currently missing titles:</summary>
${{ steps.get-comment-body-titles.outputs.body }}
</details>
<details>
<summary>
These are the currently missing translations:</summary>
${{ steps.get-comment-body-translations.outputs.body }}
</details>
<details>
<summary>
These are the errors found in titles:</summary>
${{ steps.get-title-errors-body-translations.outputs.body }}
</details>
# Create output log comment
- name: Get log comment body
id: get-log-body-translations
run: |
body=$(cat outputs/STDOUT)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Create log commit comment
uses: peter-evans/commit-comment@v3
with:
body: |
<details>
<summary>
This is the rest of the output log. Please check for additional errors:</summary>
```python
${{ steps.get-log-body-translations.outputs.body }}
```
# Actually fail on error
- name: Check if errors occurred
if: ${{ steps.STDERR.outputs.full || steps.XMLERR.outputs.full }}
run: exit 1