Skip to content

Commit

Permalink
Run actions outside container to fix Linux build failure (#1902)
Browse files Browse the repository at this point in the history
  • Loading branch information
J5lx authored Feb 5, 2025
1 parent 5f11eac commit 5682937
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 57 deletions.
22 changes: 11 additions & 11 deletions .github/actions/create-package/create-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@ harvest_files() {

create_package_linux() {
echo "::group::Set up AppImage contents"
make install INSTALL_ROOT="${PWD}/Pencil2D"
${BUILD_CMD} make -C build install INSTALL_ROOT="/workspace/Pencil2D"
echo "::endgroup::"

echo "::group::Create AppImage"
# "Downgrade" the desktop entry to version 1.0
sed -i "/^Keywords\(\[[a-zA-Z_.@]\+\]\)\?=/d;/^Version=/cVersion=1.0" \
${BUILD_CMD} sed -i "/^Keywords\(\[[a-zA-Z_.@]\+\]\)\?=/d;/^Version=/cVersion=1.0" \
Pencil2D/usr/share/applications/org.pencil2d.Pencil2D.desktop
install -Dm755 /usr/bin/ffmpeg Pencil2D/usr/plugins/ffmpeg
install -Dm755 "/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner" \
${BUILD_CMD} install -Dm755 /usr/bin/ffmpeg Pencil2D/usr/plugins/ffmpeg
${BUILD_CMD} install -Dm755 "/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner" \
"Pencil2D/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
local gst_executables="-executable=Pencil2D/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
for plugin in adpcmdec alsa app audioconvert audioparsers audioresample \
autodetect coreelements gsm id3demux jack mpg123 mulaw playback \
pulse typefindfunctions wavparse apetag; do
install -Dm755 "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgst${plugin}.so" \
${BUILD_CMD} install -Dm755 "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgst${plugin}.so" \
"Pencil2D/usr/lib/gstreamer-1.0/libgst${plugin}.so"
gst_executables="${gst_executables} -executable=Pencil2D/usr/lib/gstreamer-1.0/libgst${plugin}.so"
done
curl -fsSLO https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
chmod 755 linuxdeployqt-continuous-x86_64.AppImage
${BUILD_CMD} curl -fsSLO https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
${BUILD_CMD} chmod 755 linuxdeployqt-continuous-x86_64.AppImage
local update_info="" # Currently no appimageupdate support for nightly builds
if [ $IS_RELEASE = "true" ]; then
update_info="-updateinformation=gh-releases-zsync|${GITHUB_REPOSITORY/\//|}|latest|pencil2d-linux-amd64-*.AppImage.zsync"
fi
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib/x86_64-linux-gnu/pulseaudio" \
${BUILD_CMD} bash -c "LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:/usr/lib/x86_64-linux-gnu/pulseaudio\" \
./linuxdeployqt-continuous-x86_64.AppImage \
Pencil2D/usr/share/applications/org.pencil2d.Pencil2D.desktop \
-executable=Pencil2D/usr/plugins/ffmpeg \
Expand All @@ -60,11 +60,11 @@ create_package_linux() {
platforms/libqwayland-xcomposite-egl.so,platforms/libqwayland-xcomposite-glx.so,\
wayland-decoration-client,wayland-graphics-integration-client,wayland-shell-integration \
${update_info} \
-appimage
-appimage"
local qtsuffix="-qt${INPUT_QT}"
local output_name="pencil2d${qtsuffix/-qt5/}-linux-$3"
mv Pencil2D*.AppImage "$output_name.AppImage"
mv Pencil2D*.AppImage.zsync "$output_name.AppImage.zsync" \
mv "${GITHUB_WORKSPACE}"/Pencil2D*.AppImage "$output_name.AppImage"
mv "${GITHUB_WORKSPACE}"/Pencil2D*.AppImage.zsync "$output_name.AppImage.zsync" \
&& sed -i '1,/^$/s/^\(Filename\|URL\): .*$/\1: '"$output_name.AppImage/" "$output_name.AppImage.zsync" \
|| true
echo "output-basename=$output_name" >> "${GITHUB_OUTPUT}"
Expand Down
13 changes: 7 additions & 6 deletions .github/actions/install-dependencies/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@
setup_linux() {
# Because of how bare-bones our docker image is
echo "::group::Install prerequisites"
apt-get -yq install software-properties-common
${BUILD_CMD} apt-get -yq update
${BUILD_CMD} apt-get -yq install software-properties-common
echo "::endgroup::"

echo "::group::Add APT sources"
for ppa in ppa:ubuntu-toolchain-r/test ppa:ubuntu-sdk-team/ppa \
ppa:git-core/ppa; do
apt-add-repository -y "${ppa}"
${BUILD_CMD} apt-add-repository -y "${ppa}"
done
if [ "${INPUT_QT}" -eq 5 ]; then
apt-add-repository -y ppa:beineri/opt-qt-5.15.2-xenial
${BUILD_CMD} apt-add-repository -y ppa:beineri/opt-qt-5.15.2-xenial
fi
echo "::endgroup::"

echo "::group::Fetch APT updates"
apt-get update -yq
${BUILD_CMD} apt-get update -yq
echo "::endgroup::"

echo "::group::Install APT packages"
if [ "${INPUT_QT}" -eq 5 ]; then
apt-get install -yq --no-install-suggests --no-install-recommends \
${BUILD_CMD} apt-get install -yq --no-install-suggests --no-install-recommends \
build-essential qt515tools qt515base qt515multimedia qt515svg \
qt515wayland libgl1-mesa-dev bsdtar ffmpeg gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-alsa gstreamer1.0-pulseaudio git \
curl libfuse2
else
apt-get install -yq --no-install-suggests --no-install-recommends \
${BUILD_CMD} apt-get install -yq --no-install-suggests --no-install-recommends \
build-essential qt6-l10n-tools qt6-base-dev qt6-multimedia-dev \
libqt6svg6-dev qt6-wayland-dev libgl1-mesa-dev libarchive-tools ffmpeg \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
Expand Down
8 changes: 3 additions & 5 deletions .github/actions/setup-environment/setup-environment.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env bash

setup_linux() {
echo "MAKEFLAGS=-j2" >> "${GITHUB_ENV}"
echo "MAKEFLAGS=-j2" >> "${GITHUB_WORKSPACE}/env"
# Our container image uses the non-Unicode C locale by default
echo "LANG=C.UTF-8" >> "${GITHUB_ENV}"
echo "LANG=C.UTF-8" >> "${GITHUB_WORKSPACE}/env"
# Set up Qt environment variables and export them to the GitHub Actions workflow
if [ -f /opt/qt515/bin/qt515-env.sh ]; then
(printenv; (. /opt/qt515/bin/qt515-env.sh; printenv)) | sort -st= -k1,1 | uniq -u >> "${GITHUB_ENV}"
fi
${BUILD_CMD} bash -c 'if [ -f /opt/qt515/bin/qt515-env.sh ]; then (printenv; (. /opt/qt515/bin/qt515-env.sh; printenv)); fi' | sort -st= -k1,1 | uniq -u >> "${GITHUB_WORKSPACE}/env"
}

setup_macos() {
Expand Down
73 changes: 38 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,96 +24,95 @@ jobs:
include:
- name: Qt 5 / Linux x86_64
os: ubuntu-latest
# XXX: --privileged is sort of a brute-force solution to get FUSE
# working inside Docker, however so far I haven’t been able to
# figure out precisely *which* privileges are needed.
container: { image: "ubuntu:16.04", options: --privileged }
container: "ubuntu:16.04"
qt: 5
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
- name: Qt 5 / macOS x86_64
os: macos-13
container: null
container:
qt: 5
#- name: Qt 5 / macOS arm64
# os: macos-latest
# container: null
# container:
# qt: 5
- name: Qt 5 / Windows x86
os: windows-2019
arch: win32_msvc2019
container: null
container:
qt: 5
- name: Qt 5 / Windows x86_64
os: windows-2019
arch: win64_msvc2019_64
container: null
container:
qt: 5
- name: Qt 6 / Linux x86_64
os: ubuntu-latest
# XXX: --privileged is sort of a brute-force solution to get FUSE
# working inside Docker, however so far I haven’t been able to
# figure out precisely *which* privileges are needed.
container: { image: "ubuntu:22.04", options: --privileged }
container: "ubuntu:22.04"
qt: 6
- name: Qt 6 / macOS x86_64
os: macos-13
container: null
container:
qt: 6
#- name: Qt 6 / macOS arm64
# os: macos-latest
# container: null
# container:
# qt: 6
- name: Qt 6 / Windows x86_64
os: windows-2019
arch: win64_msvc2019_64
container: null
container:
qt: 6

name: ${{matrix.name}}
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
env: {ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true}
env: { CONTAINER: "${{matrix.container}}", BUILD_CMD: "" }
steps:
- name: Install git (Linux)
# GitHub runners come with git pre-installed, but our "custom" Linux
# container image does not
if: runner.os == 'Linux'
run: |
apt-get update -yq
apt-get -yq install software-properties-common
apt-add-repository -y ppa:git-core/ppa
apt-get update -yq
apt-get install -yq --no-install-suggests --no-install-recommends git
- name: Check out repository
uses: actions/checkout@v3
- name: Set up container (Linux)
if: runner.os == 'Linux'
# XXX: --privileged is sort of a brute-force solution to get FUSE
# working inside Docker, however so far I haven’t been able to
# figure out precisely *which* privileges are needed.
run: |
touch "${{github.workspace}}/env"
docker run --detach --privileged --workdir /workspace --volume "${{github.workspace}}:/workspace" --name "ci_${{github.sha}}" --entrypoint "tail" "${{matrix.container}}" -f /dev/null
echo '#!/usr/bin/env bash' > "${{github.workspace}}/build-cmd"
echo 'exec docker exec --env-file <(cat "${{github.workspace}}/env") "ci_${{github.sha}}" "$@"' >> "${{github.workspace}}/build-cmd"
chmod +x "${{github.workspace}}/build-cmd"
echo 'BUILD_CMD=${{github.workspace}}/build-cmd' >> "${GITHUB_ENV}"
- name: Install dependencies
uses: ./.github/actions/install-dependencies
with:
arch: ${{matrix.arch}}
qt: ${{matrix.qt}}

- name: Set up environment
uses: ./.github/actions/setup-environment
with:
arch: ${{matrix.arch}}

- name: Configure build
run: >
mkdir build; ${{runner.os == 'Linux' && matrix.qt == 6 && 'qmake6' || 'qmake'}}
mkdir build; ${{runner.os == 'Linux' && '${BUILD_CMD}' || ''}}
${{runner.os == 'Linux' && matrix.qt == 6 && 'qmake6' || 'qmake'}}
-o build PREFIX=/usr CONFIG-=debug_and_release CONFIG+=release CONFIG+=GIT
CONFIG+=PENCIL2D_${{startsWith(github.ref, 'refs/heads/release/') && 'RELEASE' || 'NIGHTLY' }}
CONFIG+=PENCIL2D_${{ startsWith(github.ref, 'refs/heads/release/') && 'RELEASE' || 'NIGHTLY' }}
VERSION=${{ env.VERSION_NUMBER }}
- name: Build Pencil2D
working-directory: build
run: ${{runner.os != 'Windows' && 'make' || 'nmake'}}
run: ${{runner.os != 'Windows' && '${BUILD_CMD} make -C build' || 'cd build; nmake'}}

- name: Run tests
env: { QT_QPA_PLATFORM: minimal }
run: build/tests/tests
run: ${{runner.os == 'Linux' && '${BUILD_CMD}' || ''}} env QT_QPA_PLATFORM=minimal build/tests/tests

- name: Create package
id: package
if: runner.os != 'Linux' || matrix.qt == 5
uses: ./.github/actions/create-package
with:
arch: ${{matrix.arch}}
qt: ${{matrix.qt}}

- name: Upload package
if: runner.os != 'Linux' || matrix.qt == 5
uses: actions/upload-artifact@v4
Expand All @@ -126,3 +125,7 @@ jobs:
echo "Build will be available for download
[here](https://get.pencil2d.org/@${{github.repository_owner}}/${{github.run_id}}/${{steps.package.outputs.output-basename}})
once the run is finished." > "${GITHUB_STEP_SUMMARY}"
- name: Stop container (Linux)
if: runner.os == 'Linux'
run: docker stop "ci_${{github.sha}}"

0 comments on commit 5682937

Please sign in to comment.