-
Notifications
You must be signed in to change notification settings - Fork 32
165 lines (148 loc) · 6.45 KB
/
Copy pathfetch-source-pkg.yml
File metadata and controls
165 lines (148 loc) · 6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# SPDX-License-Identifier: BSD-3-Clause
#
# fetch-source-pkg.yml
#
# Mirrors the latest Qualcomm-Ubuntu kernel upload from the carmel-team Launchpad
# repository into the resolute-qcom branch (preserving full upstream history),
# then triggers a kernel build.
#
# This repo mirrors exactly ONE source into ONE branch, so the workflow takes no
# inputs -- everything is fixed:
# upstream : git.launchpad.net/~carmel-team/ubuntu/+source/linux/+git/resolute
# branch : resolute-qcom
# tags : Ubuntu-qcom-X.Y.Z-A.B (mirrored verbatim from upstream)
#
# History-preserving "mirror-repoint" model
# * resolute-qcom is a movable "latest Canonical" pointer.
# * The upstream Ubuntu-qcom-X.Y.Z-A.B tag is mirrored verbatim as the immutable
# per-upload record.
# * A sync is pure fetch + repoint (scripts/sync-mirror.sh): it never merges or
# rebases, so it cannot conflict.
#
# Prerequisite: resolute-qcom must first be seeded with full history by the
# "Bootstrap: Seed Canonical Kernel History" workflow. This job is incremental
# and refuses to run against an un-seeded branch.
name: "Sync: Canonical Kernel Sources to Branch"
run-name: "Mirror latest Ubuntu-qcom upload into resolute-qcom"
on:
workflow_dispatch: # manual only; always mirrors the latest carmel-team upload
permissions:
contents: read
# Only one sync at a time -- a second run's lease-pinned push would be rejected.
concurrency:
group: mirror-sync-resolute-qcom
cancel-in-progress: false
env:
BRANCH: resolute-qcom
UPSTREAM_URL: "https://git.launchpad.net/~carmel-team/ubuntu/+source/linux/+git/resolute"
UPSTREAM_PREFIX: Ubuntu-qcom
jobs:
# ==========================================================================
# Job 1 - cheap "is there a new upload?" gate (no clone).
# ==========================================================================
check-version:
name: "Check for new uploads"
runs-on: ubuntu-24.04-arm
timeout-minutes: 10
outputs:
should_sync: ${{ steps.gate.outputs.should_sync }}
steps:
- name: Gate on un-mirrored uploads
id: gate
env:
MIRROR_URL: https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git
run: |
# Compare upstream upload tags against our mirrored tags via two cheap
# ls-remote calls (no clone). should_sync is true iff any upstream
# upload has no matching tag here. Capture ls-remote first so a transport
# failure is not mistaken for "upstream has no tags".
up_raw="$(git ls-remote --tags "${UPSTREAM_URL}" "refs/tags/${UPSTREAM_PREFIX}-*")" \
|| { echo "::error::git ls-remote failed for upstream (network/auth?)"; exit 1; }
mapfile -t UP < <(
printf '%s\n' "${up_raw}" \
| grep -v '\^{}' | sed -E "s#.*refs/tags/${UPSTREAM_PREFIX}-##" | sort -V
)
[ "${#UP[@]}" -gt 0 ] || { echo "No ${UPSTREAM_PREFIX}-* tags upstream"; exit 1; }
LATEST="${UP[-1]}"
OURS="$(
git ls-remote --tags "${MIRROR_URL}" "refs/tags/${UPSTREAM_PREFIX}-*" \
| grep -v '\^{}' | sed -E "s#.*refs/tags/${UPSTREAM_PREFIX}-##" || true
)"
# -F: match the version as a fixed string (dots are not wildcards).
SHOULD_SYNC=false
for ver in "${UP[@]}"; do
if ! grep -qxF "${ver}" <<<"${OURS}"; then SHOULD_SYNC=true; break; fi
done
echo "should_sync=${SHOULD_SYNC}" >> "$GITHUB_OUTPUT"
echo "Latest upstream: ${LATEST}; new uploads to mirror: ${SHOULD_SYNC}"
# ==========================================================================
# Job 2 - mirror every new upload (history-preserving), via sync-mirror.sh.
# ==========================================================================
sync:
name: "Mirror"
runs-on: ubuntu-24.04-arm
timeout-minutes: 60
needs: check-version
if: needs.check-version.outputs.should_sync == 'true'
permissions:
contents: write
outputs:
synced_version: ${{ steps.sync.outputs.synced_version }}
synced_count: ${{ steps.sync.outputs.synced_count }}
steps:
- name: Free up runner disk space
run: |
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/opt/hostedtoolcache/CodeQL /usr/local/share/boost \
"$AGENT_TOOLSDIRECTORY" 2>/dev/null || true
sudo apt-get clean
- name: Checkout CI scripts
uses: actions/checkout@v6
# BRANCH, UPSTREAM_URL and UPSTREAM_PREFIX come from the workflow-level env
# above; sync-mirror.sh reads them directly.
- name: Mirror new uploads
id: sync
env:
MIRROR_URL: https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git
WORKDIR: ${{ runner.temp }}/mirror-sync
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
bash scripts/sync-mirror.sh
- name: Print summary
if: always()
env:
SYNCED_COUNT: ${{ steps.sync.outputs.synced_count || 0 }}
SYNCED_VERSION: ${{ steps.sync.outputs.synced_version }}
run: |
{
echo "## Sync Summary"
echo ""
echo "| Field | Value |"
echo "|-------|-------|"
echo "| Branch | \`${BRANCH}\` |"
echo "| Uploads mirrored | ${SYNCED_COUNT} |"
echo "| Latest version | \`${SYNCED_VERSION}\` |"
} >> "$GITHUB_STEP_SUMMARY"
# ==========================================================================
# Job 3 - trigger a kernel build for the newest mirrored upload.
# ==========================================================================
trigger-build:
name: "Trigger kernel build"
runs-on: ubuntu-24.04-arm
needs: [check-version, sync]
if: needs.sync.result == 'success' && needs.sync.outputs.synced_count != '0'
permissions:
actions: write
steps:
- name: Dispatch build-kernel workflow
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.sync.outputs.synced_version }}
run: |
echo "Building ${BRANCH} ${VERSION} (flavour qcom)"
gh workflow run build-kernel.yml \
--repo "${{ github.repository }}" \
--field suite="${BRANCH}" \
--field kernel_version="${VERSION}"