tools/corrosion/.github/workflows/test.yaml
branchtransitional_engine
changeset 16067 d903f8d2395a
parent 16050 6a3dc15b78b9
--- a/tools/corrosion/.github/workflows/test.yaml	Wed Sep 18 14:10:51 2024 +0200
+++ b/tools/corrosion/.github/workflows/test.yaml	Wed Nov 20 21:37:47 2024 +0100
@@ -9,225 +9,304 @@
       - 'stable/**'
 jobs:
 
-  test_legacy_linux:
-    name: Test Corrosion (CMake 3.15)
-    uses: ./.github/workflows/test_legacy.yaml
-    with :
-      os: ubuntu-20.04
-      rust: 1.46.0
-  test_legacy_mac:
-    name: Test Corrosion (CMake 3.15)
-    uses: ./.github/workflows/test_legacy.yaml
+  visual_studio_base:
+    name: Test Visual Studio (base)
+    uses: ./.github/workflows/visual_studio.yaml
     with:
-      os: macos-12
-      rust: 1.54.0
-  test_legacy_windows:
-    name: Test Corrosion (CMake 3.15)
-    uses: ./.github/workflows/test_legacy.yaml
-    with:
-      os: windows-2019
+      vs_version: "2022"
       rust: 1.46.0
 
-  test_legacy_stable:
-    name: Legacy CMake + stable Rust
-    uses: ./.github/workflows/test_legacy.yaml
+  visual_studio_stage2:
+    name: Test Visual Studio
+    uses: ./.github/workflows/visual_studio.yaml
+    needs:
+      - visual_studio_base
+    strategy:
+      matrix:
+        vs_version:
+          - "2019"
+          - "2022"
+        arch:
+          - x86_64
+          - i686
+          - aarch64
+        rust:
+          - "1.54.0"
+        include:
+          - arch: x86_64
+            vs_version: 2022
+            rust: stable
+          - arch: x86_64
+            vs_version: 2022
+            rust: nightly
+    with:
+      vs_version: "${{ matrix.vs_version}}"
+      rust: 1.54.0
+      target_arch: "${{ matrix.arch}}"
+
+  windows_ninja_cl:
+    name: Test Windows Ninja MSVC
+    runs-on: ${{ matrix.os }}
+    needs:
+      - visual_studio_base
     strategy:
       fail-fast: false
       matrix:
         os:
-          - windows-2019 # windows-latest is currently not having a supported MSVC compiler
-          - ubuntu-20.04
-          - macos-12
-    with:
-      os: ${{ matrix.os }}
-      rust: stable
-
-  test_legacy_nightly:
-    name: Legacy CMake + nightly Rust
-    uses: ./.github/workflows/test_legacy.yaml
-    with:
-      os: ubuntu-20.04
-      rust: nightly
-
-  test_legacy_new_lockfile_msrv:
-    name: Test MSRV of the new lockfile
-    runs-on: ubuntu-20.04
-    steps:
-      - uses: actions/checkout@v4
-      - name: Install Rust
-        id: install_rust
-        uses: dtolnay/rust-toolchain@1.56
-      - name: Test Generator build with MSRV
-        run: cargo build
-        working-directory: generator
-
-  test:
-    name: Test Corrosion
-    runs-on: ${{ matrix.os }}
-    continue-on-error: ${{ matrix.rust == 'nightly' }}
-    strategy:
-      fail-fast: false
-      matrix:
-        os:
-          - windows-2019 # windows-latest is currently not having a supported MSVC compiler
-          - ubuntu-latest
-          - macos-12
+          - windows-2022
         arch:
           - x86_64
           - i686
           - aarch64
-          - powerpc64le
-        abi:
-          - gnu
-          - darwin
-          - msvc
-        cmake:
-          - 3.19.0
-        rust:
-          # Our MSRV is already tested with the legacy generator, so just test the current stable rust here.
-          - stable
-        generator:
-          - default # This is just whatever the platform default is
-          - ninja
-        compiler: [default]
+        compiler:
+          - cl
+          - clang-cl
+          - clang
         include:
