Repository navigation
Alt/lean #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Alt/lean #231
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fa30333
Add Italian language and point the fork at its own releases (#1)
1r0n51uv 2df8728
Add Italian README (#2)
1r0n51uv b2c2acb
Fork sync: automatic merge and release of clean upstream syncs (#3)
1r0n51uv d9beefc
feat: remove TV control (Android TV, Wake-on-LAN, HDMI input)
1r0n51uv e7d8b6f
feat: remove RTSS (FPS limit and counter) and per-game profiles
1r0n51uv c343e77
feat: remove local API, consolemode:// links, DDC/CI power-off and th…
1r0n51uv 2407d64
docs: update READMEs, guides, test checklist and changelogs for the l…
1r0n51uv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #!/usr/bin/env bash | ||
| # Decides whether a sync PR (branch sync/vX, opened by the dojo's keeper agent) can be merged without | ||
| # a person, and if so merges it and starts the release. Clean means: | ||
| # - the CI passed on the PR's latest commit; | ||
| # - the upstream tag merges into main without conflicts (git merge-tree); | ||
| # - what the agent changed on top of that clean merge stays inside ALLOWED_FILES, or inside | ||
| # LINE_RULES files on lines matching their regex (versions, translation entries). | ||
| # Anything else gets the needs-review label and a comment, and waits for the owner. | ||
| # Configured by the calling workflow: UPSTREAM, ALLOWED_FILES, LINE_RULES, VERSION_FILE, | ||
| # VERSION_PATTERN, RELEASE_WORKFLOW, RELEASE_INPUTS, plus BRANCH, HEAD_SHA, CONCLUSION. | ||
| set -euo pipefail | ||
|
|
||
| tag=${BRANCH#sync/} | ||
| pr=$(gh pr list --head "$BRANCH" --state open --json number,headRefOid,labels \ | ||
| --jq '.[0] | select(.) | "\(.number) \(.headRefOid) \([.labels[].name] | join(","))"') | ||
| if [[ -z $pr ]]; then | ||
| echo "No open PR for $BRANCH." | ||
| exit 0 | ||
| fi | ||
| read -r num head labels <<<"$pr" | ||
| if [[ ,$labels, == *,needs-review,* ]]; then | ||
| echo "PR #$num is waiting for a review: nothing to do." | ||
| exit 0 | ||
| fi | ||
| if [[ $head != "$HEAD_SHA" ]]; then | ||
| echo "The CI ran on $HEAD_SHA, the PR is at $head: the next CI run decides." | ||
| exit 0 | ||
| fi | ||
| if [[ $CONCLUSION != success ]]; then | ||
| echo "CI $CONCLUSION on PR #$num: the agent or the owner fixes it, the next green run decides." | ||
| exit 0 | ||
| fi | ||
|
|
||
| review() { | ||
| gh label create needs-review --color D93F0B --description "Sync PR that needs a person" 2>/dev/null || true | ||
| gh pr edit "$num" --add-label needs-review | ||
| gh pr comment "$num" --body "Fork sync: not merged automatically. $1" | ||
| echo "$1" | ||
| exit 0 | ||
| } | ||
|
|
||
| git fetch -q origin main "$BRANCH" | ||
| git fetch -q --no-tags "https://github.com/$UPSTREAM.git" "refs/tags/$tag:refs/tags/$tag" | ||
| head_ref=origin/$BRANCH | ||
|
|
||
| git merge-base --is-ancestor "$tag" "$head_ref" || review "The branch does not contain upstream \`$tag\`." | ||
| if ! git merge-base --is-ancestor origin/main "$head_ref"; then | ||
| gh pr comment "$num" --body "Fork sync: \`main\` moved after this branch was created. Merge \`main\` into it; the next green CI decides." | ||
| exit 0 | ||
| fi | ||
| if ! out=$(git merge-tree --write-tree origin/main "$tag"); then | ||
| review "Upstream \`$tag\` conflicts with \`main\`: the agent resolved code by hand." | ||
| fi | ||
| clean=$(head -1 <<<"$out") | ||
|
|
||
| declare -A rules=() | ||
| while IFS= read -r line; do | ||
| [[ -n $line ]] || continue | ||
| rules[${line%% :: *}]=${line#* :: } | ||
| done <<<"$LINE_RULES" | ||
|
|
||
| while IFS= read -r file; do | ||
| [[ -n $file ]] || continue | ||
| if grep -qxF -- "$file" <<<"$ALLOWED_FILES"; then | ||
| continue | ||
| fi | ||
| if [[ -n ${rules[$file]:-} ]]; then | ||
| other=$(git diff -U0 "$clean" "$head_ref" -- "$file" | grep -E '^[+-]' | grep -Ev '^(\+\+\+|---) ' | cut -c2- | | ||
| grep -Evx -- "${rules[$file]}" || true) | ||
| [[ -z $other ]] || review "\`$file\` changes lines other than the allowed ones:"$'\n\n```\n'"$other"$'\n```' | ||
| continue | ||
| fi | ||
| review "\`$file\` is not among the files the agent may change on its own." | ||
| done < <(git diff --name-only "$clean" "$head_ref") | ||
|
|
||
| gh pr merge "$num" --merge --match-head-commit "$HEAD_SHA" | ||
| git fetch -q origin main | ||
| version=$(git show "origin/main:$VERSION_FILE" | perl -ne 'if (/$ENV{VERSION_PATTERN}/) { print $1; exit }') | ||
| [[ -n $version ]] || { echo "Version not found in $VERSION_FILE" >&2; exit 1; } | ||
| args=() | ||
| while IFS= read -r input; do | ||
| [[ -n $input ]] && args+=(-f "${input//\{version\}/$version}") | ||
| done <<<"$RELEASE_INPUTS" | ||
| gh workflow run "$RELEASE_WORKFLOW" --ref main "${args[@]}" | ||
| echo "Merged PR #$num and started the $version release." | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: Fork sync | ||
|
|
||
| # This repo is a fork of lippdev/consolemode (see FORK.md). The dojo's keeper agent opens a PR from | ||
| # sync/vX when upstream publishes vX. When the CI of that PR finishes, this decides with fixed rules, | ||
| # no AI: a clean sync is merged and released (Release workflow, "publish" ticked); anything else | ||
| # gets the needs-review label and waits for the owner. The rules live in .github/scripts/fork-sync.sh. | ||
| on: | ||
| workflow_run: | ||
| workflows: [CI] | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| # Starts the Release workflow. | ||
| actions: write | ||
|
|
||
| concurrency: | ||
| group: fork-sync | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| merge: | ||
| if: github.event.workflow_run.event == 'pull_request' && startsWith(github.event.workflow_run.head_branch, 'sync/v') | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| ref: main | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Merge and release a clean sync | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| BRANCH: ${{ github.event.workflow_run.head_branch }} | ||
| HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | ||
| CONCLUSION: ${{ github.event.workflow_run.conclusion }} | ||
| UPSTREAM: lippdev/consolemode | ||
| # What the agent may change on top of the clean merge: the Italian catalog and docs, and the | ||
| # changelogs the release reads its notes from. | ||
| ALLOWED_FILES: | | ||
| src/ConsoleMode/Resources/Strings.it-IT.json | ||
| README.it-IT.md | ||
| CHANGELOG.md | ||
| CHANGELOG.en-US.md | ||
| # file :: regex every changed line of that file must match (whole line). | ||
| LINE_RULES: | | ||
| src/ConsoleMode/ConsoleMode.csproj :: \s*<(Version|AssemblyVersion|FileVersion|InformationalVersion)>[0-9.]+</\1>\s* | ||
| VERSION_FILE: src/ConsoleMode/ConsoleMode.csproj | ||
| VERSION_PATTERN: <Version>([^<]+)</Version> | ||
| RELEASE_WORKFLOW: release.yml | ||
| RELEASE_INPUTS: | | ||
| version={version} | ||
| publish=true | ||
| run: .github/scripts/fork-sync.sh |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Fork notes | ||
|
|
||
| This is a fork of [lippdev/consolemode](https://github.com/lippdev/consolemode). The dojo's | ||
| `keeper` agent (see `1r0n51uv/ron1n-dojo`, FLOW-013) reads this file every time upstream publishes a | ||
| release, merges it here and opens a PR from `sync/vX`. Keep it current: it is what the agent knows | ||
| about what we changed. | ||
|
|
||
| ## Lean edition (branch `alt/lean`) | ||
|
|
||
| This branch deliberately diverges from upstream and is **not** part of the keeper's sync flow. It removes | ||
| TV control, RTSS (FPS limit and counter), per-game profiles, the local control API, `consolemode://` links, | ||
| DDC/CI power-off and the es/de/fr/ru catalogs, and is meant to be redesigned further. Merging upstream into it | ||
| will conflict heavily; do it by hand, not with the keeper. | ||
|
|
||
| ## What we changed | ||
|
|
||
| - **Italian**: `src/ConsoleMode/Resources/Strings.it-IT.json` (a catalog with every key of | ||
| `Strings.en-US.json`), its wiring (`ConsoleMode.csproj`, `Tests.csproj`, `LocalizationService.cs`, | ||
| `LocalizationTests.cs`, `build/ConsoleMode.iss`), `README.it-IT.md`, the language line of the other | ||
| READMEs, `docs/TESTING.md` and `docs/TRANSLATING.md`. | ||
| - **Updates and links point at the fork**: `UpdateService.Repository`, the changelog link in | ||
| `release.yml`, the installer URLs in `build/ConsoleMode.iss`. Never take upstream's value here. | ||
| - **Fork automation**: `.github/workflows/fork-sync.yml`, `.github/scripts/fork-sync.sh`, this file. | ||
| `winget.yml`/`release.yml`'s winget job stay off (no `WINGET_TOKEN`). | ||
|
|
||
| ## Rules for a sync | ||
|
|
||
| 1. Branch `sync/v<upstream version>` from `main`, then merge the upstream **tag** (`git merge v<X>`), | ||
| never a squash: the history must keep upstream's commits. | ||
| 2. On a conflict, keep upstream's code and re-apply our changes above on top. | ||
| 3. Every key upstream added to `Strings.en-US.json` goes into `Strings.it-IT.json`, translated | ||
| (the localization tests fail on a missing key, a wrong `{0}` or an untranslated sentence). Run | ||
| `dotnet test tests/ConsoleMode.Tests/ConsoleMode.Tests.csproj` (in a `mcr.microsoft.com/dotnet/sdk:8.0` | ||
| container when `dotnet` is missing). | ||
| 4. **Version**: the fork's version is the higher of upstream's and ours; if ours is higher or equal, | ||
| ours +1 patch. Set it in `src/ConsoleMode/ConsoleMode.csproj`: `Version`, `AssemblyVersion`, | ||
| `FileVersion` and `InformationalVersion`. | ||
| 5. **Changelog**: a `## [<version>]` section in **both** `CHANGELOG.md` (Portuguese) and | ||
| `CHANGELOG.en-US.md`; the release fails without them. Keep upstream's sections, add ours on top. | ||
| 6. Anything beyond the Italian catalog, `README.it-IT.md`, the changelogs and the version lines | ||
| makes the PR "not clean": it waits for the owner (`needs-review`). | ||
| 7. Never push to `main`, never merge: `fork-sync.yml` decides, with fixed rules, after the CI is green. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lookup selects the first open PR with this branch name, but the checks below validate
origin/$BRANCHrather than that PR's actual head. A fork PR namedsync/v…can therefore be merged with its arbitrary changes while the script checks a different, trusted branch; the privileged workflow then starts a release.Technical details