Merge branch 'master' of github.com:mpusz/units #962
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The MIT License (MIT) | |
| # | |
| # Copyright (c) 2018 Mateusz Pusz | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in all | |
| # copies or substantial portions of the Software. | |
| # | |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| # SOFTWARE. | |
| name: Freestanding CI | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| paths-ignore: | |
| - "docs/**" | |
| pull_request: | |
| branches: | |
| - "**" | |
| paths-ignore: | |
| - "docs/**" | |
| workflow_dispatch: | |
| inputs: | |
| matrix-seed: | |
| description: The random seed for the subset of the full test-matrix to be run (set to '0' to select one at random) | |
| required: true | |
| type: number | |
| default: 0 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| generate-matrix: | |
| name: "Generate build matrix for ${{ github.workflow }}" | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| seed: ${{ steps.set-matrix.outputs.seed }} | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - id: set-matrix | |
| run: python .github/generate-job-matrix.py --preset freestanding --seed ${{ inputs.matrix-seed || 0 }} --debug combinations counts | |
| - name: Generate job summary | |
| if: always() | |
| env: | |
| MATRIX_JSON: ${{ steps.set-matrix.outputs.matrix }} | |
| MATRIX_SEED: ${{ steps.set-matrix.outputs.seed }} | |
| run: python .github/generate-matrix-summary.py >> $GITHUB_STEP_SUMMARY | |
| build: | |
| name: "${{ matrix.config-summary-str }}" | |
| runs-on: ${{ matrix.toolchain.os }} | |
| needs: generate-matrix | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{fromJson(needs.generate-matrix.outputs.matrix)}} | |
| env: | |
| CC: ${{ matrix.toolchain.compiler.cc }} | |
| CXX: ${{ matrix.toolchain.compiler.cxx }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - run: echo "cache_id=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_ENV | |
| - name: Cache Conan data | |
| uses: actions/cache@v5 | |
| if: always() | |
| env: | |
| cache-name: cache-conan-data | |
| with: | |
| path: ~/.conan2/p | |
| key: freestanding-${{ matrix.toolchain.os }}-${{ matrix.formatting }}-${{ matrix.contracts }}-${{ matrix.toolchain.compiler.type }}-${{ matrix.toolchain.lib }}-${{ matrix.build_type }}-${{ matrix.toolchain.compiler.version }}-${{ matrix.std }}-${{ env.cache_id }} | |
| restore-keys: | | |
| freestanding-${{ matrix.toolchain.os }}-${{ matrix.formatting }}-${{ matrix.contracts }}-${{ matrix.toolchain.compiler.type }}-${{ matrix.toolchain.lib }}-${{ matrix.build_type }}-${{ matrix.toolchain.compiler.version }}-${{ matrix.std }}- | |
| freestanding-${{ matrix.toolchain.os }}-${{ matrix.formatting }}-${{ matrix.contracts }}-${{ matrix.toolchain.compiler.type }}-${{ matrix.toolchain.lib }}-${{ matrix.build_type }}-${{ matrix.toolchain.compiler.version }}- | |
| freestanding-${{ matrix.toolchain.os }}-${{ matrix.formatting }}-${{ matrix.contracts }}-${{ matrix.toolchain.compiler.type }}-${{ matrix.toolchain.lib }}-${{ matrix.build_type }}- | |
| freestanding-${{ matrix.toolchain.os }}-${{ matrix.formatting }}-${{ matrix.contracts }}-${{ matrix.toolchain.compiler.type }}-${{ matrix.toolchain.lib }}- | |
| freestanding-${{ matrix.toolchain.os }}-${{ matrix.formatting }}-${{ matrix.contracts }}-${{ matrix.toolchain.compiler.type }}- | |
| freestanding-${{ matrix.toolchain.os }}-${{ matrix.formatting }}-${{ matrix.contracts }}- | |
| freestanding-${{ matrix.toolchain.os }}-${{ matrix.formatting }}- | |
| freestanding-${{ matrix.toolchain.os }}- | |
| - uses: hendrikmuhs/ccache-action@v1.2.22 | |
| if: runner.os == 'Linux' | |
| with: | |
| key: ${{ matrix.toolchain.os }}-${{ matrix.formatting }}-${{ matrix.contracts }}-${{ matrix.toolchain.compiler.type }}-${{ matrix.toolchain.lib }}-${{ matrix.build_type }}-${{ matrix.toolchain.compiler.version }}-${{ matrix.std }} | |
| max-size: 50M | |
| - name: Install gcc-${{ matrix.toolchain.compiler.version }} | |
| if: matrix.toolchain.compiler.type == 'GCC' | |
| shell: bash | |
| run: | | |
| if [[ "${{ matrix.toolchain.compiler.version }}" -ge 15 ]]; then | |
| sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test | |
| sudo apt update | |
| fi | |
| sudo apt install -y g++-${{ matrix.toolchain.compiler.version }} | |
| - name: Install Clang | |
| if: matrix.toolchain.compiler.type == 'CLANG' | |
| shell: bash | |
| working-directory: ${{ env.HOME }} | |
| run: | | |
| wget https://apt.llvm.org/llvm.sh | |
| chmod +x llvm.sh | |
| sudo ./llvm.sh ${{ matrix.toolchain.compiler.version }} | |
| sudo apt install -y clang-tools-${{ matrix.toolchain.compiler.version }} | |
| - name: Install Libc++ | |
| if: matrix.toolchain.compiler.type == 'CLANG' && matrix.toolchain.lib == 'libc++' | |
| shell: bash | |
| run: | | |
| sudo apt install -y libc++-${{ matrix.toolchain.compiler.version }}-dev libc++abi-${{ matrix.toolchain.compiler.version }}-dev libunwind-${{ matrix.toolchain.compiler.version }}-dev | |
| - name: Fix libc++ std.cppm path for CMake | |
| # CMake detects std.cppm relative to where libc++.so is linked | |
| # (/usr/lib/x86_64-linux-gnu/), producing a path like | |
| # /lib/x86_64-linux-gnu/../share/libc++/v1/std.cppm which resolves to | |
| # /lib/share/libc++/v1/std.cppm. On Ubuntu the actual file lives under | |
| # /usr/lib/llvm-N/share/libc++/v1/. Create the expected symlink so that | |
| # CMake's try_compile inner projects can find it. | |
| if: matrix.import_std == 'True' && matrix.toolchain.compiler.type == 'CLANG' | |
| shell: bash | |
| run: | | |
| sudo mkdir -p /lib/share | |
| sudo ln -sfn /usr/lib/llvm-${{ matrix.toolchain.compiler.version }}/share/libc++ /lib/share/libc++ | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - name: Install Ninja | |
| shell: bash | |
| run: | | |
| pip install -U ninja | |
| - name: Install Conan | |
| shell: bash | |
| run: | | |
| pip install -U conan | |
| - name: Configure Conan | |
| shell: bash | |
| run: | | |
| conan profile detect --force | |
| conan profile show -pr default | |
| - name: Install Conan dependencies | |
| shell: bash | |
| run: | | |
| conan install . -b missing ${{ matrix.conan-settings }} \ | |
| -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config" \ | |
| -c user.mp-units.build:all=True \ | |
| ${{ matrix.conan-args }} | |
| - name: Print tool versions | |
| shell: bash | |
| run: | | |
| source build/generators/conanbuild.sh | |
| ${CXX} --version | |
| cmake --version 2>&1 || true | |
| ninja --version 2>&1 || true | |
| conan --version | |
| python3 --version | |
| - name: Build freestanding | |
| shell: bash | |
| run: | | |
| conan build . -b missing ${{ matrix.conan-settings }} \ | |
| -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config" \ | |
| -c user.mp-units.build:all=True \ | |
| ${{ matrix.conan-args }} | |
| - name: Clean Conan cache before backup | |
| shell: bash | |
| run: | | |
| conan remove *#~latest --confirm | |
| conan remove *:*#~latest --confirm | |
| conan cache clean "*" -s -b -d | |
| - name: Generate freestanding summary | |
| if: failure() | |
| shell: bash | |
| env: | |
| CONAN_SETTINGS: ${{ matrix.conan-settings }} | |
| CONAN_ARGS: ${{ matrix.conan-args }} | |
| run: | | |
| echo "## ❌ Freestanding Build Failed: ${{ matrix.config-summary-str }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Local repro** (in the provided '.devcontainer' or GitHub CodeSpaces environment):" >> $GITHUB_STEP_SUMMARY | |
| echo '```sh' >> $GITHUB_STEP_SUMMARY | |
| echo "conan build . -b missing ${CONAN_SETTINGS} -c user.mp-units.build:all=True ${CONAN_ARGS}" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY |