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

Distribute aarch64 Linux tarball builds #1664

Merged
merged 79 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
9f0d51a
Test static arm64 linux builds
t3chguy May 10, 2024
fd6ed16
Split x-compile preparation stage
t3chguy May 10, 2024
4dad0a9
Simplify matrix-seshat hak build script
t3chguy May 10, 2024
303f9cb
Use docker command only around native build
t3chguy May 10, 2024
dbfe3a6
Fix dockerfile
t3chguy May 10, 2024
2bd650c
paths.fun
t3chguy May 10, 2024
624fec4
Fix Dockerfile
t3chguy May 10, 2024
194d954
Iterate
t3chguy May 10, 2024
f217a15
order
t3chguy May 10, 2024
6ab666d
Use self-hosted runner
t3chguy May 10, 2024
dfa2bc1
fpm yay
t3chguy May 10, 2024
f4a57bb
Install ruby 3.x
t3chguy May 10, 2024
f47634e
dotenv2.8.1
t3chguy May 10, 2024
2b83448
Run Linux tests on arm64
t3chguy May 11, 2024
6f95527
fix Dockerfile
t3chguy May 11, 2024
071727c
arch naming sucks.
t3chguy May 11, 2024
70a8bff
arg
t3chguy May 11, 2024
caca808
Fix runs-on
t3chguy May 11, 2024
48d5c13
Iterate
t3chguy May 13, 2024
08b22db
Iterate
t3chguy May 13, 2024
2b69504
Iterate
t3chguy May 13, 2024
9f965c9
Iterate
t3chguy May 13, 2024
451dcab
Iterate
t3chguy May 13, 2024
7f02a87
Simplify
t3chguy May 13, 2024
6f472dc
Iterate
t3chguy May 13, 2024
ac88a9d
Add super basic test for seshat
t3chguy May 13, 2024
3f6f288
Simplify
t3chguy May 13, 2024
826b874
Test inlining the world.
t3chguy May 13, 2024
7b8cdcb
Specify platform on docker runs
t3chguy May 13, 2024
af80ed9
Iterate
t3chguy May 13, 2024
afb220a
-w
t3chguy May 13, 2024
f0d1b78
Fix docker run
t3chguy May 13, 2024
a5acbb8
Iterate
t3chguy May 13, 2024
541e083
Install fpm in the docker image
t3chguy May 13, 2024
74a0744
Try static fpm
t3chguy May 13, 2024
e00f076
Iterate
t3chguy May 13, 2024
e9acadc
Delint
t3chguy May 13, 2024
c81e3c5
Update snapshot
t3chguy May 13, 2024
3898a07
Improve tests to run on arm64 & smoketest seshat
t3chguy May 13, 2024
1a71abe
Merge branch 't3chguy/better-testing' of https://github.com/vector-im…
t3chguy May 13, 2024
3eb80f3
TEST: use self hosted runner and no QEMU
t3chguy May 13, 2024
b6278a1
Iterate
t3chguy May 13, 2024
6f15f70
Add glibc check to Linux build
t3chguy May 13, 2024
5635f98
Iterate
t3chguy May 13, 2024
7d726d6
Iterate
t3chguy May 13, 2024
dd39218
Fix context
t3chguy May 13, 2024
3a9b264
Merge branch 't3chguy/glibc-check' of https://github.com/vector-im/el…
t3chguy May 13, 2024
691f997
sudo
t3chguy May 13, 2024
cf99b37
cachebust
t3chguy May 13, 2024
76451fc
uidgid
t3chguy May 13, 2024
0178454
chown?
t3chguy May 13, 2024
919a5e5
sudo?
t3chguy May 13, 2024
f276061
Iterate
t3chguy May 14, 2024
b45af1e
tmpfs noroot
t3chguy May 14, 2024
29d257f
Test
t3chguy May 14, 2024
5a35b1f
sudo =(
t3chguy May 14, 2024
5534980
freaking sudo
t3chguy May 14, 2024
16e83e2
preserve-env
t3chguy May 14, 2024
23a2dd3
DEBUG
t3chguy May 14, 2024
20f609f
chown and no sudo
t3chguy May 14, 2024
33aecf2
Split hak build stage
t3chguy May 14, 2024
368ee97
yarn install
t3chguy May 14, 2024
7b9f599
Yay no git...
t3chguy May 14, 2024
2d27868
Library not found fallback
t3chguy May 14, 2024
bf96160
Merge branch 'develop' of https://github.com/vector-im/element-deskto…
t3chguy May 14, 2024
aca961a
Check native libs in hak stage to ensure the cache is coherent
t3chguy May 14, 2024
2ac5406
test allow glibc 2.29
t3chguy May 14, 2024
e78209c
cachebust
t3chguy May 14, 2024
3cd49a1
zstd?
t3chguy May 14, 2024
f5b69af
Iterate
t3chguy May 14, 2024
9dcb1ad
Iterate
t3chguy May 14, 2024
520006a
Merge branch 'develop' into t3chguy/better-testing
t3chguy May 14, 2024
c04dc63
Merge branch 't3chguy/better-testing' of https://github.com/vector-im…
t3chguy May 14, 2024
53fe890
Simplify
t3chguy May 14, 2024
da5ceac
Discard changes to hak/matrix-seshat/build.ts
t3chguy May 14, 2024
26cf4e5
Merge branch 'develop' into t3chguy/static-linux-arm64
t3chguy May 14, 2024
e69a74c
Raise SQLCIPHER_BUNDLED
t3chguy May 14, 2024
ae861f6
Merge remote-tracking branch 'origin/t3chguy/static-linux-arm64' into…
t3chguy May 14, 2024
2b60432
delint
t3chguy May 14, 2024
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
13 changes: 10 additions & 3 deletions .github/workflows/build_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ jobs:
matrix:
arch: [amd64, arm64]
sqlcipher: [system, static]
exclude:
- arch: arm64
sqlcipher: static
uses: ./.github/workflows/build_linux.yaml
with:
arch: ${{ matrix.arch }}
Expand Down Expand Up @@ -136,6 +133,10 @@ jobs:
mkdir -p packages.element.io/install/linux/glibc-x86-64
mv linux-amd64-sqlcipher-static/*.tar.gz packages.element.io/install/linux/glibc-x86-64
fi
if [ -d linux-arm64-sqlcipher-static ]; then
mkdir -p packages.element.io/install/linux/glibc-aarch64
mv linux-arm64-sqlcipher-static/*.tar.gz packages.element.io/install/linux/glibc-aarch64
fi

# We don't wish to store the installer for every nightly ever, so we only keep the latest
- name: "[Nightly] Strip version from installer file"
Expand All @@ -152,6 +153,7 @@ jobs:

# Linux
[ -d linux-amd64-sqlcipher-static ] && mv packages.element.io/install/linux/glibc-x86-64/{*,element-desktop-nightly}.tar.gz
[ -d linux-arm64-sqlcipher-static ] && mv packages.element.io/install/linux/glibc-aarch64/{*,element-desktop-nightly}.tar.gz

- name: "[Release] Prepare release latest symlink"
if: needs.prepare.outputs.nightly-version == ''
Expand Down Expand Up @@ -179,6 +181,11 @@ jobs:
ln -s "$(find . -type f -iname "*.tar.gz" | xargs -0 -n1 -- basename)" "element-desktop.tar.gz"
popd
fi
if [ -d linux-arm64-sqlcipher-static ]; then
pushd packages.element.io/install/linux/glibc-aarch64
ln -s "$(find . -type f -iname "*.tar.gz" | xargs -0 -n1 -- basename)" "element-desktop.tar.gz"
popd
fi

- name: Stash packages.element.io
if: needs.prepare.outputs.deploy == 'false'
Expand Down
61 changes: 6 additions & 55 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,71 +23,17 @@ jobs:
with:
arch: ${{ matrix.arch }}

# This allows core contributors to test changes to the dockerbuild image within a pull request
linux_docker:
name: Linux docker
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
outputs:
docker-image: ${{ steps.docker.outputs.image }}
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-dockerbuild-pr
steps:
- uses: actions/checkout@v4

- name: "Get modified files"
id: changed_files
uses: tj-actions/changed-files@635f118699dd888d737c15018cd30aff2e0274f8 # v44
with:
files: |
dockerbuild/**
- name: Log in to the Container registry
if: steps.changed_files.outputs.any_modified == 'true'
uses: docker/login-action@5f4866a30a54f16a52d2ecb4a3898e9e424939cf
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: docker
if: steps.changed_files.outputs.any_modified == 'true'
run: |
echo "image=$IMAGE:$PR" >> $GITHUB_OUTPUT
env:
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
PR: ${{ github.event.pull_request.number }}

- name: Build and push Docker image
if: steps.changed_files.outputs.any_modified == 'true'
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5
with:
context: dockerbuild
push: true
tags: ${{ steps.docker.outputs.image }}

linux:
needs:
- fetch
- linux_docker
needs: fetch
name: "Linux (${{ matrix.arch }}) (sqlcipher: ${{ matrix.sqlcipher }})"
uses: ./.github/workflows/build_linux.yaml
strategy:
matrix:
sqlcipher: [system, static]
arch: [amd64, arm64]
exclude:
# FIXME: This combination yields a broken Seshat at this time
# Errors at launch with `undefined symbol: PKCS5_PBKDF2_HMAC
- arch: arm64
sqlcipher: static
with:
config: ${{ github.event.pull_request.base.ref == 'develop' && 'element.io/nightly' || 'element.io/release' }}
sqlcipher: ${{ matrix.sqlcipher }}
docker-image: ${{ needs.linux_docker.outputs.docker-image }}
arch: ${{ matrix.arch }}

macos:
Expand Down Expand Up @@ -128,6 +74,11 @@ jobs:
artifact: linux-arm64-sqlcipher-system
executable: "/opt/Element/element-desktop"
prepare_cmd: "sudo apt install -y ./dist/*.deb"
- name: "Linux (arm64) (sqlcipher: static)"
os: dind-l-arm64
artifact: linux-arm64-sqlcipher-static
executable: "/opt/Element/element-desktop"
prepare_cmd: "sudo apt install -y ./dist/*.deb"
- name: Windows (x86)
os: windows-latest
artifact: win-ia32
Expand Down
129 changes: 96 additions & 33 deletions .github/workflows/build_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,31 @@ on:
type: string
required: true
description: "How to link sqlcipher, one of 'system' | 'static'"
docker-image:
type: string
required: false
description: "The docker image to use for the build, defaults to ghcr.io/element-hq/element-desktop-dockerbuild"
env:
SQLCIPHER_BUNDLED: ${{ inputs.sqlcipher == 'static' && '1' || '' }}
jobs:
build:
runs-on: ubuntu-latest
container:
image: ${{ inputs.docker-image || format('ghcr.io/element-hq/element-desktop-dockerbuild:{0}', github.ref_name == 'master' && 'master' || 'develop') }}
defaults:
run:
shell: bash
# We build the hak files on native infrastructure as matrix-seshat fails to cross-compile properly
# https://github.com/matrix-org/seshat/issues/135
hak:
runs-on: ${{ inputs.arch == 'arm64' && 'dind-l-arm64' || 'ubuntu-latest' }}
env:
HAK_DOCKER_IMAGE: ${{ format('ghcr.io/element-hq/element-desktop-dockerbuild:{0}', github.event_name == 'pull_request' && 'develop' || github.ref_name) }}
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
arch: ${{ steps.config.outputs.arch }}
build-args: ${{ steps.config.outputs.build-args }}
steps:
# Workaround for self-hosted runners lacking tools
- name: Install missing tools
if: runner.environment == 'self-hosted'
run: |
sudo apt-get -qq update
# curl for yarn download, git for tj-actions/changed-files, zstd for actions/cache
sudo apt-get install -y curl git zstd
curl -fsSL --create-dirs -o $HOME/bin/yarn https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn-1.22.19.js
chmod +x $HOME/bin/yarn
echo "$HOME/bin" >> $GITHUB_PATH

- uses: nbucic/variable-mapper@0673f6891a0619ba7c002ecfed0f9f4f39017b6f
id: config
with:
Expand All @@ -57,11 +69,18 @@ jobs:
with:
name: webapp

- name: Calculate cache key
id: cache-key
run: |
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUT
env:
CACHE_KEY: ${{ runner.os }}-${{ github.ref_name }}-${{ inputs.sqlcipher }}-${{ inputs.arch }}-${{ hashFiles('hakHash', 'electronVersion', 'dockerbuild/*') }}

- name: Cache .hak
id: cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}-${{ inputs.docker-image || github.ref_name }}-${{ inputs.sqlcipher }}-${{ inputs.arch }}-${{ hashFiles('hakHash', 'electronVersion') }}
key: ${{ steps.cache-key.outputs.key }}
path: |
./.hak

Expand All @@ -77,27 +96,73 @@ jobs:
- name: Install Deps
run: "yarn install --frozen-lockfile"

- name: Prepare for static sqlcipher build
if: inputs.sqlcipher == 'static'
run: |
echo "SQLCIPHER_BUNDLED=1" >> $GITHUB_ENV
- name: "Get modified files"
id: changed_files
if: steps.cache.outputs.cache-hit != 'true' && github.event_name == 'pull_request'
uses: tj-actions/changed-files@635f118699dd888d737c15018cd30aff2e0274f8 # v44
with:
files: |
dockerbuild/**

# Ideally the docker image would be ready for cross-compilation but libsqlcipher-dev is not Multi-Arch compatible
# https://unix.stackexchange.com/a/349359
- name: Prepare for cross compilation
if: steps.cache.outputs.cache-hit != 'true' && inputs.arch == 'arm64'
run: |
set -x
dpkg --add-architecture arm64
apt-get -qq update
apt-get -qq install --no-install-recommends crossbuild-essential-arm64 libsqlcipher-dev:arm64 libssl-dev:arm64 libsecret-1-dev:arm64
rustup target add aarch64-unknown-linux-gnu
mv dockerbuild/aarch64/.cargo .
cat dockerbuild/aarch64/.env >> $GITHUB_ENV
# This allows contributors to test changes to the dockerbuild image within a pull request
- name: Build docker image
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5
if: steps.changed_files.outputs.any_modified == 'true'
with:
context: dockerbuild
load: true
platforms: linux/${{ inputs.arch }}
tags: ${{ env.HAK_DOCKER_IMAGE }}

- name: Build Natives
if: steps.cache.outputs.cache-hit != 'true'
run: "yarn build:native --target ${{ steps.config.outputs.target }}"
run: |
docker run \
-v ${{ github.workspace }}:/work -w /work \
-e SQLCIPHER_BUNDLED \
$HAK_DOCKER_IMAGE \
yarn build:native

- name: Check native libraries
run: |
shopt -s globstar

for filename in ./.hak/hakModules/**/*.node; do
./scripts/glibc-check.sh $filename
done
env:
MAX_VER: 2.28 # buster-era glibc

build:
needs: hak
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: webapp

- name: Load .hak
id: cache
uses: actions/cache/restore@v4
with:
key: ${{ needs.hak.outputs.cache-key }}
fail-on-cache-miss: true
path: |
./.hak

- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: "yarn"
env:
# Workaround for https://github.com/actions/setup-node/issues/317
FORCE_COLOR: 0

# Does not need branch matching as only analyses this layer
- name: Install Deps
run: "yarn install --frozen-lockfile"

- name: "[Nightly] Resolve version"
if: inputs.version != ''
Expand All @@ -111,8 +176,7 @@ jobs:
fi

- name: Build App
run: |
yarn build --publish never -l ${{ steps.config.outputs.build-args }}
run: yarn build --publish never -l ${{ needs.hak.outputs.build-args }}

- name: Check native libraries
run: |
Expand All @@ -139,9 +203,8 @@ jobs:
fi

./scripts/glibc-check.sh dist/linux-*unpacked/element-desktop*
./scripts/glibc-check.sh dist/linux-*unpacked/resources/app.asar.unpacked/node_modules/matrix-seshat/index.node
env:
ARCH: ${{ steps.config.outputs.arch }}
ARCH: ${{ needs.hak.outputs.arch }}

# We exclude *-unpacked as it loses permissions and the tarball contains it with correct permissions
- name: Upload Artifacts
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/dockerbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Dockerbuild
on:
workflow_dispatch: {}
push:
branches: [master, develop]
branches: [master, staging, develop]
paths:
- "dockerbuild/**"
concurrency: ${{ github.workflow }}-${{ github.ref_name }}
Expand All @@ -19,6 +19,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3
with:
install: true

- name: Log in to the Container registry
uses: docker/login-action@5f4866a30a54f16a52d2ecb4a3898e9e424939cf
with:
Expand All @@ -41,3 +49,4 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
42 changes: 10 additions & 32 deletions dockerbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
# Docker image to facilitate building Element Desktop with native bits using a glibc version with broader compatibility
FROM buildpack-deps:buster-curl
# Docker image to facilitate building Element Desktop's native bits using a glibc version with broader compatibility
FROM rust:buster

ENV DEBIAN_FRONTEND noninteractive

RUN curl --proto "=https" -L https://yarnpkg.com/latest.tar.gz | tar xvz && mv yarn-* /yarn && ln -s /yarn/bin/yarn /usr/bin/yarn
RUN apt-get -qq update && apt-get -qq dist-upgrade && \
# add repo for git-lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
# git ssh for using as docker image on CircleCI
# python for node-gyp
# rpm is required for FPM to build rpm package
apt-get -qq install --no-install-recommends \
# tclsh is required for building SQLite as part of SQLCipher
tcl \
# libsecret-1-dev is required even for prebuild keytar
apt-get -qq install --no-install-recommends qtbase5-dev bsdtar build-essential autoconf libssl-dev gcc-multilib g++-multilib lzip rpm python libcurl4 git git-lfs ssh unzip tcl \
libsecret-1-dev \
libopenjp2-tools \
# Used by github actions \
jq grep file \
# Used by seshat (when not SQLCIPHER_STATIC) \
libsqlcipher-dev && \
# git-lfs
git lfs install && \
apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/*

WORKDIR /project

# fix error /usr/local/bundle/gems/fpm-1.5.0/lib/fpm/package/freebsd.rb:72:in `encode': "\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
# http://jaredmarkell.com/docker-and-locales/
# http://askubuntu.com/a/601498
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8
RUN ln -s /usr/bin/python3 /usr/bin/python & ln -s /usr/bin/pip3 /usr/bin/pip

ENV DEBUG_COLORS true
ENV FORCE_COLOR true
ENV NODE_VERSION 18.19.0

# this package is used for snapcraft and we should not clear apt list - to avoid apt-get update during snap build
RUN curl --proto "=https" -L https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz | tar xz -C /usr/local --strip-components=1 && \
unlink /usr/local/CHANGELOG.md && unlink /usr/local/LICENSE && unlink /usr/local/README.md

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal
ENV NODE_VERSION 18.19.0
ARG TARGETOS
ARG TARGETARCH
COPY setup.sh /setup.sh
RUN /setup.sh
3 changes: 0 additions & 3 deletions dockerbuild/aarch64/.cargo/config.toml

This file was deleted.

Loading
Loading