-          - rust: nightly
-            cmake: 3.19.0
-            generator: ninja
-            arch: x86_64
-            abi: msvc
-            os: windows-2019
-          - rust: nightly
-            cmake: 3.19.0
-            generator: ninja
-            arch: x86_64
-            abi: gnu
-            os: ubuntu-latest
-          - rust: nightly
-            cmake: 3.19.0
-            generator: ninja
-            arch: x86_64
-            abi: darwin
-            os: macos-12
-          - rust: 1.54
-            cmake: 3.19.0
-            generator: ninja
-            arch: x86_64
-            abi: msvc
-            os: windows-2019
-            compiler: clang
-          - os: ubuntu-latest
-            arch: x86_64
-            abi: gnu
-            cmake: 3.20.0
-            rust: 1.54
-            generator: ninja-multiconfig
-
+          - os: windows-2022
+            vs_version: vs-2022
+            cmake: 3.22.6
+          - rust: 1.54.0
+          # Add variable mapping for ilammy/msvc-dev-cmd action
+          - arch: x86_64
+            msvc_dev_arch: amd64
+          - arch: i686
+            msvc_dev_arch: amd64_x86
+          - arch: aarch64
+            msvc_dev_arch: amd64_arm64
         exclude:
-
-          # We have a separate test Matrix for the Visual Studio Generator
-          - os: windows-2019
-            generator: default # Default generator is Visual Studio
-
-          # ARCH
-          - os: windows-2019
+          # Not sure what parameters CMake needs when cross-compiling with clang-cl, so exclude for now
+          - compiler: clang-cl
             arch: i686
-            abi: gnu
-          - os: windows-2019
-            arch: aarch64
-            abi: gnu
-          - os: windows-2019
-            arch: i686
-            generator: ninja
-          - os: windows-2019
+          - compiler: clang-cl
             arch: aarch64
-            generator: ninja
-          - os: windows-2019
-            arch: powerpc64le
-          - os: macos-12
+          - compiler: clang
             arch: i686
-          - os: macos-12
+          - compiler: clang
             arch: aarch64
-          - os: macos-12
-            arch: powerpc64le
-
-          # ABI
-          - os: ubuntu-latest
-            abi: msvc
-          - os: ubuntu-latest
-            abi: darwin
-          - os: windows-2019
-            abi: darwin
-          - os: macos-12
-            abi: msvc
-          - os: macos-12
-            abi: gnu
 
     steps:
       - uses: actions/checkout@v4
-      - name: Setup Environment and Configure CMake
-        uses: "./.github/actions/setup_test"
+      - name: Install CMake
+        uses: lukka/get-cmake@519de0c7b4812477d74976b2523a9417f552d126
+        with:
+          cmakeVersion: "${{ matrix.cmake }}"
+          ninjaVersion: "~1.10.0"
+      - name: Install Rust
+        id: install_rust
+        uses: dtolnay/rust-toolchain@master
         with:
-          target_arch: ${{matrix.arch}}
-          abi: ${{matrix.abi}}
-          cmake: ${{matrix.cmake}}
-          rust: ${{matrix.rust}}
-          generator: ${{matrix.generator}}
-          build_dir: build
-          compiler: ${{matrix.compiler}}
+          toolchain: ${{matrix.rust}}
+          targets: ${{matrix.arch}}-pc-windows-msvc
+      - name: Setup MSVC Development Environment
+        uses: ilammy/msvc-dev-cmd@v1
+        with:
+          arch: ${{ matrix.msvc_dev_arch }}
+      - name: Configure
+        run: cmake -S. -Bbuild "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "ninja-${{ matrix.arch }}-pc-windows-msvc-${{ matrix.compiler }}"
       - name: Run Tests
-        id: run_tests
         working-directory: build
         run: ctest --output-on-failure --build-config Debug -j 3
 
-  test_msvc:
-    name: Test MSVC Generator
+  windows_gnu:
+    name: Test Windows GNU
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        os:
+          - windows-2022
+        arch:
+          - x86_64
+          # - i686
+          # - aarch64
+        compiler:
+          - gcc # Clang only has experimental support for Cygwin / MinGW, so we don't test it
+        generator:
+          - ninja
+          - make
+        include:
+          - cmake: 3.22.6
+          - rust: 1.54.0
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Install CMake
+        uses: lukka/get-cmake@519de0c7b4812477d74976b2523a9417f552d126
+        with:
+          cmakeVersion: "${{ matrix.cmake }}"
+          ninjaVersion: "~1.10.0"
+      - name: Install Rust
+        id: install_rust
+        uses: dtolnay/rust-toolchain@master
+        with:
+          toolchain: ${{matrix.rust}}
+          targets: ${{matrix.arch}}-pc-windows-gnu
+      - name: Configure
+        run: cmake -S. -Bbuild "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "${{ matrix.generator }}-${{ matrix.arch }}-pc-windows-gnu-${{ matrix.compiler }}"
+      - name: Run Tests
+        working-directory: build
+        run: ctest --output-on-failure --build-config Debug -j 3
+
+  windows_gnullvm_msys2:
+    name: Test Windows gnullvm on msys2
     runs-on: ${{ matrix.os }}
     strategy:
       fail-fast: false
       matrix:
         os:
