Skip to content
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

github: Fix weblate action's rights, and update generated code. #1262

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion .github/workflows/update-translations.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
name: Update translations from Weblate
permissions:
contents: write
pull-requests: write
on:
pull_request:
schedule:
- cron: "0 10 * * 1"
workflow_dispatch:

jobs:
update-translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch and merge from Weblate
# The commit message is generated in Weblate; see https://hosted.weblate.org/addon/17163/
run: |
git checkout -b main
git log --oneline --graph --all -n5
git remote add weblate https://hosted.weblate.org/git/zulip/zulip-flutter/
git fetch weblate
git merge --ff-only weblate/main
GIT_COMMITTER_NAME="Hosted Weblate" GIT_COMMITTER_EMAIL="[email protected]" \
git cherry-pick weblate/main ^HEAD
Comment on lines -16 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I guess there's a race where if origin/main just got updated and Weblate hasn't taken that update yet, the merge --ff-only will fail.

How about reset --hard? Then the PR's base will be slightly behind the tip, but that's normal. We'll rebase it forward as part of merge like we do for many other PRs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, this change is part of the "run on this PR" don't-merge commit. Never mind, then.

(There still is that race, but it's unlikely.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One option is we can git reset --hard weblate/main and let the PR potentially be behind main if weblate is lagging. Which means one might get a PR with "cannot merge" rather than the failure one gets with git merge --ff-only, which is that the whole action fails.


- name: Clone Flutter SDK
# TODO(#1204) reinstate shallow clone with --depth=1000 and its corresponding comment here
run: |
git clone -b main https://github.com/flutter/flutter ~/flutter
TZ=UTC git --git-dir ~/flutter/.git log -1 --format='%h | %ci | %s' --date=iso8601-local
echo ~/flutter/bin >> "$GITHUB_PATH"

# The Flutter tool assumes the tip of tree is "origin/master"
# (or "upstream/master"):
# https://github.com/flutter/flutter/issues/160626
# TODO(upstream): make workaround unneeded
git --git-dir ~/flutter/.git update-ref refs/remotes/origin/master origin/main

- name: Update generated code
run: |
mkdir -p build
tools/check l10n --fix
git add lib/generated/l10n/
GIT_COMMITTER_NAME="Hosted Weblate" GIT_COMMITTER_EMAIL="[email protected]" \
git commit --amend -C HEAD

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: update-translations/weblate
delete-branch: true
title: Update translations from Weblate
base: ${{ github.head_ref }}
Loading