mirror of
https://github.com/D-Modem/app.git
synced 2026-11-28 17:38:05 -08:00
Android's unit tests fail on main (runs 411, 413, 417, 419, 424): each Robolectric test fails in MavenArtifactFetcher with an IOException. Robolectric downloads its Android framework jars (about 200 MB each) during the tests, and Maven Central refuses some downloads with HTTP 429 (its rate limit). Now Gradle downloads the two jars that the tests use (SDK 28 and SDK 35), with its retries and its cache, and Robolectric runs offline from their directory. -ProbolectricRepoUrl=<a mirror> still makes Robolectric download them itself from that mirror. Gradle tries a refused download again, up to 6 times (gradle.properties). The D-Modem bump checked out the commit that its event names. A run that waited for the run before it therefore built on an old main, and its pull request (#103) conflicted with the one that the earlier run merged (#102). Now it checks out main as it is when the run starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRSYSk1rgeTZ9ZWMcZL Signed-off-by: Neo-Desktop <321592+Neo-Desktop@users.noreply.github.com>
143 lines
5.7 KiB
YAML
143 lines
5.7 KiB
YAML
# D-Modem bump: moves the external/d-modem-re submodule to D-Modem's
|
|
# latest main, with the AT command reference that comes with it (the
|
|
# app's assets' copy, tools/at_reference.py), and opens (or updates) a pull request for it, set to merge
|
|
# by itself once its checks pass. Daily, by hand (Actions > D-Modem bump >
|
|
# Run workflow), or from D-Modem (a repository_dispatch of type
|
|
# "d-modem-main", for when its main changes).
|
|
#
|
|
# It needs the DMODEM_BUMP_TOKEN secret (an organization secret): a
|
|
# fine-grained personal access token with Contents: read and write and
|
|
# Pull requests: read and write on D-Modem/app. Not the workflow's own GITHUB_TOKEN: a pull request that
|
|
# token opens starts no other workflow, so Android's checks would never
|
|
# run on it. Without the secret the run says so and stops.
|
|
#
|
|
# It merges the pull request itself once every check on it has passed
|
|
# (it waits for them: GitHub's auto-merge, with no checks required on
|
|
# main, would merge at once, before any ran); a failed check leaves it
|
|
# open for a person.
|
|
name: D-Modem bump
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "17 6 * * *"
|
|
repository_dispatch:
|
|
types: [d-modem-main]
|
|
workflow_dispatch:
|
|
|
|
# (one bump at a time: a second waits for the first)
|
|
concurrency:
|
|
group: d-modem-bump
|
|
cancel-in-progress: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
BRANCH: bot/d-modem-bump
|
|
|
|
jobs:
|
|
bump:
|
|
runs-on: ubuntu-24.04
|
|
# (a hung step ends here, not at GitHub's 6 hours)
|
|
# (the Android checks take about 15 minutes)
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: Token present
|
|
env:
|
|
TOKEN: ${{ secrets.DMODEM_BUMP_TOKEN }}
|
|
run: |
|
|
if [ -z "$TOKEN" ]; then
|
|
echo "::error::No DMODEM_BUMP_TOKEN secret (see this workflow's header)"
|
|
exit 1
|
|
fi
|
|
|
|
# main as it is now, not the commit the event names: a run that waited for the one before it
|
|
# (concurrency) builds on the main that the earlier run merged into, and does not conflict with it
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
token: ${{ secrets.DMODEM_BUMP_TOKEN }}
|
|
ref: main
|
|
fetch-depth: 0
|
|
|
|
# only the D-Modem submodule (proot stays where it is)
|
|
- name: D-Modem's latest main
|
|
id: bump
|
|
run: |
|
|
git submodule update --init external/d-modem-re
|
|
old=$(git -C external/d-modem-re rev-parse HEAD)
|
|
git -C external/d-modem-re fetch --quiet origin main
|
|
new=$(git -C external/d-modem-re rev-parse FETCH_HEAD)
|
|
echo "old=$old" >> "$GITHUB_OUTPUT"
|
|
echo "new=$new" >> "$GITHUB_OUTPUT"
|
|
if [ "$old" = "$new" ]; then
|
|
echo "Already at D-Modem main ${new:0:7}"
|
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
git -C external/d-modem-re checkout --quiet "$new"
|
|
python3 tools/at_reference.py
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
{
|
|
echo 'log<<EOF'
|
|
git -C external/d-modem-re log --oneline --no-merges "$old..$new" | head -50
|
|
echo 'EOF'
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Commit and push
|
|
id: commit
|
|
if: steps.bump.outputs.changed == 'true'
|
|
env:
|
|
OLD: ${{ steps.bump.outputs.old }}
|
|
NEW: ${{ steps.bump.outputs.new }}
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git checkout -B "$BRANCH"
|
|
git add external/d-modem-re app/src/main/assets/docs
|
|
git commit -m "Bump D-Modem to ${NEW:0:7}" \
|
|
-m "external/d-modem-re: ${OLD:0:7} -> ${NEW:0:7} (D-Modem's main), and its AT command reference." \
|
|
-m "Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
|
|
git push --force origin "$BRANCH"
|
|
echo "head=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Pull request
|
|
id: pr
|
|
if: steps.bump.outputs.changed == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.DMODEM_BUMP_TOKEN }}
|
|
OLD: ${{ steps.bump.outputs.old }}
|
|
NEW: ${{ steps.bump.outputs.new }}
|
|
LOG: ${{ steps.bump.outputs.log }}
|
|
run: |
|
|
body=$(printf 'Moves `external/d-modem-re` to D-Modem main: [`%s..%s`](https://github.com/D-Modem/D-Modem/compare/%s...%s)\n\n```\n%s\n```\n\nOpened by the D-Modem bump workflow (`.github/workflows/d-modem-bump.yml`); it merges once the checks pass.\n' \
|
|
"${OLD:0:7}" "${NEW:0:7}" "$OLD" "$NEW" "$LOG")
|
|
title="Bump D-Modem to ${NEW:0:7}"
|
|
pr=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
|
|
if [ -n "$pr" ]; then
|
|
gh pr edit "$pr" --title "$title" --body "$body"
|
|
else
|
|
gh pr create --base main --head "$BRANCH" --title "$title" --body "$body"
|
|
pr=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
|
|
fi
|
|
echo "number=$pr" >> "$GITHUB_OUTPUT"
|
|
|
|
# (the checks a moment to start; then all of them waited for)
|
|
- name: Merged once its checks pass
|
|
if: steps.bump.outputs.changed == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.DMODEM_BUMP_TOKEN }}
|
|
PR: ${{ steps.pr.outputs.number }}
|
|
HEAD: ${{ steps.commit.outputs.head }}
|
|
run: |
|
|
for i in $(seq 1 20); do
|
|
n=$(gh pr checks "$PR" --json name --jq length 2>/dev/null || true)
|
|
[ "${n:-0}" -gt 0 ] && break
|
|
sleep 15
|
|
done
|
|
sleep 30
|
|
if ! gh pr checks "$PR" --watch --interval 30; then
|
|
echo "::warning::A check failed on pull request #$PR: it waits for a person"
|
|
exit 1
|
|
fi
|
|
gh pr merge "$PR" --merge --match-head-commit "$HEAD"
|