jobs: # skip-all

  # This is ci/actions-templates/all-features-template.yaml
  # Do not edit this file in .github/workflows
  #
  # This is an additional workflow to test building with all feature combinations.
  # Unlike our main workflows, this doesn't self-test the rustup install scripts,
  # nor run on the rust docker images. This permits a smaller workflow without the
  # templating and so on.
  build-all-features: # job-name
    runs-on: ${{ matrix.os }}
    if: ${{ contains('["pull_request", "merge_group"]', github.event_name) }}
    strategy:
      fail-fast: false
      matrix:
        include:
          # Might add more targets in future.
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: windows-latest
            target: x86_64-pc-windows-msvc
    steps:
      - name: Clone repo
        uses: actions/checkout@v4
      - name: Install rustup stable
        run: rustup toolchain install stable --profile minimal
      - name: Install Protoc
        uses: arduino/setup-protoc@v1
        with:
          version: "3.x"
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Install OpenSSL
        if: ${{ contains(matrix.os, 'windows') }}
        run: |
          Get-Command openssl
          openssl version
          echo "OPENSSL_LIB_DIR=C:/Program Files/OpenSSL/lib" >> $env:GITHUB_ENV
          echo "OPENSSL_DIR=C:/Program Files/OpenSSL/" >> $env:GITHUB_ENV
          echo "OPENSSL_INCLUDE_DIR=C:/Program Files/OpenSSL/include" >> $env:GITHUB_ENV
      - name: Install NASM
        # Building `aws-lc-rs` for Windows MSVC depends on `NASM`.
        # See: https://aws.github.io/aws-lc-rs/requirements/windows.html
        uses: ilammy/setup-nasm@v1
        if: ${{ contains(matrix.os, 'windows') }}
      - name: Set environment variables appropriately for the build
        shell: bash
        run: |
          echo "$HOME/.cargo/bin" >> $GITHUB_PATH
          echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV
      - name: Cache Cargo
        uses: Swatinem/rust-cache@v2
      - name: Install cargo-all-features
        shell: bash
        run: which cargo-check-all-features || cargo install cargo-all-features --git https://github.com/rbtcollins/cargo-all-features.git
      - name: Ensure we have our goal target installed
        run: |
          rustup target install ${{ matrix.target }}
      - name: Build every combination
        env:
          RUSTFLAGS: -D warnings
        run: |
          cargo check-all-features --root-only
