|
| 1 | +name: "Setup Runner" |
| 2 | +description: "Setup Python, System Dependencies and configure CCache" |
| 3 | + |
| 4 | +inputs: |
| 5 | + python-version: |
| 6 | + required: true |
| 7 | + python-arch: |
| 8 | + required: true |
| 9 | + |
| 10 | +outputs: |
| 11 | + nproc: |
| 12 | + description: "The number of processors" |
| 13 | + value: ${{ steps.install-deps.outputs.nproc }} |
| 14 | + python-root-dir: |
| 15 | + description: "The Python_ROOT_DIR" |
| 16 | + value: ${{ steps.install-deps.outputs.python-root-dir }} |
| 17 | + ccache-dir: |
| 18 | + description: "The ccache directory" |
| 19 | + value: ${{ steps.install-deps.outputs.ccache-dir }} |
| 20 | + compiler-id: |
| 21 | + description: "The computer compiler id to use as a caching key" |
| 22 | + value: ${{ steps.install-deps.outputs.compiler-id }} |
| 23 | + |
| 24 | +runs: |
| 25 | + using: "composite" |
| 26 | + steps: |
| 27 | + |
| 28 | + - name: Set up Python ${{ inputs.python-version }} |
| 29 | + id: setup-python |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: ${{ inputs.python-version }} |
| 33 | + architecture: ${{ inputs.python-arch }} |
| 34 | + |
| 35 | + - name: Install Dependencies |
| 36 | + id: install-deps |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + echo "Configuring" |
| 40 | + begin_group() { echo -e "::group::\033[93m$1\033[0m"; } |
| 41 | +
|
| 42 | + begin_group "Figure out NPROC" |
| 43 | + NPROC=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu) |
| 44 | + echo "There are $NPROC threads available" |
| 45 | + echo "NPROC=$NPROC" >> $GITHUB_ENV |
| 46 | + echo "nproc=$NPROC" >> $GITHUB_OUTPUT |
| 47 | + echo "::endgroup::" |
| 48 | +
|
| 49 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 50 | + DIR_SEP="\\" |
| 51 | + else |
| 52 | + DIR_SEP="/" |
| 53 | + fi |
| 54 | + echo "DIR_SEP=$DIR_SEP" >> $GITHUB_ENV |
| 55 | +
|
| 56 | + begin_group "Install system dependencies such as ninja and ccache" |
| 57 | + export CCACHE_DIR="${{ github.workspace }}${DIR_SEP}.ccache" |
| 58 | + echo "CCACHE_DIR=$CCACHE_DIR" |
| 59 | + echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV |
| 60 | + echo "ccache-dir=$CCACHE_DIR" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 63 | + echo "FC=gfortran-13" >> $GITHUB_ENV |
| 64 | + sudo apt-get -qq update |
| 65 | + sudo apt-get -qq install -y libxkbcommon-x11-0 xorg-dev libgl1-mesa-dev ccache |
| 66 | +
|
| 67 | + COMPILER="gcc-$(gcc -dumpversion)" |
| 68 | + elif [ "$RUNNER_OS" == "Windows" ]; then |
| 69 | + choco install ninja ccache |
| 70 | +
|
| 71 | + # C:\Program Files\Microsoft Visual Studio\2022\Enterprise |
| 72 | + MSVC_DIR=$(vswhere -products '*' -requires Microsoft.Component.MSBuild -latest -property installationPath) |
| 73 | + echo "Latest MSVC_DIR is: $MSVC_DIR" |
| 74 | + echo "MSVC_DIR=$MSVC_DIR" >> $GITHUB_ENV |
| 75 | + # add folder containing vcvarsall.bat |
| 76 | + echo "$MSVC_DIR\VC\Auxiliary\Build" >> $GITHUB_PATH |
| 77 | + # msvc-17.14 |
| 78 | + # COMPILER="msvc-$(vswhere -products '*' -requires Microsoft.Component.MSBuild -latest -property installationVersion | cut -d'.' -f 1,2)" |
| 79 | + # msvc-2022 |
| 80 | + COMPILER="msvc-$(vswhere -products '*' -requires Microsoft.Component.MSBuild -latest -property catalog_productLineVersion)" |
| 81 | + elif [ "$RUNNER_OS" == "macOS" ]; then |
| 82 | + brew update |
| 83 | + brew install tcl-tk |
| 84 | + brew reinstall gcc@13 |
| 85 | + echo "FC=$(brew --prefix gcc@13)/bin/gfortran-13" >> $GITHUB_ENV |
| 86 | + echo "MACOSX_DEPLOYMENT_TARGET=${{ matrix.macos_dev_target }}" >> $GITHUB_ENV |
| 87 | +
|
| 88 | + brew install ccache |
| 89 | + ccache --set-config=compiler_check=content # darwin only |
| 90 | + # clang-19 |
| 91 | + COMPILER="clang-$(clang -dumpversion | cut -d'.' -f 1)" |
| 92 | + fi; |
| 93 | + echo "::endgroup::" |
| 94 | +
|
| 95 | + begin_group "compiler ID" |
| 96 | + echo "compiler-id=$COMPILER" |
| 97 | + echo "COMPILER=$COMPILER" >> $GITHUB_ENV |
| 98 | + echo "compiler-id=$COMPILER" >> $GITHUB_OUTPUT |
| 99 | + echo "::endgroup::" |
| 100 | +
|
| 101 | + # Setup ccache, common |
| 102 | + begin_group "Configure CCache" |
| 103 | + ccache --set-config=cache_dir=$CCACHE_DIR |
| 104 | + ccache --set-config=max_size=500M |
| 105 | + ccache --set-config=compression=true |
| 106 | + ccache --set-config=sloppiness=pch_defines,time_macros |
| 107 | + ccache --set-config=base_dir="${{ github.workspace }}" |
| 108 | + ccache -p |
| 109 | + echo "::endgroup::" |
| 110 | +
|
| 111 | + begin_group "App Python_ROOT_DIR env variable" |
| 112 | + Python_ROOT_DIR="$RUNNER_TOOL_CACHE/Python/${{ steps.setup-python.outputs.python-version }}/${{ inputs.python-arch }}" |
| 113 | + echo "Python_ROOT_DIR=$Python_ROOT_DIR" >> $GITHUB_ENV |
| 114 | + echo "python-root-dir=$Python_ROOT_DIR" >> $GITHUB_OUTPUT |
| 115 | + echo "::endgroup::" |
| 116 | +
|
| 117 | + begin_group "Install python dependencies" |
| 118 | + pip install pytest lxml tzdata |
| 119 | + echo "::endgroup::" |
0 commit comments