ci.yml
1 # # AlphaOS Continuous Integration 2 # 3 # REPO_ACCESS_TOKEN secret required for cross-repo checkout 4 # 5 # Runs on: 6 # - Push to main/develop branches 7 # - Pull requests to main/develop 8 # 9 # Jobs: 10 # - Build: Compile all packages 11 # - Test: Run all tests 12 # - Lint: Run clippy and rustfmt 13 14 name: CI 15 16 on: 17 push: 18 branches: [main, develop, staging] 19 pull_request: 20 branches: [main, develop, staging] 21 22 env: 23 CARGO_TERM_COLOR: always 24 RUST_BACKTRACE: 1 25 LIBCLANG_PATH: /usr/lib/llvm-14/lib 26 27 jobs: 28 # ========================================================================== 29 # Build Job 30 # ========================================================================== 31 build: 32 name: Build 33 runs-on: ubuntu-latest 34 timeout-minutes: 60 35 36 steps: 37 - name: Checkout alphaos 38 uses: actions/checkout@v4 39 with: 40 path: alphaos 41 42 - name: Checkout alphavm 43 uses: actions/checkout@v4 44 with: 45 repository: BlockBlox-MD/alphavm 46 token: ${{ secrets.REPO_ACCESS_TOKEN }} 47 path: alphavm 48 49 - name: Configure git credentials for cargo 50 run: | 51 # Use URL rewriting to inject token for all GitHub URLs 52 TOKEN=$(echo "${{ secrets.REPO_ACCESS_TOKEN }}" | tr -d '\n\r') 53 git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/" 54 mkdir -p ~/.cargo 55 echo '[net]' >> ~/.cargo/config.toml 56 echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml 57 58 - name: Install system dependencies 59 run: | 60 sudo apt-get update 61 sudo apt-get install -y \ 62 build-essential \ 63 cmake \ 64 clang-14 \ 65 llvm-14 \ 66 libclang-14-dev \ 67 pkg-config \ 68 libssl-dev \ 69 lld 70 71 - name: Setup Rust toolchain 72 uses: dtolnay/rust-toolchain@stable 73 with: 74 components: rustfmt, clippy 75 76 - name: Cache cargo registry 77 uses: actions/cache@v4 78 with: 79 path: | 80 ~/.cargo/registry 81 ~/.cargo/git 82 key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} 83 restore-keys: | 84 ${{ runner.os }}-cargo-registry- 85 86 - name: Cache cargo build 87 uses: actions/cache@v4 88 with: 89 path: alphaos/target 90 key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} 91 restore-keys: | 92 ${{ runner.os }}-cargo-build- 93 94 - name: Build all packages 95 working-directory: alphaos 96 run: cargo build --release --workspace 97 98 # ========================================================================== 99 # Test Job 100 # ========================================================================== 101 test: 102 name: Test 103 runs-on: ubuntu-latest 104 timeout-minutes: 45 105 needs: build 106 107 steps: 108 - name: Checkout alphaos 109 uses: actions/checkout@v4 110 with: 111 path: alphaos 112 113 - name: Checkout alphavm 114 uses: actions/checkout@v4 115 with: 116 repository: BlockBlox-MD/alphavm 117 token: ${{ secrets.REPO_ACCESS_TOKEN }} 118 path: alphavm 119 120 - name: Configure git credentials for cargo 121 run: | 122 # Use URL rewriting to inject token for all GitHub URLs 123 TOKEN=$(echo "${{ secrets.REPO_ACCESS_TOKEN }}" | tr -d '\n\r') 124 git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/" 125 mkdir -p ~/.cargo 126 echo '[net]' >> ~/.cargo/config.toml 127 echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml 128 129 - name: Install system dependencies 130 run: | 131 sudo apt-get update 132 sudo apt-get install -y \ 133 build-essential \ 134 cmake \ 135 clang-14 \ 136 llvm-14 \ 137 libclang-14-dev \ 138 pkg-config \ 139 libssl-dev \ 140 lld 141 142 - name: Setup Rust toolchain 143 uses: dtolnay/rust-toolchain@stable 144 145 - name: Cache cargo 146 uses: actions/cache@v4 147 with: 148 path: | 149 ~/.cargo/registry 150 ~/.cargo/git 151 alphaos/target 152 key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} 153 restore-keys: | 154 ${{ runner.os }}-cargo-test- 155 156 - name: Run tests 157 working-directory: alphaos 158 run: cargo test --workspace --release 159 160 # ========================================================================== 161 # Lint Job 162 # ========================================================================== 163 lint: 164 name: Lint 165 runs-on: ubuntu-latest 166 timeout-minutes: 30 167 168 steps: 169 - name: Checkout alphaos 170 uses: actions/checkout@v4 171 with: 172 path: alphaos 173 174 - name: Checkout alphavm 175 uses: actions/checkout@v4 176 with: 177 repository: BlockBlox-MD/alphavm 178 token: ${{ secrets.REPO_ACCESS_TOKEN }} 179 path: alphavm 180 181 - name: Configure git credentials for cargo 182 run: | 183 # Use URL rewriting to inject token for all GitHub URLs 184 TOKEN=$(echo "${{ secrets.REPO_ACCESS_TOKEN }}" | tr -d '\n\r') 185 git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/" 186 mkdir -p ~/.cargo 187 echo '[net]' >> ~/.cargo/config.toml 188 echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml 189 190 - name: Install system dependencies 191 run: | 192 sudo apt-get update 193 sudo apt-get install -y \ 194 build-essential \ 195 cmake \ 196 clang-14 \ 197 llvm-14 \ 198 libclang-14-dev \ 199 pkg-config \ 200 libssl-dev \ 201 lld 202 203 - name: Setup Rust toolchain 204 uses: dtolnay/rust-toolchain@stable 205 with: 206 components: rustfmt, clippy 207 208 - name: Cache cargo 209 uses: actions/cache@v4 210 with: 211 path: | 212 ~/.cargo/registry 213 ~/.cargo/git 214 alphaos/target 215 key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }} 216 restore-keys: | 217 ${{ runner.os }}-cargo-lint- 218 219 - name: Install nightly for rustfmt 220 run: rustup toolchain install nightly --component rustfmt 221 222 - name: Check formatting 223 working-directory: alphaos 224 run: cargo +nightly fmt --all -- --check 225 226 - name: Run Clippy 227 working-directory: alphaos 228 run: cargo clippy --workspace --all-targets -- -D warnings