|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Test Suite |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + - name: Install Rust toolchain |
| 17 | + uses: dtolnay/rust-toolchain@stable |
| 18 | + with: |
| 19 | + components: rustfmt |
| 20 | + - name: Install system dependencies |
| 21 | + run: | |
| 22 | + sudo apt-get update |
| 23 | + sudo apt-get install -y \ |
| 24 | + dbus \ |
| 25 | + dbus-x11 \ |
| 26 | + python3 \ |
| 27 | + python3-dbus \ |
| 28 | + python3-gi \ |
| 29 | + python3-gi-cairo \ |
| 30 | + gir1.2-glib-2.0 \ |
| 31 | + systemd \ |
| 32 | + libdbus-1-dev \ |
| 33 | + pkg-config |
| 34 | + - name: Cache cargo dependencies |
| 35 | + uses: actions/cache@v4 |
| 36 | + with: |
| 37 | + path: | |
| 38 | + ~/.cargo/registry |
| 39 | + ~/.cargo/git |
| 40 | + target |
| 41 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 42 | + restore-keys: | |
| 43 | + ${{ runner.os }}-cargo- |
| 44 | + - name: Check code formatting |
| 45 | + run: cargo fmt -- --check |
| 46 | + - name: Start D-Bus session for tests |
| 47 | + run: | |
| 48 | + # Start D-Bus daemon for testing |
| 49 | + export DBUS_SESSION_BUS_ADDRESS=$(dbus-daemon --session --print-address --fork) |
| 50 | + echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> $GITHUB_ENV |
| 51 | + # Give D-Bus time to start |
| 52 | + sleep 2 |
| 53 | + # Verify D-Bus is working |
| 54 | + echo "Testing D-Bus connection..." |
| 55 | + dbus-send --session --dest=org.freedesktop.DBus --type=method_call \ |
| 56 | + --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames > /dev/null |
| 57 | + echo "D-Bus session ready" |
| 58 | + - name: Run unit tests |
| 59 | + env: |
| 60 | + RUST_BACKTRACE: 1 |
| 61 | + run: | |
| 62 | + echo "Running all tests..." |
| 63 | + cargo test --verbose |
| 64 | + - name: Run integration tests with output |
| 65 | + env: |
| 66 | + RUST_BACKTRACE: 1 |
| 67 | + run: | |
| 68 | + echo "Running integration tests with detailed output..." |
| 69 | + cargo test --test integration_tests -- --nocapture |
| 70 | + - name: Test mock script standalone |
| 71 | + run: | |
| 72 | + echo "Testing mock media player script..." |
| 73 | + timeout 3s python3 tests/mock_media_player.py || true |
| 74 | + echo "Mock script test completed" |
| 75 | + - name: Build release binary |
| 76 | + run: | |
| 77 | + echo "Building release version..." |
| 78 | + cargo build --release |
| 79 | + ls -la target/release/ |
| 80 | + - name: Upload test artifacts on failure |
| 81 | + if: failure() |
| 82 | + uses: actions/upload-artifact@v4 |
| 83 | + with: |
| 84 | + name: test-logs-${{ github.run_number }} |
| 85 | + path: | |
| 86 | + target/debug/deps/ |
| 87 | + retention-days: 5 |
| 88 | + |
| 89 | + security: |
| 90 | + name: Security Audit |
| 91 | + runs-on: ubuntu-latest |
| 92 | + steps: |
| 93 | + - name: Checkout code |
| 94 | + uses: actions/checkout@v4 |
| 95 | + - name: Install Rust toolchain |
| 96 | + uses: dtolnay/rust-toolchain@stable |
| 97 | + - name: Install cargo-audit |
| 98 | + run: cargo install cargo-audit |
| 99 | + - name: Run security audit |
| 100 | + run: cargo audit |
| 101 | + |
| 102 | + coverage: |
| 103 | + name: Code Coverage |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + - name: Checkout code |
| 107 | + uses: actions/checkout@v4 |
| 108 | + - name: Install Rust toolchain |
| 109 | + uses: dtolnay/rust-toolchain@stable |
| 110 | + with: |
| 111 | + components: llvm-tools-preview |
| 112 | + - name: Install system dependencies |
| 113 | + run: | |
| 114 | + sudo apt-get update |
| 115 | + sudo apt-get install -y \ |
| 116 | + dbus \ |
| 117 | + dbus-x11 \ |
| 118 | + python3-dbus \ |
| 119 | + python3-gi \ |
| 120 | + libdbus-1-dev \ |
| 121 | + pkg-config |
| 122 | + - name: Install cargo-llvm-cov |
| 123 | + run: cargo install cargo-llvm-cov |
| 124 | + - name: Start D-Bus session for coverage |
| 125 | + run: | |
| 126 | + export DBUS_SESSION_BUS_ADDRESS=$(dbus-daemon --session --print-address --fork) |
| 127 | + echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> $GITHUB_ENV |
| 128 | + sleep 2 |
| 129 | + - name: Generate code coverage |
| 130 | + run: | |
| 131 | + cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info |
| 132 | + - name: Upload coverage to Codecov |
| 133 | + uses: codecov/codecov-action@v4 |
| 134 | + with: |
| 135 | + files: lcov.info |
| 136 | + fail_ci_if_error: false |
| 137 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments