Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-platform CI #64

Open
zicklag opened this issue May 17, 2021 · 4 comments
Open

Multi-platform CI #64

zicklag opened this issue May 17, 2021 · 4 comments
Assignees

Comments

@zicklag
Copy link
Contributor

zicklag commented May 17, 2021

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
@PsichiX
Copy link
Collaborator

PsichiX commented May 20, 2021

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

@PsichiX PsichiX self-assigned this May 20, 2021
@zicklag
Copy link
Contributor Author

zicklag commented May 20, 2021

Cool, let me know if you have any questions. 👍

@zicklag
Copy link
Contributor Author

zicklag commented May 20, 2021

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! 😲 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

@PsichiX
Copy link
Collaborator

PsichiX commented Oct 26, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants