spiegel-keyman/.github/workflows/linux-source-verification.yml
Eberhard Beilharz 2c8f878f1d
chore(linux): add verification for source tarball and source package
This change adds a new GitHub action that verifies that Keyman can build
from the source package. Also check that source package used for Launchpad
and Debian/Ubuntu packaging doesn't produce lintian errors. Previously
lintian errors did go unnoticed because they didn't stop the build.

Also refactor `launchpad.sh` script to be a proper builder script, and add
some new parameters to allow skipping some steps in the script.

Build-bot: skip
Test-bot: skip
2026-05-06 19:03:12 +02:00

128 lines
4.9 KiB
YAML

# Keyman is copyright (C) SIL Global. MIT License.
#
# This workflow verifies two things:
# - the source tarball that gets uploaded to downloads.keyman.com. It
# verifies that it contains all files needed to run `build.sh`
# - the source package that gets uploaded to launchpad. It verifies that
# running lintian doesn't output any errors.
name: "Linux source verification"
run-name: "Linux source verification - ${{ github.event.client_payload.branch }} (branch ${{ github.event.client_payload.baseBranch }}), by @${{ github.event.client_payload.user }}, testbuild: ${{ github.event.client_payload.isTestBuild }}"
on:
repository_dispatch:
types: ['linux-source-verification:*']
# Input:
# buildSha: The SHA of the commit to build, e.g. of the branch or
# refs/pull/1234/head for PR
# branch: The branch to build, for a PR in the form `PR-1234`
# baseBranch: For a PR the base branch, otherwise the same as `branch`
# baseRef: The ref of the previous commit. For a PR the same as `baseBranch`.
# user: The user that triggered the build or created the PR
# isTestBuild: false for Releases, otherwise true
env:
STATUS_CONTEXT: 'Linux source verification'
GH_TOKEN: ${{ github.token }}
jobs:
source_verification:
name: Verify source tarball and Linux source package
runs-on: ubuntu-latest
outputs:
KEYMAN_VERSION: ${{ steps.version_step.outputs.KEYMAN_VERSION }}
steps:
- name: Set pending status on PR builds
id: set_status
if: github.event.client_payload.isTestBuild == 'true'
shell: bash
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/$GITHUB_REPOSITORY/statuses/${{ github.event.client_payload.buildSha }} \
-f state='pending' \
-f target_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
-f description='Linux source verification started' \
-f context="$STATUS_CONTEXT"
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: '${{ github.event.client_payload.buildSha }}'
fetch-depth: 0
clean: false
path: ${{ github.workspace }}/keyman/
- name: Install devscripts
uses: ./keyman/.github/actions/apt-install
with:
packages: devscripts equivs
- name: Install dependencies
run: |
cd ${{ github.workspace }}/keyman/linux
./scripts/deb-packaging.sh --gha dependencies
- name: Set version as output parameter
id: version_step
shell: bash
run: |
THIS_SCRIPT="${{ github.workspace }}/keyman/.github/workflows/linux-source-verification.yml"
if [[ -f "${THIS_SCRIPT%/*}/../../resources/build/builder-basic.inc.sh" ]]; then
. "${THIS_SCRIPT%/*}/../../resources/build/builder-basic.inc.sh"
else
# TODO: remove following block post v19 release (file was renamed in v19 alpha)
if [[ -f "${THIS_SCRIPT%/*}/../../resources/build/build-utils.sh" ]]; then
. "${THIS_SCRIPT%/*}/../../resources/build/build-utils.sh"
fi
fi
echo "KEYMAN_VERSION=${KEYMAN_VERSION:-${VERSION}}" >> $GITHUB_OUTPUT
- name: Verify source tarball
shell: bash
run: |
cd ${{ github.workspace }}/keyman/linux
./scripts/verify_source.sh --source-only "${{ github.workspace }}/keyman-${{ steps.version_step.outputs.KEYMAN_VERSION }}"
- name: Verify Ubuntu source package
shell: bash
run: |
cd ${{ github.workspace }}/keyman/linux
./scripts/verify_source.sh --no-create-tarball --launchpad-only "${{ github.workspace }}/keyman-${{ steps.version_step.outputs.KEYMAN_VERSION }}"
set_status:
name: Set result status on PR builds
needs: [source_verification]
runs-on: ubuntu-latest
if: ${{ always() && github.event.client_payload.isTestBuild == 'true' }}
steps:
- name: Set success
if: needs.source_verification.result == 'success'
run: |
echo "RESULT=success" >> $GITHUB_ENV
echo "MSG=Linux source verification succeeded" >> $GITHUB_ENV
- name: Set cancelled
if: needs.source_verification.result == 'cancelled'
run: |
echo "RESULT=error" >> $GITHUB_ENV
echo "MSG=Linux source verification cancelled" >> $GITHUB_ENV
- name: Set failure
if: needs.source_verification.result == 'failure'
run: |
echo "RESULT=failure" >> $GITHUB_ENV
echo "MSG=Linux source verification failed" >> $GITHUB_ENV
- name: Set final status
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/$GITHUB_REPOSITORY/statuses/${{ github.event.client_payload.buildSha }} \
-f state="$RESULT" \
-f target_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
-f description="$MSG" \
-f context="$STATUS_CONTEXT"