|
1 | | -# Template. Installed as .github/workflows/i18n-completeness.yml in each repo |
2 | | -# that holds English. Keep the filename, because exercism/i18n's |
3 | | -# rerun-source-check.yml finds this workflow's runs by it. Don't edit a copy in |
4 | | -# a source repo. Edit exercism/i18n/source-repo-workflows/ and re-sync. |
| 1 | +# This workflow is installed as .github/workflows/i18n-completeness.yml in |
| 2 | +# every repo that holds English. Don't edit it in those repos. Edit it in |
| 3 | +# exercism/i18n/source-repo-workflows/ and copy it to each repo. Keep the file |
| 4 | +# name, because exercism/i18n's rerun-source-check.yml looks for it. |
5 | 5 | # |
6 | | -# This workflow checks whether exercism/i18n holds the translation for every |
7 | | -# production locale for all the English changed in a PR. If any translation is |
8 | | -# missing, the check fails. Once `completeness` is a required status check on |
9 | | -# `main`, a PR can't be merged until its translations exist. |
| 6 | +# This workflow checks that exercism/i18n has a translation of all the English |
| 7 | +# a PR changes, and fails if anything is missing. The work happens in |
| 8 | +# exercism/i18n/.github/workflows/source-completeness.yml. This file only sets |
| 9 | +# when it runs and what it is allowed to do. |
10 | 10 | # |
11 | | -# The logic lives in exercism/i18n's scripts/completeness.mjs. This workflow |
12 | | -# fetches what that script needs and runs it. |
13 | | -# |
14 | | -# Fork safety: |
15 | | -# |
16 | | -# - It runs on `pull_request`, so PRs from forks get a read-only token and no |
17 | | -# secrets. It doesn't need any, because both repos are public. |
18 | | -# - The PR is never checked out. Its merge ref is fetched into a bare |
19 | | -# repository without file contents and read with `git ls-tree` and |
20 | | -# `git cat-file`, so nothing from the PR is written to disk or run. |
21 | | -# - The only code that runs is exercism/i18n's scripts, from its `main` branch. |
22 | | -# - Website YAML and TypeScript files are parsed as data and never run. |
23 | | -# |
24 | | -# What counts as a change: |
25 | | -# |
26 | | -# GitHub's `refs/pull/<n>/merge` is what `main` would look like after the merge, |
27 | | -# and its first parent is the current `main`. The check compares the two, so a |
28 | | -# PR only needs translations for the English it adds or changes. If the PR has |
29 | | -# a merge conflict, GitHub has no merge ref and the check fails with a message |
30 | | -# saying so. |
| 11 | +# GitHub reports this check as `i18n / completeness`. To make it a required |
| 12 | +# check, require that name. |
31 | 13 |
|
32 | 14 | name: i18n completeness |
33 | 15 |
|
34 | 16 | on: |
35 | 17 | pull_request: |
36 | 18 | branches: [main] |
37 | 19 |
|
38 | | -permissions: |
39 | | - contents: read |
40 | | - |
41 | | -concurrency: |
42 | | - group: i18n-completeness-${{ github.event.pull_request.number }} |
43 | | - cancel-in-progress: true |
| 20 | +permissions: {} |
44 | 21 |
|
45 | 22 | jobs: |
46 | | - completeness: |
47 | | - runs-on: ubuntu-latest |
48 | | - steps: |
49 | | - # Checks out exercism/i18n for its scripts and translations. The PR's own |
50 | | - # repo is never checked out. |
51 | | - # |
52 | | - # TODO(iHiD): once locales/ holds a few hundred thousand files, make this a |
53 | | - # sparse checkout of scripts/, the two JSON files and the production |
54 | | - # locales only. |
55 | | - - name: Check out exercism/i18n (scripts and translations) |
56 | | - uses: actions/checkout@v7 |
57 | | - with: |
58 | | - repository: exercism/i18n |
59 | | - ref: main |
60 | | - path: i18n |
61 | | - persist-credentials: false |
62 | | - |
63 | | - - uses: pnpm/action-setup@v6 |
64 | | - with: |
65 | | - package_json_file: i18n/package.json |
66 | | - |
67 | | - - uses: actions/setup-node@v7 |
68 | | - with: |
69 | | - node-version: 24 |
70 | | - |
71 | | - # Installs the scripts' one dependency, `yaml`, which is only needed for |
72 | | - # the website. |
73 | | - - name: Install |
74 | | - run: pnpm install --frozen-lockfile --dir i18n |
75 | | - |
76 | | - - name: Fetch the PR's merge ref as git objects (no working tree) |
77 | | - env: |
78 | | - REPO: ${{ github.repository }} |
79 | | - PR: ${{ github.event.pull_request.number }} |
80 | | - run: | |
81 | | - set -euo pipefail |
82 | | - git init --quiet --bare pr |
83 | | - git -C pr remote add origin "https://github.com/${REPO}.git" |
84 | | - git -C pr config remote.origin.promisor true |
85 | | - git -C pr config remote.origin.partialclonefilter blob:none |
86 | | - if ! git -C pr fetch --quiet --depth=2 --filter=blob:none --no-tags origin "refs/pull/${PR}/merge"; then |
87 | | - echo "::error::This PR has no merge ref, which usually means it conflicts with main. Resolve the conflict and this check will run." |
88 | | - exit 1 |
89 | | - fi |
90 | | -
|
91 | | - - name: Does exercism/i18n hold every translation this PR needs? |
92 | | - env: |
93 | | - REPO: ${{ github.repository }} |
94 | | - run: node i18n/scripts/completeness.mjs --source-repo=pr --repo="$REPO" --head=FETCH_HEAD --base='FETCH_HEAD^1' |
| 23 | + i18n: |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + uses: exercism/i18n/.github/workflows/source-completeness.yml@main |
0 commit comments