Skip to content
Merged
Show file tree
Hide file tree
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
109 changes: 109 additions & 0 deletions .github/actions/abi_checker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Check ABI Against Previous Package Version
description: |
This Github Actions checks the ABI of a newly built package against the latest
[or possibly a fixed] version of that same package stored a repository.

inputs:
version:
description: The specific version to run the ABI checker against. If not defined, defaults to latest
requred: false

runs:
using: "composite"

steps:
- name : List All The Versions Of The Built Packages Contained In The Staging PPA
shell: bash
run: |
set +e
./qcom-build-utils/scripts/ppa_interface.py \
--operation list-versions \
--apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
--package-name ${{env.BUILT_PACKAGE_NAME}}

RET=$?
set -e

# TODO modify the ABI checker script to remove the logic that downloads the newest version of the package
# in order to simplify the code.
- name : Download Latest Version Of The Built Package From PPA To Compare ABI Against
shell: bash
run: |
set +e
./qcom-build-utils/scripts/ppa_interface.py \
--operation download \
--apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
--package-name ${{env.BUILT_PACKAGE_NAME}}

RET=$?
set -e

if (( RET == 0 )); then
echo "✅ Successfully downloaded latest version"
fi

# TODO deal with other return values

- name: ABI Check
shell: bash
run: |
set +e

./qcom-build-utils/scripts/deb_abi_checker.py \
--new-package-dir ./build-area \
--apt-server-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
--result-file ./results.txt

RET=$?
set -e

echo "ABI check returned $RET"

# (0): RETURN_ABI_NO_DIFF
# Bit 0 (1): RETURN_ABI_COMPATIBLE_DIFF
# Bit 1 (2): RETURN_ABI_INCOMPATIBLE_DIFF
# Bit 2 (4): RETURN_ABI_STRIPPED_PACKAGE
# Bit 3 (8): RETURN_PPA_PACKAGE_NOT_FOUND
# Bit 4 (16): RETURN_PPA_ERROR

if (( RET == 0 )); then
echo "✅ ABI check returned NO_DIFF"
fi

if (( RET & 1 )); then
echo "⚠️ ABI check returned COMPATIBLE DIFF"
fi

if (( RET & 2 )); then
echo "⚠️ ABI check returned INCOMPATIBLE DIFF"
fi

if (( RET & 4 )); then
echo "❌ ABI check returned STRIPPED PACKAGE"
exit 1
fi

if (( RET & 8 )); then
echo "⚠️ ABI check failed because the PPA did not contained an old version for the package."
echo "Assumption is that this is the first time the package was build."
echo "INITIAL_UPLOAD_TO_PPA=true" >> $GITHUB_ENV
fi

if (( RET & 16 )); then
echo "❌ ABI check failed because there was an error on the PPA"
exit 1
fi

- name: Package Version Increment Check
shell: bash
run: |
echo "Run package version check here with ret value"
echo "Content of result file :"
cat ./results.txt

if grep -qE '^\s*-\s*Version:\s*.*FAIL' ./results.txt; then
echo "❌ Test failed: At least one FAIL found in - Version: line"
exit 1
else
echo "✅ Test passed: All versions are PASS"
fi
114 changes: 114 additions & 0 deletions .github/actions/push_to_repo/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Push Built Package To Repo If Need Be
description: |
This Github Actions pushes the newly built package to a repository

inputs:
token:
description: PAT token
required: true

force-override:
description: If the version of the package already exists, override it.
default: false

env:
BUILT_PACKAGE_NAME: null
BUILT_PACKAGE_VERSION: null

runs:
using: "composite"

steps:


- name: Extract built package name
shell: bash
run: |
changes_file=$(find ./build-area -maxdepth 1 -name '*.changes' | head -n 1)

main_binary=$(grep '^Binary:' "$changes_file" | sed 's/^Binary: //' | tr ' ' '\n' | grep -v -- '-dev' | head -n 1)
version=$(grep '^Version:' "$changes_file" | sed 's/^Version: //')

echo "BUILT_PACKAGE_NAME=$main_binary" >> $GITHUB_ENV
echo "BUILT_PACKAGE_VERSION=$version" >> $GITHUB_ENV

echo "Built package name : $main_binary"
echo "Built package version : $version"

- name : List All The Versions Of The Built Packages Contained In The Staging PPA
shell: bash
run: |
set +e
./qcom-build-utils/scripts/ppa_interface.py \
--operation list-versions \
--apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
--package-name ${{env.BUILT_PACKAGE_NAME}}

RET=$?
set -e

- name: Check If Need To Upload To Repo
id: check-version
shell: bash
run: |
echo "Checking if the repo already contains the built version"

set +e
./qcom-build-utils/scripts/ppa_interface.py \
--operation contains-version \
--apt-config "deb [arch=${{env.ARCH}} trusted=yes] ${{env.REPO_URL}} ${{env.UBUNTU_CODENAME}}/stable main" \
--package-name ${{env.BUILT_PACKAGE_NAME}} \
--version ${{env.BUILT_PACKAGE_VERSION}}

RET=$?
set -e

echo "do_upload=true" >> $GITHUB_OUTPUT

if [[ "$RET" == "0" && "${{inputs.force-override}}" == "false" ]]; then
echo "Package version already exists in the repo and force-override is set to false. We are therefore done here."
echo "do_upload=false" >> $GITHUB_OUTPUT
elif [[ "$RET" == "0" && "${{inputs.force-override}}" == "true" ]]; then
echo "Package version already exists in the repo, but force-override is set to true. Proceeding to override the package"
else
echo "The package version does not exist in the repo. Proceeding to uploat it."
fi

- name: Checkout Staging Repo
if: steps.check-version.outputs.do_upload == 'true'
uses: actions/checkout@v4
with:
repository: ${{env.REPO_NAME}}
ref: main
token: ${{inputs.token}}
path: ./pkg-oss-staging-repo
fetch-depth: 1

# TODO Improve the commit messgae to include what are the packages that have been added
- name: Upload Debian Packages To Staging Repo
if: steps.check-version.outputs.do_upload == 'true'
shell: bash
run: |
./qcom-build-utils/scripts/ppa_organizer.py --build-dir ./build-area --output-dir ./pkg-oss-staging-repo/pool/${{env.UBUNTU_CODENAME}}/stable/main

cd ./pkg-oss-staging-repo

PPA_PACKAGES_FILE_REPO_PATH=dists/${{env.UBUNTU_CODENAME}}/stable/main/binary-${{env.ARCH}}

dpkg-scanpackages --multiversion pool/${{env.UBUNTU_CODENAME}} > $PPA_PACKAGES_FILE_REPO_PATH/Packages
dpkg-scanpackages --type ddeb --multiversion pool/${{env.UBUNTU_CODENAME}} >> $PPA_PACKAGES_FILE_REPO_PATH/Packages

gzip -k -f $PPA_PACKAGES_FILE_REPO_PATH/Packages

cat $PPA_PACKAGES_FILE_REPO_PATH/Packages

git add .

git config user.name "Github Service Bot"
git config user.email "[email protected]"

git commit -s -m "Uploaded Package ${{env.BUILT_PACKAGE_NAME}} at version ${{env.BUILT_PACKAGE_VERSION}} for distro ${{env.UBUNTU_CODENAME}}"

git remote set-url origin https://x-access-token:${{inputs.token}}@github.com/${{env.REPO_NAME}}.git

git push origin
Loading
Loading