Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Minor update of build scripts and GitHub Actions workflows and actions #11282

Merged
merged 12 commits into from
Sep 18, 2024
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
5 changes: 5 additions & 0 deletions .github/actions/check-changes/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ runs:
shopt -s extglob
shopt -s dotglob
# 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a "hidden" sha1 hash of
# the "empty tree", retrived via 'git hash-object -t tree /dev/null',
# and used here as a last-resort fallback to always provide a valid
# git ref.
if [[ "${GIT_BASE_REF}" ]]; then
if ! git cat-file -e "${GIT_BASE_REF}" &> /dev/null; then
echo "::warning::Provided base reference ${GIT_BASE_REF} is invalid"
Expand Down
65 changes: 37 additions & 28 deletions .github/actions/flatpak-builder-lint/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,57 @@ runs:
working-directory: ${{ inputs.workingDirectory }}
run: |
: Check artifact input
case "${{ inputs.artifact }}" in
builddir);;
repo);;
manifest);;
appstream);;
*)
echo "::error::Given artifact type is incorrect"
exit 2
;;
esac
if ! [[ "${{ inputs.artifact }}" =~ builddir|repo|manifest|appstream ]]; then
echo "::error::Given artifact type is incorrect"
exit 2
fi

- name: Run flatpak-builder-lint
id: result
shell: bash
working-directory: ${{ inputs.workingDirectory }}
run: |
: Run flatpak-builder-lint
exit_code=0
ret=$(flatpak-builder-lint --exceptions ${{ inputs.artifact }} ${{ inputs.path }}) || exit_code=$?
if [[ $exit_code != 0 && -z "$ret" ]]; then

return=0
result="$(flatpak-builder-lint --exceptions ${{ inputs.artifact }} ${{ inputs.path }})" || return=$?

if [[ ${return} != 0 && -z "${result}" ]]; then
echo "::error::Error while running flatpak-builder-lint"
exit 2
fi

if [[ ${{ inputs.artifact }} == "appstream" ]]; then
echo $ret
if [[ "${{ inputs.artifact }}" == "appstream" ]]; then
echo "${result}"

[[ $exit_code != 0 ]] && echo "::error::Flatpak appstream info is not valid"
if [[ ${return} != 0 ]]; then echo "::error::Flatpak appstream info is not valid"; fi

exit $exit_code
exit ${return}
fi

n_warnings=$(echo $ret | jq '.warnings | length')
for ((i = 0 ; i < n_warnings ; i++)); do
warning=$(echo $ret | jq ".warnings[$i]")
echo "::warning::$warning found in the Flatpak ${{ inputs.artifact }}"
done
# This jq command selects any available array under the 'warnings' key in the JSON document
# or provides an empty array as a fallback if the key is not present. This array is then
# piped to the 'map' function to apply a transformation to every element in the array,
# converting it to a string prefixed with the output level, the actual element value, and
# finally the suffix string defined in 'template'.
#
# The result of this expression is concatenated with a similar expression doing the same
# but for the 'errors' key and its associated array.
#
# The second jq invocation then selects each element of the array and outputs it directly,
# which will be strings of the formats:
#
# * '::warning:: <original warning> <template text>'
# * '::error:: <original error> <template text>'
#
# If no warnings or errors were found, only empty arrays were used for 'map' and thus
# only an empty result array is generated.

n_errors=$(echo $ret | jq '.errors | length')
for ((i = 0 ; i < n_errors ; i++)); do
error=$(echo $ret | jq ".errors[$i]")
echo "::error::$error found in the Flatpak ${{ inputs.artifact }}"
done
template=" found in the Flatpak ${{ inputs.artifact }}"
while read -r log_line; do
if [[ "${log_line}" ]]; then echo "${log_line}"; fi
done <<< "$(echo "${result}" \
| jq -r '(.warnings // [] | try map("::warning:: " + . + "${template}")) + (.errors // [] | try map("::error:: " + . + "${template}"))' \
| jq -r '.[]')"

[[ -z $n_errors || $n_errors == 0 ]] || exit 2
exit ${return}
15 changes: 14 additions & 1 deletion .github/actions/generate-docs/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,25 @@ runs:
: "${minor:=}"
: "${patch:=}"

# This expression will first try to match all the LIBOBS_API_[...]_VER
# lines in 'obs-config.h', before removing the '#define ' prefix and
# trimming away whitespace characters and linebreaks.
# This will yield a single line with the each major, minor, and patch
# version variable name followed by its value, so every even item
# in this string will contain a version part.

read -r _ major _ minor _ patch _ <<< \
"$(grep -E -e "#define LIBOBS_API_(MAJOR|MINOR|PATCH)_VER *" libobs/obs-config.h \
| sed 's/#define //g' \
| tr -s ' ' \
| tr '\n' ' ')"

# This expression simply replaces the definition of the 'version' and
# 'release' variables in the Python script with updated variants using
# the version tokens set by the previous expression.
# The copyright variable assignment is updated to use the current
# local year as the second year value.

