|
| 1 | +name: Check Documentation |
| 2 | + |
| 3 | +# This action runs: |
| 4 | +# - When this file changes |
| 5 | +# - When changes on documentation (doc) |
| 6 | +# - When changes on translation (locale) |
| 7 | +# - When the way the documentation build changes (CMakeLists.txt, doc/CMakeLists.txt, doc/conf.py.in) |
| 8 | +# |
| 9 | +# documentation is tested only on: |
| 10 | +# - ubuntu-latest |
| 11 | +# - default postgres installed on ubuntu-latest |
| 12 | + |
| 13 | +on: |
| 14 | + workflow_dispatch: |
| 15 | + push: |
| 16 | + paths: |
| 17 | + - '.github/workflows/documentation.yml' |
| 18 | + - 'doc/**' |
| 19 | + - 'locale/**' |
| 20 | + - 'CMakeLists.txt' |
| 21 | + |
| 22 | + branches-ignore: |
| 23 | + - 'gh-pages' |
| 24 | + |
| 25 | + tags: [] |
| 26 | + |
| 27 | + pull_request: |
| 28 | + paths: |
| 29 | + - '.github/workflows/documentation.yml' |
| 30 | + - 'doc/**' |
| 31 | + - 'locale/**' |
| 32 | + - 'CMakeLists.txt' |
| 33 | + |
| 34 | +concurrency: |
| 35 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 36 | + cancel-in-progress: true |
| 37 | + |
| 38 | +permissions: |
| 39 | + contents: read |
| 40 | + |
| 41 | +env: |
| 42 | + release: Release |
| 43 | + os: ubuntu-latest |
| 44 | + |
| 45 | +jobs: |
| 46 | + check-documentation: |
| 47 | + name: documentation |
| 48 | + runs-on: ubuntu-latest |
| 49 | + |
| 50 | + strategy: |
| 51 | + fail-fast: false |
| 52 | + matrix: |
| 53 | + language: [en] |
| 54 | + os: [ubuntu-latest] |
| 55 | + |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + fetch-depth: 2 |
| 60 | + |
| 61 | + - name: check modified files |
| 62 | + id: check_files |
| 63 | + run: | |
| 64 | + # allways processing english, no matter what the change was |
| 65 | + if [[ "${{ matrix.language }}" == "en" ]]; then echo "PROCESS=true" >> $GITHUB_ENV; echo "CHK_LINK=true" >> $GITHUB_ENV; exit 0; fi |
| 66 | +
|
| 67 | + if [[ "${{ matrix.language }}" == "zh_Hans" && "${{ github.repository_owner }}" != "pgRouting" ]]; then echo "PROCESS=false" >> $GITHUB_ENV; exit 0; fi |
| 68 | +
|
| 69 | + # when this file changes all languages are tested |
| 70 | + if git diff --name-only HEAD^ HEAD | grep -q '.github/workflows/documentation.yml' ; then echo "PROCESS=true" >> $GITHUB_ENV; exit 0; fi |
| 71 | +
|
| 72 | + # when there is a change on the way the build is done all languages are tested |
| 73 | + if git diff --name-only HEAD^ HEAD | grep -q '^CMakeLists.txt' ; then echo "PROCESS=true" >> $GITHUB_ENV; exit 0; fi |
| 74 | + if git diff --name-only HEAD^ HEAD | grep -q '^doc/CMakeLists.txt' ; then echo "PROCESS=true" >> $GITHUB_ENV; exit 0; fi |
| 75 | + if git diff --name-only HEAD^ HEAD | grep -q '^doc/conf.py.in' ; then echo "PROCESS=true" >> $GITHUB_ENV; exit 0; fi |
| 76 | +
|
| 77 | + # if there is a change on the translation |
| 78 | + if git diff --name-only HEAD^ HEAD | grep -q "^locale/${{ matrix.language }}" ; then echo "PROCESS=true" >> $GITHUB_ENV; echo "CHK_LINK=true" >> $GITHUB_ENV; exit 0; fi |
| 79 | +
|
| 80 | + - name: Get postgres version |
| 81 | + if: env.PROCESS == 'true' |
| 82 | + run: | |
| 83 | + sudo service postgresql start |
| 84 | + PGVER=$(psql --version | grep -Po '(?<=psql \(PostgreSQL\) )[^;]+(?=\.\d+ \()') |
| 85 | + echo "PGVER=${PGVER}" >> $GITHUB_ENV |
| 86 | + echo "PGPORT=5432" >> $GITHUB_ENV |
| 87 | +
|
| 88 | + - name: Install python |
| 89 | + if: env.PROCESS == 'true' |
| 90 | + uses: actions/setup-python@v5 |
| 91 | + with: |
| 92 | + python-version: '3.12' |
| 93 | + |
| 94 | + - name: Install dependencies |
| 95 | + if: env.PROCESS == 'true' |
| 96 | + run: | |
| 97 | + sudo apt-get update |
| 98 | +
|
| 99 | + # Basic dependencies |
| 100 | + sudo apt-get install -y \ |
| 101 | + postgresql-${PGVER} \ |
| 102 | + postgresql-server-dev-${PGVER} |
| 103 | +
|
| 104 | + # documentation dependencies |
| 105 | + sudo apt-get install -y \ |
| 106 | + graphviz \ |
| 107 | + python3-sphinx \ |
| 108 | + python3-sphinx-bootstrap-theme \ |
| 109 | + sphinx-intl |
| 110 | +
|
| 111 | + - name: Install Google OR-Tools |
| 112 | + if: env.PROCESS == 'true' |
| 113 | + run: | |
| 114 | + sudo pip install --root=/ ortools==9.10.4067 |
| 115 | +
|
| 116 | + - name: Configure |
| 117 | + if: env.PROCESS == 'true' |
| 118 | + run: | |
| 119 | + mkdir build |
| 120 | + cd build |
| 121 | + cmake -DCMAKE_BUILD_TYPE=${{ env.release }} \ |
| 122 | + -DSPHINX_LINKCHECK=ON .. |
| 123 | +
|
| 124 | + - name: Build Documentation |
| 125 | + if: env.PROCESS == 'true' |
| 126 | + run: | |
| 127 | + cd build |
| 128 | + make html-${{ matrix.language }} |
| 129 | +
|
| 130 | + - name: Check Links |
| 131 | + if: env.CHK_LINK == 'true' |
| 132 | + run: | |
| 133 | + cd build |
| 134 | + make linkcheck-${{ matrix.language }} |
0 commit comments