Skip to content

Commit 2de9028

Browse files
Move the reusable workflow into a directory named reusable-workflows (#15)
Signed-off-by: Simon Beaudoin <[email protected]>
1 parent 718b830 commit 2de9028

File tree

2 files changed

+332
-0
lines changed

2 files changed

+332
-0
lines changed
Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
# This is the reusable workflow that gets invoked in other package repositories
2+
3+
name: Qualcomm Build Debian Package Reusable Workflow
4+
on:
5+
workflow_call:
6+
inputs:
7+
ref:
8+
description: The ref name that was used to invoke this reusable workflow
9+
type: string
10+
required: true
11+
secrets:
12+
ACTIONS_SSH_KEY:
13+
required: true
14+
15+
permissions:
16+
contents: read
17+
security-events: write
18+
19+
env:
20+
PPA_URL: https://qualcomm-linux.github.io/qcom-oss-staging-ppa/
21+
22+
# This variable is set to true below if the ABI check is not able to find an initial
23+
# version of the package in the PPA.
24+
INITIAL_UPLOAD_TO_PPA: 'false'
25+
ABI_CHECK_RETURN_VALUE: 0
26+
27+
PRODUCT_DISTRO: null
28+
PRODUCT_CODENAME: null
29+
PRODUCT_ARCH: null
30+
31+
PPA_PACKAGES_FILE_REPO_PATH: null
32+
33+
jobs:
34+
build-debian-package:
35+
36+
runs-on: [self-hosted, Linux, ARM64]
37+
38+
steps:
39+
40+
- name: Ensure Workspace Is Clean
41+
run: rm -rf *
42+
43+
# This checkout is done so that any change in qcom-build-utils doesnt't need to be propagated up
44+
# Simply relaunching a job that uses this reusable workflow for a given ref will automatically see the changes
45+
- name: Checkout Tip of qcom-build-utils For The Specified Ref
46+
uses: actions/checkout@v4
47+
with:
48+
repository: qualcomm-linux/qcom-build-utils
49+
ref: ${{ inputs.ref }}
50+
ssh-key: ${{ secrets.ACTIONS_SSH_KEY }}
51+
path: ./qcom-build-utils
52+
fetch-depth: 1
53+
54+
- name: Checkout Repository And Submodules Recursively
55+
uses: actions/checkout@v4 # Using public GitHub action to checkout repo, see https://github.com/actions/checkout
56+
with:
57+
path: ./package-repo
58+
ref: ${{ github.head_ref }}
59+
clean: false # A rm -rf * was done first, don't clean otherwise this would delete qcom-build-utils cloned above
60+
submodules: 'recursive' # Make sure all submodules are recursively checked out
61+
ssh-key: ${{ secrets.ACTIONS_SSH_KEY }} # Add SSH key for cloning private repos
62+
fetch-depth: 1 # Speedup things since full history isn't needed
63+
64+
- name: Exctract Product Configuration From qcom-product.conf
65+
run: |
66+
CONFIG_FILE="package-repo/qcom-distro-ubuntu/qcom-product.conf"
67+
68+
DISTRO=$(grep '^Distro:' "$CONFIG_FILE" | cut -d':' -f2 | xargs)
69+
CODENAME=$(grep '^Codename:' "$CONFIG_FILE" | cut -d':' -f2 | xargs)
70+
ARCH=$(grep '^Arch:' "$CONFIG_FILE" | cut -d':' -f2 | xargs)
71+
72+
echo "Distro: $DISTRO"
73+
echo "Codename: $CODENAME"
74+
echo "Arch: $ARCH"
75+
76+
echo "PRODUCT_DISTRO=${DISTRO}" >> $GITHUB_ENV
77+
echo "PRODUCT_CODENAME=${CODENAME}" >> $GITHUB_ENV
78+
echo "PRODUCT_ARCH=${ARCH}" >> $GITHUB_ENV
79+
80+
echo "PPA_PACKAGES_FILE_REPO_PATH=dists/$CODENAME/stable/main/binary-$ARCH" >> $GITHUB_ENV
81+
82+
# Based on the information extracted from qcom-product.conf, verify if the chroot {CODENAME}-{ARCH}-{DISTRO} exists,
83+
# and if not, create it.
84+
# TODO : if it doesnt exist, the script needs to be run as root to create it. Find how to use sudo from here.
85+
- name: Validate Or Create Chroot Environment
86+
run: |
87+
./qcom-build-utils/scripts/prep_chroot_env.py \
88+
--arch ${{ env.PRODUCT_ARCH }} \
89+
--os-codename ${{ env.PRODUCT_CODENAME }} \
90+
--suffix ${{ env.PRODUCT_DISTRO }}
91+
92+
# Prepare the directory structures necessary depending on format is quilt or native
93+
# TODO : This can be beautified a bit
94+
# TODO : remove the hardcoding of fastrpc package names
95+
- name: Prepare Workspace Structure For The Build
96+
run: |
97+
echo "Listing the content of what was checked out, exclusing .md files : "; tree -I '*.md|LICENSE.txt'
98+
99+
mkdir build
100+
101+
if grep -q 'quilt' ./package-repo/debian/source/format; then
102+
echo "Source format is quilt"
103+
104+
mkdir upstream-source
105+
cp -r package-repo/qcom-*-source/* upstream-source/
106+
cd upstream-source
107+
tar -czf ../qcom-fastrpc1_1.0.0.orig.tar.gz .
108+
cd ..
109+
mkdir work
110+
cp -r package-repo/debian work/
111+
tar -xf qcom-fastrpc1_1.0.0.orig.tar.gz -C work
112+
113+
elif grep -q 'native' ./package-repo/debian/source/format; then
114+
echo "Source format is native"
115+
116+
mkdir work
117+
cp -r package-repo/* work/
118+
119+
else
120+
echo "Source format is unknown or unsupported"
121+
122+
exit 1
123+
fi
124+
125+
- name: Build .dsc
126+
run: |
127+
cd work
128+
dpkg-source -b .
129+
cd ..
130+
131+
# Run lintian to see if the package is well formatted
132+
# TODO make it fail if there are errors, and perhaps add a -Werror kind of input
133+
- name: Run lintian
134+
run: |
135+
set +e
136+
lintian ./*.dsc
137+
set -e
138+
139+
- name: Build Debian Packages
140+
run: |
141+
set +e
142+
sbuild \
143+
-A \
144+
--arch=arm64 \
145+
-d noble-arm64-ubuntu \
146+
--no-run-lintian \
147+
--build-dir ./build \
148+
--build-dep-resolver=apt \
149+
--extra-repository="deb [arch=arm64 trusted=yes] http://pkg.qualcomm.com noble/stable main" \
150+
./*.dsc
151+
RET=$?
152+
set -e
153+
154+
if (( RET == 0 )); then
155+
echo "✅ Successfully built package"
156+
else
157+
# Print the real .build log, not the symlink
158+
tail -n 500 $(find ./build -maxdepth 1 -name "*.build" ! -type l)
159+
echo "❌ Build failed, printed the last 500 lines of the build log file"
160+
exit 1
161+
fi
162+
163+
- name : List All The Versions Of The Built Packages Contained In The Staging PPA
164+
run: |
165+
set +e
166+
./qcom-build-utils/scripts/ppa_interface.py \
167+
--operation list-versions \
168+
--apt-config "deb [arch=${{ env.PRODUCT_ARCH }} trusted=yes] ${{ env.PPA_URL }} ${{ env.PRODUCT_CODENAME }}/stable main" \
169+
--package-name libqcom-example1
170+
171+
RET=$?
172+
set -e
173+
174+
# TODO : For now, this step is completely skipped over (if false below).
175+
# Next step is to activate it and download the latest version.
176+
# Then, modify the ABI checker script to remove the logic that downloads the newest version of the package
177+
# in order to simplify the code.
178+
- name : Download Latest Version Of The Built Package From PPA To Compare ABI Against
179+
if: ${{ false }}
180+
run: |
181+
set +e
182+
./qcom-build-utils/scripts/ppa_interface.py \
183+
--operation download \
184+
--apt-config "deb [arch=${{ env.PRODUCT_ARCH }} trusted=yes] ${{ env.PPA_URL }} ${{ env.PRODUCT_CODENAME }}/stable main" \
185+
--package-name libqcom-example1
186+
187+
RET=$?
188+
set -e
189+
190+
if (( RET == 0 )); then
191+
echo "✅ Successfully downloaded latest version"
192+
fi
193+
194+
# TODO deal with other return values
195+
196+
- name: ABI Check
197+
run: |
198+
set +e
199+
200+
./qcom-build-utils/scripts/deb_abi_checker.py \
201+
--new-package-dir ./build \
202+
--apt-server-config "deb [arch=${{ env.PRODUCT_ARCH }} trusted=yes] ${{ env.PPA_URL }} ${{ env.PRODUCT_CODENAME }}/stable main" \
203+
--result-file ./results.txt
204+
205+
RET=$?
206+
set -e
207+
208+
echo "ABI check returned $RET"
209+
210+
# (0): RETURN_ABI_NO_DIFF
211+
# Bit 0 (1): RETURN_ABI_COMPATIBLE_DIFF
212+
# Bit 1 (2): RETURN_ABI_INCOMPATIBLE_DIFF
213+
# Bit 2 (4): RETURN_ABI_STRIPPED_PACKAGE
214+
# Bit 3 (8): RETURN_PPA_PACKAGE_NOT_FOUND
215+
# Bit 4 (16): RETURN_PPA_ERROR
216+
217+
if (( RET == 0 )); then
218+
echo "✅ ABI check returned NO_DIFF"
219+
fi
220+
221+
if (( RET & 1 )); then
222+
echo "⚠️ ABI check returned COMPATIBLE DIFF"
223+
fi
224+
225+
if (( RET & 2 )); then
226+
echo "⚠️ ABI check returned INCOMPATIBLE DIFF"
227+
fi
228+
229+
if (( RET & 4 )); then
230+
echo "❌ ABI check returned STRIPPED PACKAGE"
231+
exit 1
232+
fi
233+
234+
if (( RET & 8 )); then
235+
echo "⚠️ ABI check failed because the PPA did not contained an old version for the package."
236+
echo "Assumption is that this is the first time the package was build."
237+
echo "INITIAL_UPLOAD_TO_PPA=true" >> $GITHUB_ENV
238+
fi
239+
240+
if (( RET & 16 )); then
241+
echo "❌ ABI check failed because there was an error on the PPA"
242+
exit 1
243+
fi
244+
245+
echo "ABI_CHECK_RETURN_VALUE=${RET}" >> $GITHUB_ENV
246+
247+
- name: Package Version Increment Check
248+
if: ${{ env.INITIAL_UPLOAD_TO_PPA == 'false' }}
249+
run: |
250+
echo "Run package version check here with ret value ${{ env.ABI_CHECK_RETURN_VALUE }}"
251+
echo "Content of result file :"
252+
cat ./results.txt
253+
254+
if grep -qE '^\s*-\s*Version:\s*.*FAIL' ./results.txt; then
255+
echo "❌ Test failed: At least one FAIL found in - Version: line"
256+
exit 1
257+
else
258+
echo "✅ Test passed: All versions are PASS"
259+
fi
260+
261+
# TODO Complete this in order to check if the version we just compiled exists in the PPA or not
262+
# in order to know it we need to execute the upload steps below
263+
# Use env.INITIAL_UPLOAD_TO_PPA in the logic also
264+
- name: Check If Need To Upload To PPA
265+
if: ${{ false }}
266+
run: |
267+
set +e
268+
./qcom-build-utils/scripts/ppa_interface.py \
269+
--operation contains-version \
270+
--apt-config "deb [arch=${{ env.PRODUCT_ARCH }} trusted=yes] ${{ env.PPA_URL }} ${{ env.PRODUCT_CODENAME }}/stable main" \
271+
--package-name libqcom-example1
272+
--version 1.1.0
273+
274+
RET=$?
275+
set -e
276+
277+
- name: Checkout PPA staging repo
278+
if: ${{ env.INITIAL_UPLOAD_TO_PPA == 'true' }}
279+
uses: actions/checkout@v4
280+
with:
281+
repository: qualcomm-linux/qcom-oss-staging-ppa
282+
ref: main
283+
ssh-key: ${{ secrets.ACTIONS_SSH_KEY }}
284+
path: ./qcom-oss-staging-ppa
285+
fetch-depth: 1
286+
287+
# TODO Improve the commit messgae to include what are the packages that have been added
288+
- name: Upload Debian Packages To PPA Server If First Build
289+
if: ${{ env.INITIAL_UPLOAD_TO_PPA == 'true' }}
290+
run: |
291+
./qcom-build-utils/scripts/ppa_organizer.py --build-dir ./build --output-dir ./qcom-oss-staging-ppa/pool/${{env.PRODUCT_CODENAME}}/stable/main
292+
293+
cd ./qcom-oss-staging-ppa
294+
295+
dpkg-scanpackages --multiversion pool/${{ env.PRODUCT_CODENAME }} > ${{ env.PPA_PACKAGES_FILE_REPO_PATH }}/Packages
296+
dpkg-scanpackages --type ddeb --multiversion pool/${{ env.PRODUCT_CODENAME }} >> ${{ env.PPA_PACKAGES_FILE_REPO_PATH }}/Packages
297+
298+
gzip -k -f ${{ env.PPA_PACKAGES_FILE_REPO_PATH }}/Packages
299+
300+
cat ${{ env.PPA_PACKAGES_FILE_REPO_PATH }}/Packages
301+
302+
git add .
303+
304+
git commit -s -m "Uploaded Packages"
305+
306+
git push
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This is the TEMPLATE workflow that needs to be copied in the .github/workflows folder
2+
# of any new debian package repo.
3+
4+
# If need be, adjust the branch/tag in the line that invokes the reusable workflow
5+
# Also change the ref: to also match it
6+
7+
name: Build Debian Package
8+
9+
on:
10+
pull_request_target:
11+
branches: [ main ]
12+
push:
13+
branches: [ main ]
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
security-events: write
19+
20+
jobs:
21+
build:
22+
uses: qualcomm-linux/qcom-build-utils/reusable-workflows/build-debian-package-reusable-workflow.yml@main
23+
with:
24+
ref: main
25+
secrets:
26+
ACTIONS_SSH_KEY: ${{ secrets.ACTIONS_SSH_KEY }}

0 commit comments

Comments
 (0)