sed -i -E \
-e "s/version = '([0-9]+\.[0-9]+\.[0-9]+)'/version = '${major}.${minor}.${patch}'/g" \
-e "s/release = '([0-9]+\.[0-9]+\.[0-9]+)'/release = '${major}.${minor}.${patch}'/g" \
Expand All @@ -46,7 +59,7 @@ runs:
echo "commitHash=${GITHUB_SHA:0:9}" >> $GITHUB_OUTPUT

- name: Install Sphinx 📜
uses: totaldebug/sphinx-publish-action@1.2.0
uses: totaldebug/sphinx-publish-action@cdbb304b4b8aa1fd36015e3c459c1f122804bd6b
with:
sphinx_src: ${{ inputs.sourceDirectory }}/docs/sphinx
build_only: true
Expand Down
32 changes: 12 additions & 20 deletions .github/actions/qt-xml-validator/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,27 @@ runs:
- name: Register Annotations 📝
uses: korelstar/xmllint-problem-matcher@1bd292d642ddf3d369d02aaa8b262834d61198c0

- name: Check for Changed Files ✅
uses: ./.github/actions/check-changes
id: checks
with:
checkGlob: 'UI/forms/**/*.ui'

- name: Validate XML 💯
if: fromJSON(steps.checks.outputs.hasChangedFiles)
id: result
shell: bash
env:
GITHUB_EVENT_FORCED: ${{ github.event.forced }}
GITHUB_REF_BEFORE: ${{ github.event.before }}
CHANGED_FILES: ${{ steps.checks.outputs.changedFiles }}
run: |
: Validate XML 💯
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
shopt -s globstar

if ! git cat-file -e "${GITHUB_REF_BEFORE}" &> /dev/null; then
GITHUB_REF_BEFORE='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
fi

changes=($(git diff --name-only HEAD~1 HEAD -- UI/forms/**/*.ui))
case "${GITHUB_EVENT_NAME}" in
pull_request) changes=($(git diff --name-only origin/"${GITHUB_BASE_REF}" HEAD -- UI/forms/**/*.ui)) ;;
push)
if [[ "${GITHUB_EVENT_FORCED}" == false ]]; then
changes=($(git diff --name-only ${GITHUB_REF_BEFORE} HEAD -- UI/forms/**/*.ui))
fi
;;
*) ;;
esac
CHANGED_FILES=($(echo "${CHANGED_FILES//[\[\]\'\"]/}" | tr "," "\n"))

