Leafwing-Studios / template-repo

A quick, CI-enabled Bevy template repository.
Apache License 2.0
43 stars 9 forks source link

Run examples in CI #26

Open alice-i-cecile opened 2 years ago

alice-i-cecile commented 2 years ago

Initial attempts were not satisfactory. #29 is particularly challenging, but we also need an example-agnostic way to kill examples that are taking too long.

Draft workflow:


  run-examples:
    runs-on: ubuntu-latest
    steps:
      - name: Install Bevy dependencies
        run: |
          sudo apt-get update;
          DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \
            libasound2-dev libudev-dev;
      - uses: actions/checkout@v2
      - uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: runner.os−cargo−run−examples−{{ hashFiles('**/Cargo.toml') }}
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
      - name: Build project
        run: |
          cargo +nightly build
      - name: Run examples
        run: |
          for example_name in example/*.rs; do
            cargo +nightly run −−example $(basename $example_name .rs)"
            sleep 3
          done
alice-i-cecile commented 2 years ago

https://www.baeldung.com/linux/bash-kill-child-process-after-timeout may be useful.