Skip to content

Commit c5e9124

Browse files
committed
Merge branch 'self-hosted-ci'
2 parents 154807c + 1f78717 commit c5e9124

File tree

13 files changed

+1078
-310
lines changed

13 files changed

+1078
-310
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,38 @@ env:
1616
ouisync/target/
1717
1818
jobs:
19-
test:
20-
name: test on ${{ matrix.name }}
21-
runs-on: ${{ matrix.os }}
22-
strategy:
23-
matrix:
24-
name: [linux, windows]
25-
include:
26-
- name: linux
27-
os: ubuntu-24.04
28-
env:
29-
OUISYNC_LIB: ouisync/target/debug/libouisync_service.so
30-
analyze: true
19+
test_linux:
20+
name: test on linux
21+
runs-on: self-hosted
3122

32-
- name: windows
33-
os: windows-latest
34-
env:
35-
# Install Dokan2.dll to where `flutter test` can find it
36-
DOKAN_DLL_OUTPUT_PATH: C:\Windows\System32
37-
OUISYNC_LIB: ouisync\target\debug\ouisync_service.dll
38-
# FIXME: The mount test fails on windows CI with a panic somewhere in the dokan-rust
39-
# crate. Disabling for now but it needs to be looked into.
40-
test-args: --exclude-tags mount
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
submodules: recursive
27+
28+
- name: Create container name
29+
run: echo "CONTAINER=ouisync-unit-test-linux-$GITHUB_RUN_ID" >> $GITHUB_ENV
30+
31+
- name: Start container
32+
run: ./docker/linux.sh --container $CONTAINER --srcdir . --cache start
4133

42-
env: ${{ matrix.env }}
34+
- name: Analyze
35+
run: ./docker/linux.sh --container $CONTAINER analyze
36+
37+
- name: Run tests
38+
run: ./docker/linux.sh --container $CONTAINER unit-test
39+
40+
- name: Stop container
41+
run: ./docker/linux.sh --container $CONTAINER stop
42+
if: always()
43+
44+
test_windows:
45+
name: test on windows
46+
runs-on: windows-latest
47+
env:
48+
# Install Dokan2.dll to where `flutter test` can find it
49+
DOKAN_DLL_OUTPUT_PATH: C:\Windows\System32
50+
OUISYNC_LIB: ouisync\target\debug\ouisync_service.dll
4351

4452
steps:
4553
- uses: actions/checkout@v4
@@ -54,18 +62,10 @@ jobs:
5462
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
5563
restore-keys: ${{ runner.os }}-cargo-
5664

57-
- name: Install dependencies (linux)
58-
run: |
59-
sudo apt update -y
60-
sudo apt-get install libfuse-dev
61-
if: matrix.name == 'linux'
62-
6365
# FIXME: when dokan is installed some tests fail with weird panic from the dokan-rust library.
64-
# Disabling for now. See also the comment for the `test-args` variable in the `windows`
65-
# strategy.
66+
# Disabling for now. See also the comment in the 'Run tests' step.
6667
# - name: Install dependencies (windows)
6768
# run: choco install dokany2
68-
# if: matrix.name == 'windows'
6969

7070
- uses: subosito/flutter-action@v2
7171
with:
@@ -109,25 +109,25 @@ jobs:
109109
- name: "[HACK] Force dokan-sys to build"
110110
run: cargo clean --package dokan-sys
111111
working-directory: ouisync
112-
if: matrix.name == 'windows'
113112

114113
- name: Build Ouisync service library for tests
115114
working-directory: ouisync
116115
run: cargo build --package ouisync-service --lib
117116

118117
- name: Run tests
119-
run:
120-
flutter test ${{ matrix.test-args }}
118+
# FIXME: The mount test fails on windows CI with a panic somewhere in the dokan-rust
119+
# crate. Disabling for now but it needs to be looked into.
120+
run: flutter test --exclude-tags mount
121121

