Skip to content

Commit

Permalink
Merge pull request #337 from opendocument-app/fix-ci-conan-core
Browse files Browse the repository at this point in the history
Fix CI build with core
  • Loading branch information
andiwand authored Apr 27, 2024
2 parents b192766 + 9891604 commit 8cc5db6
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 42 deletions.
80 changes: 54 additions & 26 deletions .github/workflows/android_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ name: OpenDocument-Reader-Android

on:
workflow_dispatch:
pull_request:
push:
paths-ignore:
- '**.md'
push:
- '.github/**'
- '!.github/workflows/android_main.yml'
branches:
- main
pull_request:
paths-ignore:
- '**.md'
- '.github/**'
- '!.github/workflows/android_main.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-20.04
Expand All @@ -19,49 +27,59 @@ jobs:
- name: checkout
uses: actions/checkout@v3

- name: ninja
- name: install ninja
run: sudo apt-get install -y ninja-build
- name: java
- name: setup java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17

- name: set up python 3.8
- name: setup python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: install pip and conan
run: python -m pip install --upgrade pip conan
- name: conan revisions
run: python -m pip install --upgrade pip conan==1.*

- name: conan config
run: conan config set general.revisions_enabled=1
- name: conan repo
run: conan remote add odr https://odr.jfrog.io/artifactory/api/conan/odr-conan
run: conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan

- name: tweak conan profile for build machine
run: |
echo "" >> conanprofile_build.txt
echo "[settings]" >> conanprofile_build.txt
echo "compiler=clang" >> conanprofile_build.txt
echo "compiler.libcxx=libstdc++11" >> conanprofile_build.txt
echo "" >> conanprofile_build.txt
- run: ./gradlew assembleDebug lintProDebug lintLiteDebug --stacktrace
- name: gradle
run: ./gradlew assembleDebug lintProDebug lintLiteDebug --stacktrace

- uses: actions/upload-artifact@v3
- name: upload apks
uses: actions/upload-artifact@v3
with:
name: APKs
path: app/build/outputs/apk/**/*.apk
if-no-files-found: error

- uses: actions/upload-artifact@v3
- name: upload lint results
uses: actions/upload-artifact@v3
with:
name: lint-report
path: app/build/reports/lint-results-*.html
if-no-files-found: error

test:
runs-on: macos-11
strategy:
fail-fast: false
# Make sure the matrix here and in cache_AVD_images.yml is the same
matrix:
include:
# Oldest version we support
- arch: x86
api-level: 19
# Oldest x86_64
- arch: x86_64
api-level: 21
Expand All @@ -81,28 +99,37 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17

- name: brew
- name: install brew
run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
- name: fix ninja install
run: rm '/usr/local/bin/2to3'
- name: ninja
- name: install ninja
run: brew install ninja
# https://stackoverflow.com/a/57758679/198996
- name: bundler
- name: install bundler
run: gem install bundler:1.17.3
- name: fastlane
- name: install fastlane
run: bundle install

- name: pip
- name: install pip
run: python3 -m ensurepip
- name: conan
run: pip3 install conan
- name: conan revisions
- name: install conan
run: pip3 install --upgrade conan==1.*

- name: conan config
run: conan config set general.revisions_enabled=1
- name: conan repo
run: conan remote add odr https://odr.jfrog.io/artifactory/api/conan/odr-conan
run: conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan

- name: tweak conan profile for build machine
run: |
echo "" >> conanprofile_build.txt
echo "[settings]" >> conanprofile_build.txt
echo "compiler=clang" >> conanprofile_build.txt
echo "compiler.libcxx=libc++" >> conanprofile_build.txt
echo "" >> conanprofile_build.txt
- name: Android Virtual Device (AVD) cache
uses: actions/cache@v3
Expand Down Expand Up @@ -152,7 +179,8 @@ jobs:
test ! -f sorry_but_tests_are_failing
- uses: actions/upload-artifact@v3
- name: upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: testResults-${{ matrix.api-level }}-${{ matrix.arch }}
Expand Down
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# make sure "which conan" points to a version of 1.x
# create virtual environment in project root and "pip install conan==1.*"
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/bin")
# or make sure "which conan" points to a version of 1.x

# TODO: call FIND_PROGRAM(conan) here manually so the location is cached for later
# TODO: use proper virtual environment

Expand All @@ -23,14 +26,17 @@ string(REPLACE "armeabi-v7a" "armv7" ARCH "${ARCH}")
string(REPLACE "arm64-v8a" "armv8" ARCH "${ARCH}")

include(${CMAKE_CURRENT_LIST_DIR}/app/conan.cmake)
conan_cmake_autodetect(settings ARCH ${ARCH})
conan_cmake_autodetect(settings_host ARCH ${ARCH})
# inspired from here https://docs.conan.io/en/latest/integrations/cross_platform/android.html
configure_file(app/toolchain.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/toolchain.cmake @ONLY)
conan_cmake_install(PATH_OR_REFERENCE ${CMAKE_CURRENT_LIST_DIR}
BUILD missing
SETTINGS ${settings}
PROFILE ${CMAKE_CURRENT_LIST_DIR}/conanprofile.txt
ENV CONAN_CMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_BINARY_DIR}/toolchain.cmake)
SETTINGS_HOST ${settings_host} compiler.libcxx=c++_shared
PROFILE_BUILD ${CMAKE_CURRENT_LIST_DIR}/conanprofile_build.txt
PROFILE_HOST ${CMAKE_CURRENT_LIST_DIR}/conanprofile_host.txt
ENV_HOST
CONAN_CMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_BINARY_DIR}/toolchain.cmake
ANDROID_NDK_ROOT=${CMAKE_ANDROID_NDK})
include(${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake)

find_package(odr REQUIRED)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ Feel free to use it in your own project too, but please don't forget to tell us
height="80">](https://play.google.com/store/apps/details?id=at.tomtasche.reader)

More information at http://reader.tomtasche.at/ and in the app itself.

## Setup

- `conan remote add odr https://artifactory.opendocument.app/artifactory/api/conan/conan`
9 changes: 5 additions & 4 deletions app/src/main/cpp/CoreWrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#include "CoreWrapper.h"
#include <string>
#include <optional>

#include <odr/document.hpp>
#include <odr/document_cursor.hpp>
#include <odr/document_element.hpp>
#include <odr/file.hpp>
#include <odr/html.hpp>
#include <odr/open_document_reader.hpp>
#include <odr/exceptions.hpp>

#include <android/log.h>

#include <string>
#include <optional>

std::optional<odr::Html> html;

JNIEXPORT jobject JNICALL
Expand Down
1 change: 0 additions & 1 deletion conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ odrcore/3.0.0@
cmake
cmake_paths
cmake_find_package

6 changes: 0 additions & 6 deletions conanprofile.txt

This file was deleted.

11 changes: 11 additions & 0 deletions conanprofile_build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include(default)

[settings]
build_type=Release

[env]
CONAN_RUN_TESTS=False
CONAN_CMAKE_GENERATOR=Ninja

[conf]
tools.build:skip_test=True
16 changes: 16 additions & 0 deletions conanprofile_host.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(default)

[settings]
os=Android
os.api_level=19
compiler=clang
compiler.libcxx=c++_shared
build_type=Release

[env]
CONAN_RUN_TESTS=False
CONAN_CMAKE_GENERATOR=Ninja

[conf]
tools.android:ndk_path=$ENV{ANDROID_NDK_ROOT}
tools.build:skip_test=True

0 comments on commit 8cc5db6

Please sign in to comment.