|
| 1 | +# Based on https://github.com/bevyengine/bevy_github_ci_template/blob/68e3d4d606b0faa6c462fdfb2f570c9a139efc8d/.github/workflows/ci.yaml |
| 2 | + |
| 3 | +name: CI |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +jobs: |
| 13 | + # Check which patterns changed |
| 14 | + changed_files: |
| 15 | + name: Test Suite |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 30 |
| 18 | + outputs: |
| 19 | + all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }} |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + - name: Get changed files |
| 25 | + id: changed-files |
| 26 | + uses: tj-actions/changed-files@v40 |
| 27 | + with: |
| 28 | + files: patterns/**.rs |
| 29 | + - name: Filter pattern names |
| 30 | + id: changed-patterns |
| 31 | + env: |
| 32 | + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} |
| 33 | + run: | |
| 34 | + PATTERNS=$( |
| 35 | + for file in "$ALL_CHANGED_FILES"; do |
| 36 | + echo "$file" | awk -F / '{print $2}' |
| 37 | + done |
| 38 | + ) |
| 39 | + echo "all_changed_files=$PATTERNS" | sort -u >> "$GITHUB_OUTPUT" |
| 40 | + - name: Filter pattern names |
| 41 | + env: |
| 42 | + ALL_CHANGED_FILES: ${{ steps.changed-patterns.outputs.all_changed_files }} |
| 43 | + run: echo "$ALL_CHANGED_FILES" |
| 44 | + |
| 45 | + |
| 46 | + # Run cargo clippy -- -D warnings |
| 47 | + clippy_check: |
| 48 | + name: Clippy |
| 49 | + if: needs.changed_files.outputs.all_changed_files != '' |
| 50 | + runs-on: ubuntu-latest |
| 51 | + timeout-minutes: 30 |
| 52 | + steps: |
| 53 | + - name: Checkout sources |
| 54 | + uses: actions/checkout@v4 |
| 55 | + - name: Cache |
| 56 | + uses: actions/cache@v3 |
| 57 | + with: |
| 58 | + path: | |
| 59 | + ~/.cargo/bin/ |
| 60 | + ~/.cargo/registry/index/ |
| 61 | + ~/.cargo/registry/cache/ |
| 62 | + ~/.cargo/git/db/ |
| 63 | + target/ |
| 64 | + key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }} |
| 65 | + - name: Install stable toolchain |
| 66 | + uses: dtolnay/rust-toolchain@stable |
| 67 | + with: |
| 68 | + components: clippy |
| 69 | + - name: Install Dependencies |
| 70 | + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev |
| 71 | + - name: Run clippy |
| 72 | + run: cargo clippy -- -D warnings |
| 73 | + |
| 74 | + # Run cargo fmt --all -- --check |
| 75 | + format: |
| 76 | + name: Format |
| 77 | + if: needs.changed_files.outputs.all_changed_files != "" |
| 78 | + runs-on: ubuntu-latest |
| 79 | + timeout-minutes: 30 |
| 80 | + steps: |
| 81 | + - name: Checkout sources |
| 82 | + uses: actions/checkout@v4 |
| 83 | + - name: Install stable toolchain |
| 84 | + uses: dtolnay/rust-toolchain@stable |
| 85 | + with: |
| 86 | + components: rustfmt |
| 87 | + - name: Run cargo fmt |
| 88 | + run: cargo fmt --all -- --check |
| 89 | + |
| 90 | + # Run cargo test |
| 91 | + test: |
| 92 | + name: Test Suite |
| 93 | + if: needs.changed_files.outputs.all_changed_files != "" |
| 94 | + runs-on: ubuntu-latest |
| 95 | + timeout-minutes: 30 |
| 96 | + steps: |
| 97 | + - name: Checkout sources |
| 98 | + uses: actions/checkout@v4 |
| 99 | + - name: Cache |
| 100 | + uses: actions/cache@v3 |
| 101 | + with: |
| 102 | + path: | |
| 103 | + ~/.cargo/bin/ |
| 104 | + ~/.cargo/registry/index/ |
| 105 | + ~/.cargo/registry/cache/ |
| 106 | + ~/.cargo/git/db/ |
| 107 | + target/ |
| 108 | + key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} |
| 109 | + - name: Install stable toolchain |
| 110 | + uses: dtolnay/rust-toolchain@stable |
| 111 | + - name: Install Dependencies |
| 112 | + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev |
| 113 | + - name: Run cargo test |
| 114 | + run: cargo test |
0 commit comments