/ .github / workflows / ci.yml
ci.yml
  1  # DeltaVM 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]
 19    pull_request:
 20      branches: [main, develop]
 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: 45
 35  
 36      steps:
 37        - name: Checkout deltavm
 38          uses: actions/checkout@v4
 39          with:
 40            path: deltavm
 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  
 70        - name: Setup Rust toolchain
 71          uses: dtolnay/rust-toolchain@stable
 72          with:
 73            components: rustfmt, clippy
 74  
 75        - name: Cache cargo registry
 76          uses: actions/cache@v4
 77          with:
 78            path: |
 79              ~/.cargo/registry
 80              ~/.cargo/git
 81            key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
 82            restore-keys: |
 83              ${{ runner.os }}-cargo-registry-
 84  
 85        - name: Cache cargo build
 86          uses: actions/cache@v4
 87          with:
 88            path: deltavm/target
 89            key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
 90            restore-keys: |
 91              ${{ runner.os }}-cargo-build-
 92  
 93        - name: Build all packages
 94          working-directory: deltavm
 95          run: cargo build --release --workspace
 96  
 97    # ==========================================================================
 98    # Test Job
 99    # ==========================================================================
100    test:
101      name: Test
102      runs-on: ubuntu-latest
103      timeout-minutes: 30
104      needs: build
105  
106      steps:
107        - name: Checkout deltavm
108          uses: actions/checkout@v4
109          with:
110            path: deltavm
111  
112        - name: Checkout alphavm
113          uses: actions/checkout@v4
114          with:
115            repository: BlockBlox-MD/alphavm
116            token: ${{ secrets.REPO_ACCESS_TOKEN }}
117            path: alphavm
118  
119        - name: Configure git credentials for cargo
120          run: |
121            # Use URL rewriting to inject token for all GitHub URLs
122            TOKEN=$(echo "${{ secrets.REPO_ACCESS_TOKEN }}" | tr -d '\n\r')
123            git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/"
124            mkdir -p ~/.cargo
125            echo '[net]' >> ~/.cargo/config.toml
126            echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml
127  
128        - name: Install system dependencies
129          run: |
130            sudo apt-get update
131            sudo apt-get install -y \
132              build-essential \
133              cmake \
134              clang-14 \
135              llvm-14 \
136              libclang-14-dev \
137              pkg-config \
138              libssl-dev
139  
140        - name: Setup Rust toolchain
141          uses: dtolnay/rust-toolchain@stable
142  
143        - name: Cache cargo
144          uses: actions/cache@v4
145          with:
146            path: |
147              ~/.cargo/registry
148              ~/.cargo/git
149              deltavm/target
150            key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
151            restore-keys: |
152              ${{ runner.os }}-cargo-test-
153  
154        - name: Run tests
155          working-directory: deltavm
156          run: cargo test --workspace --release
157  
158    # ==========================================================================
159    # Lint Job
160    # ==========================================================================
161    lint:
162      name: Lint
163      runs-on: ubuntu-latest
164      timeout-minutes: 30
165  
166      steps:
167        - name: Checkout deltavm
168          uses: actions/checkout@v4
169          with:
170            path: deltavm
171  
172        - name: Checkout alphavm
173          uses: actions/checkout@v4
174          with:
175            repository: BlockBlox-MD/alphavm
176            token: ${{ secrets.REPO_ACCESS_TOKEN }}
177            path: alphavm
178  
179        - name: Configure git credentials for cargo
180          run: |
181            # Use URL rewriting to inject token for all GitHub URLs
182            TOKEN=$(echo "${{ secrets.REPO_ACCESS_TOKEN }}" | tr -d '\n\r')
183            git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/"
184            mkdir -p ~/.cargo
185            echo '[net]' >> ~/.cargo/config.toml
186            echo 'git-fetch-with-cli = true' >> ~/.cargo/config.toml
187  
188        - name: Install system dependencies
189          run: |
190            sudo apt-get update
191            sudo apt-get install -y \
192              build-essential \
193              cmake \
194              clang-14 \
195              llvm-14 \
196              libclang-14-dev \
197              pkg-config \
198              libssl-dev
199  
200        - name: Setup Rust toolchain
201          uses: dtolnay/rust-toolchain@stable
202          with:
203            components: rustfmt, clippy
204  
205        - name: Cache cargo
206          uses: actions/cache@v4
207          with:
208            path: |
209              ~/.cargo/registry
210              ~/.cargo/git
211              deltavm/target
212            key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
213            restore-keys: |
214              ${{ runner.os }}-cargo-lint-
215  
216        - name: Install nightly for rustfmt
217          run: rustup toolchain install nightly --component rustfmt
218  
219        - name: Check formatting
220          working-directory: deltavm
221          run: cargo +nightly fmt --all -- --check
222  
223        - name: Run Clippy
224          working-directory: deltavm
225          run: cargo clippy --workspace --all-targets -- -D warnings