-          - windows-2019
           - windows-2022
         arch:
           - x86_64
+          # - i686
+          # - aarch64
+        generator:
+          - Ninja
+          - MSYS Makefiles
+        include:
+          - arch: x86_64
+            msystem: CLANG64
+#          - arch: i686
+#            msystem: CLANG32
+#          - arch: aarch64
+#            msystem: CLANGARM64
+    defaults:
+      run:
+        shell: msys2 {0}
+    steps:
+      - uses: actions/checkout@v4
+      - name: Install Rust
+        id: install_rust
+        uses: dtolnay/rust-toolchain@master
+        with:
+          toolchain: stable
+          targets: ${{matrix.arch}}-pc-windows-gnullvm
+      - uses: msys2/setup-msys2@v2
+        with:
+          msystem: ${{matrix.msystem}}
+          path-type: inherit
+          install: >-
+            git
+            make
+          pacboy: >-
+            toolchain:p
+            cmake:p
+            ninja:p
+      - name: Configure
+        run: cmake -S. -Bbuild -G "${{matrix.generator}}" --toolchain=.github/scripts/toolchains/${{matrix.arch}}-pc-windows-gnullvm.cmake
+      - name: Run Tests
+        working-directory: build
+        run: ctest --output-on-failure --build-config Debug -j 3
+
+# For now just test if hostbuild works when cross-compiling on windows.
+# For testing everything we would also need to install a cross-compiler first.
+  windows_cross_hostbuild:
+    name: Test Windows Cross
+    runs-on: windows-2022
+    steps:
+      - uses: actions/checkout@v4
+      - name: Install CMake
+        uses: lukka/get-cmake@519de0c7b4812477d74976b2523a9417f552d126
+        with:
+          cmakeVersion: "~3.22.0"
+          ninjaVersion: "~1.10.0"
+      - name: Install Rust
+        id: install_rust
+        uses: dtolnay/rust-toolchain@master
+        with:
+          toolchain: stable
+          targets: aarch64-unknown-linux-gnu
+      - name: Configure
+        run: cmake -S. -Bbuild "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" -DRust_CARGO_TARGET=aarch64-unknown-linux-gnu
+      - name: Run Tests
+        working-directory: build
+        run: ctest --output-on-failure --build-config Debug -R hostbuild
+
+  linux_base:
+    name: Test Linux (base)
+    uses: ./.github/workflows/linux.yaml
+    with:
+      c_compiler: "gcc"
+      generator: "Ninja"
+
+  linux_stage2:
+    name: Test Linux
+    needs:
+      - linux_base
+    uses: ./.github/workflows/linux.yaml
+    with:
+      target_arch: "${{ matrix.arch }}"
+      c_compiler: "${{ matrix.compiler }}"
+      generator: "${{ matrix.generator }}"
+    strategy:
+      fail-fast: false
+      matrix:
+        arch:
+          - x86_64
           - i686
           - aarch64
+        compiler:
+          - gcc
+        generator:
+          - "Ninja"
+          - "Unix Makefiles"
         include:
-          - rust: 1.54.0
-          # Override rust version for x86_64
+          # rustc doesn't support cross-compiling with clang out of the box, since
+          # clang requires a --target parameter. Corrosion currently can only pass
+          # this for the top-level crate, so linking of cdylibs that are built as
+          # dependencies of this crate will fail if they exist.
+          # Solutions would be to make cross-compiling with clang work out-of-the-box
+          # in rustc, or working around it in corrosion by adding a linker-wrapper.
+          # For this reason we only test clang with the host target for now.
+          - arch: x86_64
+            compiler: clang
+            generator: "Ninja"
           - arch: x86_64
