Skip to content

Commit

Permalink
CI: github actions ensure compiler support
Browse files Browse the repository at this point in the history
  • Loading branch information
henryborchers committed Aug 16, 2023
1 parent 9a69dda commit e54b952
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 32 deletions.
79 changes: 47 additions & 32 deletions .github/workflows/tox_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,73 +11,88 @@ 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
run: |
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}}"


23 changes: 23 additions & 0 deletions ci/docker/shared/conan/ensure_compiler_support_by_conan.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit e54b952

Please sign in to comment.