raui icon indicating copy to clipboard operation
raui copied to clipboard

Multi-platform CI

Open zicklag opened this issue 4 years ago • 4 comments

The SDL2 issue on Windows still remains to be solved as far as I know, but I just setup CI for Bevy Retro and 98% of the workflow file that I used should be usable with RAUI. It sets up builds for rust nightly and stable for windows, macos, and linux. It's also got caching to speed up the builds, making non-Rust changes complete the full pipeline in less that 4 minutes!

I don't have time to make a PR out of it, but here it is for reference once you get to it.

name: Build & Test

on:
  push:
    branches: [ master, staging, trying ]
  pull_request:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Install alsa and udev
        run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
        if: runner.os == 'linux'

      - name: Cargo Cache
        uses: actions/cache@v2
        env:
          cache-name: cargo-cache
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git/db
            target
          key: ${{ env.cache-name }}-${{ runner.os }}-check-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ env.cache-name }}-${{ runner.os }}-check-
            ${{ env.cache-name }}-${{ runner.os }}-
            ${{ env.cache-name }}-

      - name: Check
        run: cargo check --workspace --all-features

  build-and-test-native:
    needs: check
    strategy:
      matrix:
        os: [ 'windows-latest', 'ubuntu-latest', 'macos-latest' ]
        toolchain: [ 'stable', 'nightly' ]
    continue-on-error: ${{ matrix.toolchain == 'nightly' }}
    env:
      # Override the Cargo.toml dev profile settings to optimize for build speed
      CARGO_PROFILE_DEV_DEBUG: 'true'
      CARGO_PROFILE_DEV_OPT_LEVEL: '0'

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v2

      - name: Install alsa and udev
        run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
        if: runner.os == 'linux'

      - name: Cargo Cache
        uses: actions/cache@v2
        env:
          cache-name: cargo-cache
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git/db
            target
          key: ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.toolchain }}-
            ${{ env.cache-name }}-${{ matrix.os }}-
            ${{ env.cache-name }}-

      - name: Rust Toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.toolchain }}
          override: true

      - name: Build
        run: cargo build --workspace --features ldtk --verbose

      - name: Test
        run: cargo test --workspace --features ldtk --verbose

  build-wasm:
    needs: check
    runs-on: ubuntu-latest
    env:
      # Override the Cargo.toml dev profile settings to optimize for build speed
      CARGO_PROFILE_DEV_DEBUG: 'true'
      CARGO_PROFILE_DEV_OPT_LEVEL: '0'
    steps:
      - uses: actions/checkout@v2

      - name: Cargo Cache
        uses: actions/cache@v2
        env:
          cache-name: cargo-cache
        with:
          path: |
            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ~/.cargo/git/db
            target
          key: ${{ env.cache-name }}-wasm-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ env.cache-name }}-${{ runner.os }}-wasm-
            ${{ env.cache-name }}-${{ runner.os }}-
            ${{ env.cache-name }}-

      - name: Rust Toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: wasm32-unknown-unknown
          override: true

      - name: Build
        run: cargo build --workspace --features ldtk --verbose --target wasm32-unknown-unknown

zicklag avatar May 17 '21 23:05 zicklag

gonna play with it tomorrow, first i'll have to get more familiar with more advanced parts of this snippet :D

PsichiX avatar May 20 '21 19:05 PsichiX

Cool, let me know if you have any questions. :+1:

zicklag avatar May 20 '21 19:05 zicklag

I'm feeling like the caching might not be helping CI necessarily because a couple of times the cache upload failed for some reason and also because they can be massive ( ~2-3GB somtimes ) and when you're building on so many platforms GitHub's 5GB cache limit doesn't last and it has to keep re-creating them. I think CI takes about 12 mins each run without the cache.

I'm still feeling it out, but you might want to leave the caching out for simplicity because it's up for debate right now whether or not it's helping.

Edit: Yeah, I'm disabling the cache of the target dir for my project. A cache upload just to 14 minutes! :astonished: That's not speeding it up at this point. I think I'll still keep the cache for the cargo registry, though. No need to download the crates over and over again.

Edit 2: Yep, turning of caching of the target/ dir and just leaving the caching of the cargo registry worked great and builds only take 9 minutes for all platforms:

image

You can see my up-to-date workflow file here: https://github.com/katharostech/bevy_retro/blob/master/.github/workflows/rust.yaml

zicklag avatar May 20 '21 23:05 zicklag

now since RAUI has new App module based on winit (completely replacing Tetra based QuickStart), i think we can have truly multiplatform CI, will have to test it in the near future

PsichiX avatar Oct 26 '23 21:10 PsichiX