-            rust: 1.46.0
-          - os: windows-2019
-            cmake: 3.20.6  # Multi-config Generators require at least CMake 3.20
-          - os: windows-2022
-            cmake: 3.21.5 # VS on windows-2022 requires at least CMake 3.21
+            generator: "Ninja Multi-Config"
+            compiler: gcc
+
+  darwin:
+    name: Test MacOS
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        arch:
+          - x86_64
+          - aarch64
+        compiler:
+          - clang
+        generator:
+          - "Ninja"
+          - "Xcode"
+        include:
+          - os: macos-latest
+          - cmake: 3.22.6
+          - rust: 1.54.0
 
     steps:
       - uses: actions/checkout@v4
-      # The initial configure for MSVC is quite slow, so we cache the build directory
-      # (including the build directories of the tests) since reconfiguring is
-      # significantly faster.
-      - name: Cache MSVC build directory
-        id: cache-msvc-builddir
-        uses: actions/cache@v4
+      - name: Install CMake
+        uses: lukka/get-cmake@519de0c7b4812477d74976b2523a9417f552d126
         with:
-          path: build
-          key: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.rust }}-msvc-build
-      - name: Setup Environment and Configure CMake
-        uses: "./.github/actions/setup_test"
+          cmakeVersion: "${{ matrix.cmake }}"
+          ninjaVersion: "~1.10.0"
+      # Install cbindgen before Rust to use recent default Rust version.
+      - name: Install cbindgen
+        run: cargo install cbindgen
+      - name: Install Rust
+        id: install_rust
+        uses: dtolnay/rust-toolchain@master
         with:
-          target_arch: ${{matrix.arch}}
-          abi: msvc
-          cmake: ${{matrix.cmake}}
-          rust: ${{matrix.rust}}
-          generator: default
-          build_dir: build
-          configure_params: "-DCORROSION_TESTS_KEEP_BUILDDIRS=ON"
+          toolchain: ${{matrix.rust}}
+          targets: ${{matrix.arch}}-apple-darwin
+      - name: Configure
+        run: cmake -S. -Bbuild --log-level=DEBUG -G "${{ matrix.generator }}" "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "${{ matrix.arch }}-apple-darwin-${{ matrix.compiler }}"
       - name: Run Tests
         working-directory: build
         run: ctest --output-on-failure --build-config Debug -j 3
 
+
   test_cxxbridge:
     name: Test cxxbridge integration
     runs-on: ${{ matrix.os }}
@@ -235,39 +314,74 @@
       fail-fast: false
       matrix:
         os:
-          - windows-2019
+          - windows-2022
           - ubuntu-latest
-          - macos-12
+          - macos-13
         include:
-          - abi: default
-        #  - os: windows-2019
-        #    abi: gnu
+          # Should be in sync with the `cxx` version the Carg.lock of the cxxbridge tests,
+          # otherwise the caching will not work and the cmd will be built from source.
+          - cxxbridge_version: "1.0.86"
     steps:
       - uses: actions/checkout@v4
       - uses: actions/cache@v4
         id: cache_cxxbridge
         with:
           path: "~/.cargo/bin/cxxbridge*"
-          key: ${{ runner.os }}-cxxbridge_1_0_86
+          key: ${{ runner.os }}-cxxbridge_${{ matrix.cxxbridge_version }}
       - name: Install cxxbridge
         if: steps.cache_cxxbridge.outputs.cache-hit != 'true'
-        run: cargo install cxxbridge-cmd@1.0.86
+        run: cargo install cxxbridge-cmd@${{ matrix.cxxbridge_version }}
       - name: Install lld
         run: sudo apt update && sudo apt install -y lld
         if: ${{ 'Linux' == runner.os }}
-      - name: Setup Environment and Configure CMake
-        uses: "./.github/actions/setup_test"
+      - name: Setup MSVC Development Environment
+        uses: ilammy/msvc-dev-cmd@v1
+        if: runner.os == 'Windows'
+      - name: Install CMake
+        uses: lukka/get-cmake@519de0c7b4812477d74976b2523a9417f552d126
         with:
-          target_arch: x86_64
-          cmake: 3.15.7
-          rust: stable minus 2 releases
-          abi: ${{ matrix.abi }}
-          generator: ninja
-          build_dir: build
-          configure_params: -DCORROSION_TESTS_CXXBRIDGE=ON
+          cmakeVersion: "~3.22.0"
+          ninjaVersion: "~1.10.0"
+      - name: Install Rust
+        uses: dtolnay/rust-toolchain@master
+        with:
+          toolchain: stable minus 2 releases
+      - name: Configure
+        run: >
+          cmake
+          -S.
+          -Bbuild
+          -GNinja
+          -DCORROSION_VERBOSE_OUTPUT=ON
+          -DCORROSION_TESTS_CXXBRIDGE=ON
       - name: Run Tests
         working-directory: build
         run: ctest --output-on-failure --build-config Debug -j 3 -R "^cxxbridge"
