From 9a69ddaeca94067aa4b27a33003ef897ad89ac3b Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 16 Aug 2023 13:05:07 -0500 Subject: [PATCH 1/2] update test files url --- tests/CMakeLists.txt | 2 +- tests/conftest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4c9b4208..723ed8a2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -set(TEST_FILES_BASE_URL "https://jenkins.library.illinois.edu/nexus/repository/sample-data/ocr_test_images") +set(TEST_FILES_BASE_URL "https://nexus.library.illinois.edu/repository/sample-data/ocr_test_images") list(APPEND test_image_files blankpage.tif) list(APPEND test_image_files engwithheadings.tif) diff --git a/tests/conftest.py b/tests/conftest.py index 621a1461..7612b312 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,7 +5,7 @@ import pytest -USER_CONTENT_URL = "https://jenkins.library.illinois.edu/nexus/repository/sample-data/ocr_test_images" +USER_CONTENT_URL = "https://nexus.library.illinois.edu/repository/sample-data/ocr_test_images" TESSDATA_SOURCE_URL = "https://github.com/tesseract-ocr/tessdata/raw/main/" From e54b9525119ed096f3d5b546138fc05249127745 Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 16 Aug 2023 13:18:58 -0500 Subject: [PATCH 2/2] CI: github actions ensure compiler support --- .github/workflows/tox_matrix.yml | 79 +++++++++++-------- .../conan/ensure_compiler_support_by_conan.py | 23 ++++++ 2 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 ci/docker/shared/conan/ensure_compiler_support_by_conan.py diff --git a/.github/workflows/tox_matrix.yml b/.github/workflows/tox_matrix.yml index 89c588f6..db7dfc47 100644 --- a/.github/workflows/tox_matrix.yml +++ b/.github/workflows/tox_matrix.yml @@ -11,44 +11,73 @@ jobs: - os: macos-latest compiler_version: 14.0 compiler_libcxx: libc++ - conan_user_home: "/Users/runner" - os: ubuntu-latest - compiler_version: 11.3 + compiler_version: 11.4 compiler_libcxx: libstdc++11 - conan_user_home: "/home/runner" - os: windows-2019 compiler_version: 16 - conan_user_home: 'C:/Users/runneradmin' fail-fast: false name: Python ${{ matrix.python-version }} ${{ matrix.os }} build steps: + - uses: actions/github-script@v6 + id: conan-path-script + with: + result-encoding: string + script: | + if ('${{matrix.os}}' === 'windows-2019'){ + return 'C:/Users/runneradmin' + } + if ('${{matrix.os}}' === 'ubuntu-latest'){ + return '/home/runner' + } + if ('${{matrix.os}}' === 'macos-latest'){ + return '/Users/runner' + } + return '' - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: 'pip' # caching pip dependencies - cache-dependency-path: '**/requirements-dev.txt' + cache-dependency-path: | + requirements-ci.txt + requirements/requirements-*.txt - run: | pip install wheel - pip install -r requirements-dev.txt + pip install -r requirements-ci.txt - uses: actions/cache@v3 - id: cache + id: cache-conan with: - path: "${{ matrix.conan_user_home }}/.conan" - key: ${{ runner.os }}-${{ hashFiles('**/conanfile.py') }} + path: "${{steps.conan-path-script.outputs.result}}/.conan" + key: ${{ runner.os }}-compiler-${{ matrix.compiler_version}} ${{ hashFiles('**/conanfile.py') }} + - name: Ensure conan settings has current compiler as valid + if: "!contains(matrix.os, 'windows')" + env: + CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" + run: | + conan config init + python ci/docker/shared/conan/ensure_compiler_support_by_conan.py $(conan config home)/settings.yml ${{matrix.compiler_version}} + conan profile update settings.compiler.version=${{matrix.compiler_version}} default - - name: Build conan packages on Windows - if: ${{ contains(matrix.os, 'windows') && steps.cache.outputs.cache-hit != 'true' }} + - name: Prebuild Conan packages (Windows) + if: | + contains(matrix.os, 'windows') && steps.cache-conan.outputs.cache-hit != 'true' shell: cmd + env: + CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - pip install -r requirements/requirements-conan.txt - conan config init - conan config set general.revisions_enabled=1 conan profile new default --detect - conan install . --build missing --no-import -pr:b=default + conan config set general.revisions_enabled=1 + conan install . --build missing --build=openjpeg --no-import -pr:b=default + + - name: Prebuild Conan packages env: - CONAN_USER_HOME: ${{ matrix.conan_user_home }} + CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" + if: "!contains(matrix.os, 'windows') && steps.cache-conan.outputs.cache-hit != 'true'" + run: | + conan config set general.revisions_enabled=1 + conan install . --build missing --build=openjpeg --no-import -pr:b=default - name: Run tox on Windows if: contains(matrix.os, 'windows') shell: cmd @@ -56,28 +85,14 @@ jobs: call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" tox -e py env: - CONAN_USER_HOME: ${{ matrix.conan_user_home }} + CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" - - name: Build conan packages on Non-Windows Operating Systems - if: ${{ !contains(matrix.os, 'windows') && steps.cache.outputs.cache-hit != 'true' }} - run: | - cc --version && cc -dumpfullversion -dumpversion - pip install -r requirements/requirements-conan.txt - if conan profile show default; then echo 'profile exists'; else conan profile new default --detect; fi - conan config init - conan config set general.revisions_enabled=1 - if [[ -z "$CONAN_COMPILER_LIBCXX" ]]; then echo 'CONAN_COMPILER_LIBCXX is not defined'; else conan profile update settings.compiler.libcxx=$CONAN_COMPILER_LIBCXX default; fi - conan install . --build missing --build openjpeg --no-import -pr:b=default - env: - CONAN_COMPILER_VERSION: ${{ matrix.compiler_version }} - CONAN_COMPILER_LIBCXX: ${{ matrix.compiler_libcxx }} - CONAN_USER_HOME: ${{ matrix.conan_user_home }} - name: Run tox on Non-Windows Operating Systems if: "!contains(matrix.os, 'windows')" run: tox -e py -vvv env: CONAN_COMPILER_VERSION: ${{ matrix.compiler_version }} CONAN_COMPILER_LIBCXX: ${{ matrix.compiler_libcxx }} - CONAN_USER_HOME: ${{ matrix.conan_user_home }} + CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" diff --git a/ci/docker/shared/conan/ensure_compiler_support_by_conan.py b/ci/docker/shared/conan/ensure_compiler_support_by_conan.py new file mode 100644 index 00000000..71491a97 --- /dev/null +++ b/ci/docker/shared/conan/ensure_compiler_support_by_conan.py @@ -0,0 +1,23 @@ +import yaml +import argparse + +def get_arg_parser(): + parser = argparse.ArgumentParser() + parser.add_argument("settings") + parser.add_argument("compiler_version") + return parser + + +def main(): + parser = get_arg_parser() + args = parser.parse_args() + with open(args.settings) as fp: + data = yaml.safe_load(fp) + if args.compiler_version not in data['compiler']['gcc']['version']: + data['compiler']['gcc']['version'].append(args.compiler_version) + with open(args.settings, "w") as fp: + yaml.dump(data, fp) + print(f"Updated {args.settings}") + +if __name__ == '__main__': + main() \ No newline at end of file