if (( ${#changes[@]} )); then
if (( ${#CHANGED_FILES[@]} )); then
if [[ '${{ inputs.failCondition }}' == never ]]; then set +e; fi
xmllint \
--schema ${{ github.workspace }}/UI/forms/XML-Schema-Qt5.15.xsd \
--noout "${changes[@]}"
--noout "${CHANGED_FILES[@]}"
fi
17 changes: 17 additions & 0 deletions .github/actions/sparkle-appcast/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,23 @@ runs:
hdiutil detach ${mount_point}
curl -s -L -O ${feed_url}
# The Xpath Xplained:
#
# //rss/channel/item - Select every <item> node, under a
# <channel> node, under a <rss> node,
# which:
# [*...] - Has a child node, which
# [local-name()='channel'] - Has the local name "channel"
# (required to match the
# namespaced sparkle:channel node),
# which in turn has
# [text()='${{ inputs.channel}'] - A text node that contains the
# content of inputs.channel
# /enclosure/@url - Then select the "url" attribute of
# every <enclosure> node under
# these matching <item> nodes
local -a artifacts=($(\
xmllint \
-xpath "//rss/channel/item[*[local-name()='channel'][text()='${{ inputs.channel }}']]/enclosure/@url" \
Expand Down
38 changes: 38 additions & 0 deletions .github/actions/sparkle-appcast/appcast_adjust.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,58 @@ xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no"/>
<xsl:strip-space elements="*"/>

<!-- Select /rss/channel/title and store it as default value for 'pCustomTitle' -->
<xsl:param name="pCustomTitle" select="/rss/channel/title" />
<!-- Select /rss/channel/link and store it as default value for 'pCustomLink' -->
<xsl:param name="pCustomLink" select="/rss/channel/link" />
<!-- Set empty strings as default values for pSparkleUrl and pDeltaUrl -->
<xsl:param name="pSparkleUrl" select="''" />
<xsl:param name="pDeltaUrl" select="''" />

<!-- XSLT identity rule - copy all nodes and their child nodes as well as attributes
(attributes are _not_ descendants of the nodes they belong to).
This copy rule is applied as the "default" transformation for all nodes.
-->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<!-- Match the <title> under <channel> and <rss> and do not translate it
(effectively removes it).
-->
<xsl:template match="/rss/channel/title" />
<!-- Match the <link> under <channel> and <rss> and do not translate it
(effectively removes it).
-->
<xsl:template match="/rss/channel/link" />
<!-- Match the <channel> under <rss> and apply a copy translation, which
* Creates a new <title> element with a text child node and the text content
of the pCustomTitle variable
* Creates a new <link> element with a text child node and the text content
of the pCustomLink variable
* Copies all child nodes and attributes of the original <channel> node
(this is why <title> and <link> were explicitly not translated before)
-->
<xsl:template match="/rss/channel">
<xsl:copy>
<xsl:element name="title"><xsl:value-of select="$pCustomTitle" /></xsl:element>
<xsl:element name="link"><xsl:value-of select="$pCustomLink" /></xsl:element>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<!-- Match every url attribute of <enclosure> nodes in <sparkle:deltas> nodes
(which themselves are under <item>, <channel>, and <rss> nodes respectively).

Create a new attribute with the name "url" and then set its content to either
* The original value of the attribute if it starts with the value of the
pDeltaUrl variable, OR
* The actual value of the pDeltaUrl variable, with the value of the
pSparkleUrl variable removed in front of the current url value added after

This effectively updates every url attribute on a delta <enclosure> node
that does not start with the current delta url path.
-->
<xsl:template match="/rss/channel/item/sparkle:deltas/enclosure/@url">
<xsl:attribute name="url">
<xsl:choose>
Expand All @@ -37,6 +70,11 @@ xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
</xsl:choose>
</xsl:attribute>
</xsl:template>
<!-- Match any <sparkle:fullReleaseNotesLink> node under <item>, <channel>,
and <rss> respectively, and replace it with a new node named
<sparkle:releaseNotesLink> and populate it with all child nodes and
attributes of the original node.
-->
<xsl:template match="/rss/channel/item/sparkle:fullReleaseNotesLink">
<xsl:element name="sparkle:releaseNotesLink"><xsl:apply-templates select="@* | node()" /></xsl:element>
</xsl:template>
Expand Down
17 changes: 17 additions & 0 deletions .github/actions/sparkle-appcast/appcast_legacy.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,29 @@ xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no"/>
<xsl:strip-space elements="*"/>

<!-- XSLT identity rule - copy all nodes and their child nodes as well as attributes
(attributes are _not_ descendants of the nodes they belong to).
This copy rule is applied as the "default" transformation for all nodes.
-->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<!-- Select every <item> node under a <channel> and <rss> node respectively,
which has a <sparkle:channel> child node whose text child node's value
is not equal to 'stable', then apply to translation, effectively removing
it.
-->
<xsl:template match="/rss/channel/item[sparkle:channel[text()!='stable']]" />
<!-- Select every <sparkle:channel> node under a <item> node which sits under a
<channel> and <rss> node respectively, then apply no translation, effectively
removing it.
-->
<xsl:template match="/rss/channel/item/sparkle:channel" />
<!-- Select every <sparkle:deltas> node under a <item> node which sits under a
<channel> and <rss> node respectively, then apply no translation, effectively
removing it.
-->
<xsl:template match="/rss/channel/item/sparkle:deltas" />
</xsl:stylesheet>
8 changes: 2 additions & 6 deletions .github/scripts/.build.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ if (( ! ${+CI} )) {
exit 1
}

autoload -Uz is-at-least && if ! is-at-least 5.2; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue."
autoload -Uz is-at-least && if ! is-at-least 5.9; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.9%b is the minimum supported version. Upgrade Zsh to fix this issue."
exit 1
fi

Expand Down Expand Up @@ -57,7 +57,6 @@ build() {
macos-x86_64
macos-arm64
ubuntu-x86_64
ubuntu-aarch64
)

local config='RelWithDebInfo'
Expand Down Expand Up @@ -211,13 +210,10 @@ build() {
local cmake_bin='/usr/bin/cmake'
cmake_args+=(
--preset ubuntu-ci
--toolchain ${project_root}/cmake/linux/toolchain-${target##*-}-gcc.cmake
-DENABLE_BROWSER:BOOL=ON
-DCEF_ROOT_DIR:PATH="${project_root}/.deps/cef_binary_${CEF_VERSION}_${target//ubuntu-/linux_}"
)

if [[ ${target##*-} == aarch64 ]] cmake-args+=(-DENABLE_QSV11:BOOL=OFF)

cmake_build_args+=(build_${target%%-*} --config ${config} --parallel)
cmake_install_args+=(build_${target%%-*} --prefix ${project_root}/build_${target%%-*}/install/${config})

Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/.package.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ if (( ! ${+CI} )) {
exit 1
}

autoload -Uz is-at-least && if ! is-at-least 5.2; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue."
autoload -Uz is-at-least && if ! is-at-least 5.9; then
print -u2 -PR "%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.9%b is the minimum supported version. Upgrade Zsh to fix this issue."
exit 1
fi

Expand Down
6 changes: 6 additions & 0 deletions .github/scripts/utils.zsh/check_ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ if [[ -f /etc/os-release ]] {
log_group
return 2
}

autoload -Uz is-at-least && if ! is-at-least 24.04 ${dist_version}; then
log_error "Not running on a recent-enough Ubuntu distribution. Aborting"
log_group
return 2
fi
} else {
log_error "Unable to determine local Linux distribution, but Ubuntu is required. Aborting"
log_group
Expand Down
Loading
Loading