+
+  autoinstall_cargo_target:
+    name: Test Auto-installing Cargo target via rustup
+    runs-on: ubuntu-22.04
+    steps:
+      - uses: actions/checkout@v4
+      - name: Install CMake
+        uses: lukka/get-cmake@519de0c7b4812477d74976b2523a9417f552d126
+      - name: Install Rust
+        id: install_rust
+        uses: dtolnay/rust-toolchain@stable
+      - name: Install Cross Compiler
+        shell: bash
+        run: |
+          echo "::group::apt-install"
+          sudo apt-get update
+          sudo apt-get install -y gcc-aarch64-linux-gnu
+          echo "::endgroup::"
+      - name: Assert rustup target is not installed
+        run: rustup show | ( ! grep aarch64)
+      - name: Configure Corrosion
+        run: cmake -S. -Bbuild -GNinja -DRust_RUSTUP_INSTALL_MISSING_TARGET=ON --preset "aarch64-unknown-linux-gnu-gcc"
+      - name: Check rustup target is installed after configuring
+        run: rustup show | grep aarch64
+
   install:
     name: Test Corrosion as a Library
     runs-on: ${{ matrix.os }}
@@ -275,13 +389,12 @@
       fail-fast: false
       matrix:
         os:
-          - windows-2019
+          - windows-2022
           - ubuntu-latest
-          - macos-12
+          - macos-13
         include:
-          - rust: 1.46.0
-          - os: macos-12
-            rust: 1.54.0  # On MacOS-12 linking fails before Rust 1.54
+          - rust: 1.54.0
+
     steps:
       - uses: actions/checkout@v4
       - name: Setup MSVC Development Environment
@@ -290,32 +403,17 @@
       - name: Install CMake
         uses: lukka/get-cmake@519de0c7b4812477d74976b2523a9417f552d126
         with:
-          cmakeVersion: "~3.18.0"
+          cmakeVersion: "~3.22.0"
           ninjaVersion: "~1.10.0"
+      # Install cbindgen before Rust to use recent default Rust version.
+      - name: Install cbindgen
+        run: cargo install cbindgen
       - name: Install Rust
         uses: dtolnay/rust-toolchain@master
         with:
           toolchain: ${{matrix.rust}}
-      - name: CMake Version
-        run: cmake --version
-      - name: Rust Version
-        run: rustc --version
-      - name: Test Corrosion as subdirectory
-        run: >
-          cmake
-          -S.
-          -Bbuild
-          -GNinja
-          -DCORROSION_VERBOSE_OUTPUT=ON
-          -DCORROSION_TESTS_INSTALL_CORROSION=OFF
-          &&
-          cd build
-          &&
-          ctest --output-on-failure -C Debug -j 3
       - name: Test Corrosion as installed module
         run: >
-          cmake -E remove_directory build
-          &&
           cmake
           -S.
           -Bbuild
@@ -327,21 +425,21 @@
           cd build
           &&
           ctest --output-on-failure -C Release -j 3
-  # We need some "accumulation" job here because bors fails (timeouts) to
-  # listen on matrix builds.
-  # Hence, we have some kind of dummy here that bors can listen on
+
+  # We want an "accumulation" job here because it is easier to specify required
+  # jobs here via needs, then in the github UI, since we use matrix jobs.
   ci-success:
     name: bors-ci-status
     if: ${{ always() }}
     needs:
-      - test_legacy_linux
-      - test_legacy_mac
-      - test_legacy_windows
-      - test_legacy_stable
-      - test_legacy_new_lockfile_msrv
-      - test
-      - test_msvc
+      - visual_studio_stage2
+      - windows_ninja_cl
+      - windows_gnu
+      - windows_gnullvm_msys2
+      - linux_stage2
+      - darwin
       - test_cxxbridge
+      - autoinstall_cargo_target
       - install
     runs-on: ubuntu-latest
     # Step copied from: https://github.com/cross-rs/cross/blob/80c9f9109a719ffb0f694060ddc6e371d5b3a540/.github/workflows/ci.yml#L361