122122
- name: Upload test/debug artifacts
123123
uses: actions/upload-artifact@v4
124124
with:
125125
# Name of the produced zip file
126-
name: test-artifacts-${{ matrix.name }}
126+
name: test-artifacts-${{ runner.os }}
127127
path: test/widget/artifacts/*
128128
if-no-files-found: ignore
129-
# Upload even when tests fail
130-
if: always()
129+
# Upload when tests fail
130+
if: failure()
131131

132132
build:
133133
name: build on ${{ matrix.name }}
@@ -280,8 +280,7 @@ jobs:
280280

281281
integration_test_android:
282282
name: "run integration tests on android ${{ matrix.api-level }}"
283-
runs-on: ubuntu-24.04
284-
283+
runs-on: self-hosted
285284
strategy:
286285
fail-fast: false
287286
matrix:
@@ -292,10 +291,7 @@ jobs:
292291
# - 25
293292

294293
- 26
295-
296-
# This uses different target so it's included explicitly
297-
# - 27
298-
294+
- 27
299295
- 28
300296
- 29
301297
- 30
@@ -305,50 +301,27 @@ jobs:
305301
- 34
306302
- 35
307303
- 36
308-
target:
309-
- google_apis
310-
include:
311-
- api-level: 27
312-
target: default
313-
steps:
314-
315-
- name: Enable KVM
316-
run: |
317-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
318-
sudo udevadm control --reload-rules
319-
sudo udevadm trigger --name-match=kvm
320304

305+
steps:
321306
- uses: actions/checkout@v4
322307
with:
323308
submodules: recursive
324309

325-
- uses: ./.github/actions/setup_android_tests
326-
327-
- name: Prebuild
328-
run: flutter build apk --debug --flavor itest --target-platform android-x64
329-
330310
- name: Run tests
331-
uses: reactivecircus/android-emulator-runner@v2
332-
with:
333-
api-level: ${{ matrix.api-level }}
334-
target: ${{ matrix.target }}
335-
arch: x86_64
336-
sdcard-path-or-size: 16M
337-
script: |
338-
adb logcat -c || true
339-
adb logcat > logcat.txt &
340-
yes | ./util/adb-format-sdcard.sh
341-
flutter test integration_test --flavor itest --ignore-timeouts
342-
343-
- name: Upload logcat
344-
uses: actions/upload-artifact@v4
345-
with:
346-
# Name of the produced zip file
347-
name: logcat-${{ matrix.api-level }}
348-
path: logcat.txt
349-
if-no-files-found: ignore
350-
# Upload only when the tests fail
351-
if: failure() || cancelled()
311+
run: |
312+
./docker/linux.sh \
313+
--container ouisync-integration-test-android-${{ matrix.api-level }}-$GITHUB_RUN_ID \
314+
integration-test --platform android --api ${{ matrix.api-level }}
315+
316+
# - name: Upload logcat
317+
# uses: actions/upload-artifact@v4
318+
# with:
319+
# # Name of the produced zip file
320+
# name: logcat-${{ matrix.api-level }}
321+
# path: logcat.txt
322+
# if-no-files-found: ignore
323+
# # Upload only when the tests fail
324+
# if: failure() || cancelled()
352325

353326

354327
# TODO: Integration tests on both linux and windows currently fail or hang. Commenting them out until they are fixed.
Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
FROM ubuntu:22.04
44

55
ARG NDK_VERSION
6+
ARG RUST_VERSION=1.91.0
7+
ARG FLUTTER_VERSION=3.32.5
68

7-
ENV FLUTTER_VERSION=3.32.5
8-
ENV RUST_VERSION=1.89.0
9-
10-
RUN apt-get update && apt-get upgrade -y
11-
RUN apt-get install -y \
12-
build-essential cmake ninja-build clang pkg-config \
13-
git xxd unzip \
14-
wget curl rsync \
15-
libgtk-3-dev libfuse-dev libappindicator3-dev libsecret-1-dev libcurl4-openssl-dev \
16-
python3-minimal python-is-python3 \
17-
openjdk-17-jdk
9+
RUN apt-get update && \
10+
apt-get upgrade -y && \
11+
apt-get install -y \
12+
build-essential cmake ninja-build clang pkg-config \
13+
git xxd unzip \
14+
wget curl rsync \
15+
libgtk-3-dev libfuse-dev libappindicator3-dev libsecret-1-dev libcurl4-openssl-dev \
16+
python3-minimal python-is-python3 \
17+
openjdk-17-jdk \
18+
libpulse0 \
19+
fuse3 \
20+
&& \
21+
apt-get clean
1822

1923
# download and install sdkmanager
2024
# https://developer.android.com/studio#command-tools
@@ -30,19 +34,25 @@ RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
3034
ENV PATH="${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${PATH}"
3135
RUN yes | sdkmanager --licenses
3236

33-
# These would be installed automatically, but good to have them in the image.
37+
# Install android packages (some of these would be installed automatically, but good to have them in
38+
# the image to speed things up).
39+
#
3440
# TODO: Why do we need different versions of `build-tools` and `platforms`?
35-
RUN sdkmanager --install \
36-
"ndk;$NDK_VERSION" \
37-
'build-tools;35.0.0' \
38-
'build-tools;36.0.0' \
39-
'platform-tools' \
40-
'platforms;android-31' \
41-
'platforms;android-33' \
42-
'platforms;android-34' \
43-
'platforms;android-35' \
44-
'cmake;3.22.1' \
45-
'cmdline-tools;latest'
41+
RUN sdkmanager --install \
42+
"cmdline-tools;latest" \
43+
"build-tools;35.0.0" \
44+
"build-tools;36.0.0" \
45+
"platform-tools" \
46+
"platforms;android-31" \
47+
"platforms;android-33" \
48+
"platforms;android-34" \
49+
"platforms;android-35" \
50+
"platforms;android-36" \
51+
"emulator" \
52+
"ndk;$NDK_VERSION" \
53+
"cmake;3.22.1"
54+
55+
ENV PATH="${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator:${PATH}"
4656

4757
# install flutter
4858
RUN wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz -P /tmp
@@ -56,19 +66,27 @@ RUN git config --global --add safe.directory /opt/flutter
5666

5767
RUN flutter config --enable-android --enable-linux-desktop
5868
RUN flutter precache --linux
59-
RUN flutter config --no-analytics
69+
RUN flutter config --no-analytics --no-cli-animations
6070
RUN yes | flutter doctor --android-licenses
71+
RUN dart --disable-analytics
6172
RUN flutter doctor -v
6273

63-
# install rust
74+
# Install rust
6475
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=${RUST_VERSION} -y
6576
ENV PATH="/root/.cargo/bin:$PATH"
6677
RUN rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android
6778

79+
# Install some rust utilities
80+
RUN cargo install cargo-sweep
81+
6882
# Expose Java
6983
# Sentry started to require JDK even for non Android builds. This requirement
7084
# might be removed in the future.
7185
# https://github.com/getsentry/sentry-dart/issues/3033#issuecomment-3140320200
7286
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
7387

88+
ENV LANG="C.UTF-8"
89+
ENV LANGUAGE="C.UTF-8"
90+
ENV LC_ALL="C.UTF-8"
91+
7492
WORKDIR /opt

docker/README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
# Docker building
1+
# Testing and building in Docker
22

3-
This folder contains scripts for building Ouisync App in remote docker containers.
3+
This folder contains scripts for testing and building Ouisync App in docker containers.
44

5-
The `build-linux.sh` script will build `aab`, `apk`, `deb-cli` and `deb-gui` packages.
6-
The `build-windows.sh` script will build `msix` and `exe` packages.
5+
- The `linux.sh` script is used to run unit and integration tests and to build release packages for
6+
linux and android.
7+
- The `build-windows.sh` script is used to build release packages for windows.
78

89
## Usage
910

10-
Assuming you have machines running Docker listed in your `~/.ssh/config` as `linux_machine` and `windows_machine`, run
11-
12-
```bash
13-
./docker/build-linux.sh --host linux_machine --commit <COMMIT_HASH>
14-
./docker/build-windows.sh --host windows_machine --commit <COMMIT_HASH>
15-
```
11+
Run `./docker/linux.sh --help` and `./docker/build-windows.sh --help` for usage instructions.
1612

1713
## Requirements
1814

19-
Have [pass](https://www.passwordstore.org/) installed with eQualitie's password repository.
15+
To build the release packages, have [pass](https://www.passwordstore.org/) installed with
16+
eQualitie's password repository.

0 commit comments

Comments
 (0)