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

Use Docker files for Linux workflows #666

Merged
merged 2 commits into from
Feb 19, 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
89 changes: 19 additions & 70 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,34 +103,25 @@ jobs:
path: ${{ steps.deb.outputs.path }}

rpm:
name: rpm (${{ matrix.build-type }}, Qt ${{ matrix.qt-version-major }}, ${{ matrix.container != '' && matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
name: rpm (${{ matrix.build-type }}, Qt ${{ matrix.qt-version-major }}, ${{ matrix.image }})
runs-on: ubuntu-latest
container: zjeffer/notes:${{ matrix.image }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
# Fedora's release cycle: https://docs.fedoraproject.org/en-US/releases/lifecycle/
container: fedora:38
- # Fedora's release cycle: https://docs.fedoraproject.org/en-US/releases/lifecycle/
image: fedora
qt-version-major: 6
build-type: release

- os: ubuntu-20.04
container: opensuse/leap:15
- image: opensuse
qt-version-major: 6
build-type: release
steps:
- name: Install build dependencies
env:
PKG_MANAGER: ${{ startsWith(matrix.container, 'fedora') && 'dnf' || 'zypper' }}
# Fedora doesn't include libxkbcommon-devel as a dependency of Qt 6, so have to install it manually.
PKG_LIST: ${{ startsWith(matrix.container, 'fedora') && 'libxkbcommon-devel qt6-qtbase-private-devel qt6-qtdeclarative-devel' || 'qt6-base-private-devel qt6-declarative-devel' }}
run: |
${{ env.PKG_MANAGER }} update -y
${{ env.PKG_MANAGER }} install -y cmake gcc git ${{ env.PKG_LIST }} rpm-build rpmlint
# Prevent git's dubious ownership message
git config --global --add safe.directory "${PWD}"
- name: Setup git configuration
# workaround for "detected dubious ownership in repository" git error: https://github.com/actions/checkout/issues/1169
run: git config --global --add safe.directory "${PWD}"

- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -164,7 +155,7 @@ jobs:
VERBOSE: 1
# openSUSE defaults to GCC 7, which doesn't support the filesystem library from C++17,
# and causes trouble compiling for Qt 6. So we have to manully specify GCC 10 instead.
CXX: ${{ startsWith(matrix.container, 'opensuse') && 'g++-10' || 'g++' }}
CXX: ${{ startsWith(matrix.image, 'opensuse') && 'g++-10' || 'g++' }}
run: |
cmake --warn-uninitialized --warn-unused-vars \
-B build \
Expand Down Expand Up @@ -211,45 +202,24 @@ jobs:
# NOTE: This job uses a fixed Qt version (set in the 'qt-version' key below)!
# So, remember to keep it updated whenever a new Qt version is available on aqtinstall.
appimage-aqtinstall:
name: AppImage (${{ matrix.build-type }}, Qt ${{ matrix.qt-version }}, ${{ matrix.container != '' && matrix.container || matrix.os }})
name: AppImage (${{ matrix.build-type }}, Qt ${{ matrix.qt-version }}, ${{ matrix.image }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
container:
image: zjeffer/notes:${{ matrix.image }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
container: ubuntu:20.04
- os: ubuntu-22.04
build-type: release
qt-version: 5.15.2

- os: ubuntu-20.04
container: ubuntu:20.04
image: ubuntu-aqtinstall-5

- os: ubuntu-22.04
build-type: release
qt-version: 6.4.3
image: ubuntu-aqtinstall-6
steps:
- name: Install other dependencies in docker container
# - appstream: Used to validate the AppStream metadata file.
# - cmake: Used to help build the application.
# - curl: Used to download the linuxdeploy AppImage tool.
# - desktop-file-utils: Used to validate the desktop file.
# - git: To clone this repository.
# - libfontconfig1: Used as dependency of the resulting AppImage.
# - libxcb-cursor0: Used as dependency of the resulting AppImage.
# - libxkbcommon-x11-0: Used as dependency of the resulting AppImage.
# - python3/python3-pip: Used by aqtinstall.
# - sudo: Used by most GitHub actions to install things.
if: matrix.container != ''
run: |
# Configure the timezone, otherwise 'install-qt-action' gets stuck at 'configuring tzdata'.
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
echo UTC > /etc/timezone
# install packages
apt update
apt install -y appstream cmake curl desktop-file-utils git libfontconfig1 libxcb-cursor0 libxkbcommon-x11-0 python3 python3-pip sudo
# Upgrade to the latest setuptools, as Ubuntu's python3-setuptools package has compatibility issues with aqtinstall.
python3 -m pip install --upgrade setuptools

- name: Checkout code
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -281,21 +251,6 @@ jobs:
echo "artifact_name=${artifact_name}" >> "${GITHUB_OUTPUT}"
echo "file_name=${file_name}" >> "${GITHUB_OUTPUT}"

- name: Install Qt ${{ matrix.qt-version }} (aqtinstall)
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
# Prevents the installation of a custom Python build, potentially linked against an unsupported version of glibc.
setup-python: false
cache: true

- name: Install Qt 6 system dependencies
# 'libmysqlclient21' is actually only needed by linuxdeploy for Qt 6 builds. I'm including it here just for convenience.
if: startsWith(matrix.qt-version, '6.')
run: |
sudo apt update
sudo apt install -y libxkbcommon-dev libmysqlclient21

# TODO: Figure out why this error only occurs on the Linux container when building with -DGIT_REVISION=ON
# The error: fatal: detected dubious ownership in repository
- name: Prevent git's dubious ownership message
Expand Down Expand Up @@ -336,12 +291,6 @@ jobs:
curl -fLO --retry 10 https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
chmod +x linuxdeploy-plugin-qt-x86_64.AppImage

- name: Install useless dependencies to make linuxdeploy happy
# We won't use any of these sql drivers, but install them anyway so linuxdeploy doesn't fail.
run: |
sudo apt update
sudo apt install -y libpq5 libodbc1

- name: Deploy (${{ matrix.build-type }})
env:
APPIMAGE_EXTRACT_AND_RUN: 1
Expand Down Expand Up @@ -372,7 +321,7 @@ jobs:
fi

- name: Validate AppStream metadata
if: matrix.container != 'ubuntu:20.04'
if: matrix.image != 'ubuntu:20.04'
run: |
cd build/Notes
appstreamcli validate --verbose 'usr/share/metainfo/${{ env.APP_ID }}.metainfo.xml'
Expand Down
17 changes: 17 additions & 0 deletions Dockerfiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Docker images for CI/CD

The Dockerfiles in this folder are used to build images for CI/CD pipelines.

### Building images locally

```bash
docker build -f <path-to-dockerfile> -t <image-name> .
# for example:
docker build -f ./ubuntu-aqtinstall-6 -t zjeffer:notes/ubuntu-aqtinstall-6.4.3 .
```

### Pushing images to Docker Hub

```bash
docker push <image-name>
```
5 changes: 5 additions & 0 deletions Dockerfiles/fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM fedora:38

RUN dnf update -y && \
dnf install -y cmake gcc git rpm-build rpmlint \
libxkbcommon-devel qt6-qtbase-private-devel qt6-qtdeclarative-devel
5 changes: 5 additions & 0 deletions Dockerfiles/opensuse
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM opensuse/leap:15

RUN zypper update -y && \
zypper install -y cmake gcc git rpm-build rpmlint \
qt6-base-private-devel qt6-declarative-devel
37 changes: 37 additions & 0 deletions Dockerfiles/ubuntu-aqtinstall-5
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM ubuntu:22.04

ENV QT_VERSION=5.15.2
ENV QT_ARCHITECTURE=gcc_64

# this image can also be used for appimage builds
# Configure the timezone, otherwise 'install-qt-action' gets stuck at 'configuring tzdata'.
RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime \
&& echo UTC > /etc/timezone

# install packages
# - appstream: Used to validate the AppStream metadata file.
# - cmake: Used to help build the application.
# - curl: Used to download the linuxdeploy AppImage tool.
# - desktop-file-utils: Used to validate the desktop file.
# - git: To clone this repository.
# - libfontconfig1: Used as dependency of the resulting AppImage.
# - libxcb-cursor0: Used as dependency of the resulting AppImage.
# - libxkbcommon-x11-0: Used as dependency of the resulting AppImage.
# - python3/python3-pip: Used by aqtinstall.
# - sudo: Used by most GitHub actions to install things.
# - libpq5: Useless, but needed to keep linuxdeploy happy
# - libodbc1: Useless, but needed to keep linuxdeploy happy
# - file: Necessary for building the AppImage
RUN apt update && \
apt install -y appstream cmake curl desktop-file-utils git libfontconfig1 libxcb-cursor0 libxkbcommon-x11-0 python3 python3-pip sudo \
libpq5 libodbc1 file \
# qt dependencies
build-essential libgl1-mesa-dev libgstreamer-gl1.0-0 libpulse-dev libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 \
libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb1 libxkbcommon-dev libxkbcommon-x11-0 libxcb-xkb-dev \
libqt5network5 libqt5sql5 libqt5widgets5 qml-module-qtquick2 qml-module-qtquick-controls2 qml-module-qtquick-window2

RUN python3 -m pip install --upgrade pip setuptools aqtinstall

# use aqtinstall to install qt
RUN python3 -m aqt install-qt --outputdir /Qt linux desktop $QT_VERSION $QT_ARCHITECTURE
ENV PATH="/Qt/$QT_VERSION/$QT_ARCHITECTURE/bin:$PATH"
40 changes: 40 additions & 0 deletions Dockerfiles/ubuntu-aqtinstall-6
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM ubuntu:22.04

ENV QT_VERSION=6.4.3
ENV QT_ARCHITECTURE=gcc_64

# this image can also be used for appimage builds
# Configure the timezone, otherwise 'install-qt-action' gets stuck at 'configuring tzdata'.
RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime \
&& echo UTC > /etc/timezone

# install packages
# - appstream: Used to validate the AppStream metadata file.
# - cmake: Used to help build the application.
# - curl: Used to download the linuxdeploy AppImage tool.
# - desktop-file-utils: Used to validate the desktop file.
# - git: To clone this repository.
# - libfontconfig1: Used as dependency of the resulting AppImage.
# - libxcb-cursor0: Used as dependency of the resulting AppImage.
# - libxkbcommon-x11-0: Used as dependency of the resulting AppImage.
# - python3/python3-pip: Used by aqtinstall.
# - sudo: Used by most GitHub actions to install things.
# - libpq5: Useless, but needed to keep linuxdeploy happy
# - libodbc1: Useless, but needed to keep linuxdeploy happy
# - file: Necessary for building the AppImage
RUN apt update && \
apt install -y appstream cmake curl desktop-file-utils git libfontconfig1 libxcb-cursor0 libxkbcommon-x11-0 python3 python3-pip sudo \
libpq5 libodbc1 file \
# qt dependencies
build-essential libgl1-mesa-dev libgstreamer-gl1.0-0 libpulse-dev libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 \
libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb1 libxkbcommon-dev libxkbcommon-x11-0 libxcb-xkb-dev \
libqt6network6 libqt6sql6 libqt6widgets6 qml6-module-qtqml-workerscript qml6-module-qtquick-controls qml6-module-qtquick-layouts qml6-module-qtquick-particles qml6-module-qtquick-templates qml6-module-qtquick-window qt6-qpa-plugins

RUN python3 -m pip install --upgrade pip setuptools aqtinstall

# qt6 dependencies
RUN apt install -y libxkbcommon-dev libmysqlclient21

# use aqtinstall to install qt
RUN python3 -m aqt install-qt --outputdir /Qt linux desktop $QT_VERSION $QT_ARCHITECTURE
ENV PATH="/Qt/$QT_VERSION/$QT_ARCHITECTURE/bin:$PATH"
Loading