|
| 1 | +name: Docs multilingual compatibility monitor |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "40 5 * * *" |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + issues: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + compat: |
| 14 | + name: Docs compatibility (${{ matrix.channel.name }}) |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + channel: |
| 20 | + - name: pinned |
| 21 | + install_command: python -m pip install -r requirements-build.txt |
| 22 | + - name: latest |
| 23 | + install_command: python -m pip install multilingualprogramming |
| 24 | + - name: upstream-main |
| 25 | + install_command: python -m pip install "multilingualprogramming @ git+https://github.com/johnsamuelwrites/multilingual.git@main" |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Set up Python |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: "3.12" |
| 34 | + |
| 35 | + - name: Install Python dependencies |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + python -m pip install pytest PyYAML |
| 39 | + ${{ matrix.channel.install_command }} |
| 40 | +
|
| 41 | + - name: Capture dependency metadata |
| 42 | + env: |
| 43 | + CHANNEL_NAME: ${{ matrix.channel.name }} |
| 44 | + run: | |
| 45 | + python - <<'PY' |
| 46 | + import json |
| 47 | + import os |
| 48 | + import pathlib |
| 49 | + import subprocess |
| 50 | +
|
| 51 | + data = { |
| 52 | + "channel": os.environ["CHANNEL_NAME"], |
| 53 | + "pip_freeze": subprocess.check_output(["python", "-m", "pip", "freeze"], text=True).splitlines(), |
| 54 | + } |
| 55 | + try: |
| 56 | + from multilingualprogramming.version import __version__ |
| 57 | + data["multilingual_version"] = __version__ |
| 58 | + except Exception as exc: |
| 59 | + data["multilingual_version_error"] = str(exc) |
| 60 | +
|
| 61 | + out = pathlib.Path("build") |
| 62 | + out.mkdir(exist_ok=True) |
| 63 | + path = out / f"multilingual-metadata-{os.environ['CHANNEL_NAME']}.json" |
| 64 | + path.write_text(json.dumps(data, indent=2), encoding="utf-8") |
| 65 | + print(path.read_text(encoding="utf-8")) |
| 66 | + PY |
| 67 | +
|
| 68 | + - name: Validate multilingual docs metadata |
| 69 | + run: python scripts/validate_multilingual_docs.py --strict-freshness |
| 70 | + |
| 71 | + - name: Run docs tests |
| 72 | + run: python -m pytest _tests -q |
| 73 | + |
| 74 | + - name: Set up Ruby |
| 75 | + uses: ruby/setup-ruby@v1 |
| 76 | + with: |
| 77 | + ruby-version: "3.3" |
| 78 | + bundler-cache: true |
| 79 | + |
| 80 | + - name: Build Jekyll site |
| 81 | + run: bundle exec jekyll build --baseurl "/docs" |
| 82 | + |
| 83 | + - name: Check internal links |
| 84 | + run: python scripts/check_internal_links.py --site-dir _site --base-path /docs |
| 85 | + |
| 86 | + - name: Check Pages artifact |
| 87 | + run: python scripts/check_pages_artifact.py --site-dir _site --base-path /docs |
| 88 | + |
| 89 | + - name: Upload metadata artifact |
| 90 | + if: always() |
| 91 | + uses: actions/upload-artifact@v4 |
| 92 | + with: |
| 93 | + name: docs-multilingual-${{ matrix.channel.name }} |
| 94 | + path: build/multilingual-metadata-${{ matrix.channel.name }}.json |
| 95 | + |
| 96 | + notifier: |
| 97 | + name: Open issue on scheduled failure |
| 98 | + if: failure() && github.event_name == 'schedule' |
| 99 | + runs-on: ubuntu-latest |
| 100 | + needs: compat |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: Create or update compatibility issue |
| 104 | + uses: actions/github-script@v7 |
| 105 | + with: |
| 106 | + script: | |
| 107 | + const title = 'Compatibility alert: docs monitor failed against multilingual'; |
| 108 | + const { owner, repo } = context.repo; |
| 109 | + const existing = await github.rest.issues.listForRepo({ owner, repo, state: 'open', per_page: 100 }); |
| 110 | + const match = existing.data.find((issue) => issue.title === title); |
| 111 | + const body = [ |
| 112 | + 'The scheduled multilingual compatibility monitor for the docs site failed.', |
| 113 | + '', |
| 114 | + `Workflow: ${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`, |
| 115 | + `Date: ${new Date().toISOString()}`, |
| 116 | + '', |
| 117 | + 'Check the `latest` and `upstream-main` jobs first to see whether the regression is upstream or in the docs assumptions.', |
| 118 | + ].join('\n'); |
| 119 | +
|
| 120 | + if (match) { |
| 121 | + await github.rest.issues.createComment({ owner, repo, issue_number: match.number, body }); |
| 122 | + return; |
| 123 | + } |
| 124 | +
|
| 125 | + await github.rest.issues.create({ owner, repo, title, body, labels: ['bug'] }); |
0 commit comments