Monitor multilingual compatibility #12
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: Monitor multilingual compatibility | |
| on: | |
| schedule: | |
| - cron: "45 5 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| compat: | |
| name: Compatibility (${{ matrix.channel.name }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| channel: | |
| - name: pinned | |
| install_command: python -m pip install -r requirements-build.txt | |
| - name: latest | |
| install_command: python -m pip install multilingualprogramming | |
| - name: upstream-main | |
| install_command: python -m pip install "multilingualprogramming @ git+https://github.com/johnsamuelwrites/multilingual.git@main" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install monitored package | |
| run: | | |
| python -m pip install --upgrade pip | |
| ${{ matrix.channel.install_command }} | |
| - name: Capture dependency metadata | |
| env: | |
| CHANNEL_NAME: ${{ matrix.channel.name }} | |
| run: | | |
| python - <<'PY' | |
| import json | |
| import os | |
| import pathlib | |
| import subprocess | |
| data = { | |
| "channel": os.environ["CHANNEL_NAME"], | |
| "pip_freeze": subprocess.check_output(["python", "-m", "pip", "freeze"], text=True).splitlines(), | |
| } | |
| try: | |
| from multilingualprogramming.version import __version__ | |
| data["multilingual_version"] = __version__ | |
| except Exception as exc: | |
| data["multilingual_version_error"] = str(exc) | |
| out = pathlib.Path("build") | |
| out.mkdir(exist_ok=True) | |
| path = out / f"multilingual-metadata-{os.environ['CHANNEL_NAME']}.json" | |
| path.write_text(json.dumps(data, indent=2), encoding="utf-8") | |
| print(path.read_text(encoding="utf-8")) | |
| PY | |
| - name: Validate release metadata | |
| run: python tools/check_release.py | |
| - name: Check local links | |
| run: python tools/check_links.py | |
| - name: Execute all example programs | |
| run: python tools/check_examples.py | |
| - name: Upload metadata artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playground-multilingual-${{ matrix.channel.name }} | |
| path: build/multilingual-metadata-${{ matrix.channel.name }}.json | |
| notifier: | |
| name: Open issue on scheduled failure | |
| if: failure() && github.event_name == 'schedule' | |
| runs-on: ubuntu-latest | |
| needs: compat | |
| steps: | |
| - name: Create or update compatibility issue | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const title = 'Compatibility alert: multilingual monitor failed'; | |
| const { owner, repo } = context.repo; | |
| const existing = await github.rest.issues.listForRepo({ owner, repo, state: 'open', per_page: 100 }); | |
| const match = existing.data.find((issue) => issue.title === title); | |
| const body = [ | |
| 'The scheduled multilingual compatibility monitor failed.', | |
| '', | |
| `Workflow: ${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`, | |
| `Date: ${new Date().toISOString()}`, | |
| '', | |
| 'Check the `latest` and `upstream-main` jobs first to find the regression source.', | |
| ].join('\n'); | |
| if (match) { | |
| await github.rest.issues.createComment({ owner, repo, issue_number: match.number, body }); | |
| return; | |
| } | |
| await github.rest.issues.create({ owner, repo, title, body, labels: ['bug'] }); |