Added specific workflow for 2.0.x documentation regeneration. #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: validate-and-update_2_0_x | |
| on: | |
| pull_request: | |
| branches: | |
| - 2.0.x | |
| push: | |
| branches: | |
| - 2.0.x | |
| jobs: | |
| json-schema-validation: | |
| runs-on: ubuntu-latest | |
| name: JSON Schema validation through pre-commit | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pre-commit/action@v3.0.1 | |
| with: | |
| extra_args: --all -c .pre-commit-config.yaml | |
| generate-charts: | |
| runs-on: ubuntu-latest | |
| name: Generate graphical representations of the schemas | |
| needs: | |
| - json-schema-validation | |
| strategy: | |
| matrix: | |
| schema-version: [ "2.0.x" ] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 150 | |
| - uses: ts-graphviz/setup-graphviz@v2 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| cache: 'pip' | |
| architecture: x64 | |
| cache-dependency-path: 'dev-requirements.txt' | |
| - name: Install chart generator dependencies (development) | |
| run: | | |
| pip install --upgrade pip wheel | |
| pip install -r dev-requirements.txt | |
| - name: Changes at ${{ matrix.schema-version }} schemas | |
| id: changed | |
| run: | | |
| dotfile="json-schemas/openebench-bdm-${{ matrix.schema-version }}.dot" | |
| if [ -f "$dotfile" ] ; then | |
| at="$(git --no-pager log -p -1 "--format=tformat:%at" --no-patch -- "$dotfile")" | |
| dat="$at" | |
| find json-schemas/"${{ matrix.schema-version }}" -type f -name "*.json" | while read -r schema ; do | |
| dat="$(git --no-pager log -p -1 "--format=tformat:%at" --no-patch -- "$schema")" | |
| if [ "$at" -lt "$dat" ] ; then | |
| touch /tmp/there_were_changes.txt | |
| break | |
| fi | |
| done | |
| if [ -f /tmp/there_were_changes.txt ] ; then | |
| echo "any_changed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "any_changed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| else | |
| echo "any_changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Generated ${{ matrix.schema-version }} schema | |
| id: generate-if-changed | |
| if: steps.changed.outputs.any_changed == 'true' | |
| run: | | |
| ext-json-validate --dot-report openebench-bdm-${{ matrix.schema-version }}.dot "OpenEBench Benchmarking Data Model ${{ matrix.schema-version }}" json-schemas/${{ matrix.schema-version }} | |
| dot -Tpng openebench-bdm-${{ matrix.schema-version }}.dot -o openebench-bdm-${{ matrix.schema-version }}.dot.png | |
| dot -Tpdf openebench-bdm-${{ matrix.schema-version }}.dot -o openebench-bdm-${{ matrix.schema-version }}.dot.pdf | |
| dot -Tsvg openebench-bdm-${{ matrix.schema-version }}.dot -o openebench-bdm-${{ matrix.schema-version }}.dot.svg | |
| - uses: actions/upload-artifact@v7 | |
| if: steps.generate-if-changed.outcome == 'success' | |
| with: | |
| name: charts-${{ matrix.schema-version }} | |
| retention-days: 2 | |
| path: openebench-bdm-${{ matrix.schema-version }}.dot* | |
| push-charts: | |
| runs-on: ubuntu-latest | |
| name: Store newly generated charts | |
| needs: | |
| - generate-charts | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - id: download | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: charts-* | |
| merge-multiple: true | |
| path: charts-dir | |
| - id: move | |
| name: Move charts to their right place | |
| run: | | |
| skip=true | |
| if [ -d "${{steps.download.outputs.download-path}}" ] ; then | |
| mv "${{steps.download.outputs.download-path}}"/* json-schemas/ | |
| skip=false | |
| fi | |
| echo "skip=$skip" >> "$GITHUB_OUTPUT" | |
| - name: Create Pull Request | |
| id: cpr | |
| uses: peter-evans/create-pull-request@v8 | |
| if: steps.move.outputs.skip == 'false' | |
| with: | |
| title: Updated schemas documentation 2.0.x (triggered by ${{ github.sha }}) | |
| branch: create-pull-request/patch-schema-docs_2_0_x | |
| delete-branch: true | |
| signoff: true | |
| commit-message: "[create-pull-request] Automatically commit updated contents (generated schemas documentation for 2.0.x)" | |
| - name: Check outputs | |
| if: ${{ steps.cpr.outputs.pull-request-number }} | |
| run: | | |
| echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
| echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |