| 
 | 1 | +name: Integration (Emulation Mode)  | 
 | 2 | + | 
 | 3 | +# Trigger on push and pull request events  | 
 | 4 | +on:  | 
 | 5 | +  push:  | 
 | 6 | +    paths-ignore:  | 
 | 7 | +      - "**.md"  | 
 | 8 | +      - "doc/**"  | 
 | 9 | +  pull_request:  | 
 | 10 | +    paths-ignore:  | 
 | 11 | +      - "**.md"  | 
 | 12 | +      - "doc/**"  | 
 | 13 | +  workflow_dispatch:  | 
 | 14 | + | 
 | 15 | +env:  | 
 | 16 | +  AS: nasm  | 
 | 17 | +  RUST_TOOLCHAIN: 1.83.0  | 
 | 18 | +  TOOLCHAIN_PROFILE: minimal  | 
 | 19 | + | 
 | 20 | +permissions:  | 
 | 21 | +  contents: read  | 
 | 22 | + | 
 | 23 | +jobs:  | 
 | 24 | +  build-and-test:  | 
 | 25 | +    name: Build and Test MigTD in Emulation Mode  | 
 | 26 | +    runs-on: ubuntu-22.04  | 
 | 27 | +    timeout-minutes: 60  | 
 | 28 | + | 
 | 29 | +    steps:  | 
 | 30 | +      # Install first since it's needed to build NASM  | 
 | 31 | +      - name: Install LLVM and Clang  | 
 | 32 | +        uses: KyleMayes/install-llvm-action@a7a1a882e2d06ebe05d5bb97c3e1f8c984ae96fc # v2.0.7  | 
 | 33 | +        with:  | 
 | 34 | +          version: "10.0"  | 
 | 35 | +          directory: ${{ runner.temp }}/llvm  | 
 | 36 | +        | 
 | 37 | +      - name: Install libtinfo5  | 
 | 38 | +        run: sudo apt-get update -y && sudo apt-get install libtinfo5 -y  | 
 | 39 | + | 
 | 40 | +      - name: Install NASM  | 
 | 41 | +        uses: ilammy/setup-nasm@72793074d3c8cdda771dba85f6deafe00623038b # v1.5.2  | 
 | 42 | + | 
 | 43 | +      - name: Install build dependencies  | 
 | 44 | +        run: sudo apt-get install build-essential ocaml ocamlbuild automake autoconf libtool wget python-is-python3 libssl-dev git cmake perl libtss2-dev pkg-config  | 
 | 45 | + | 
 | 46 | +      - name: Checkout sources  | 
 | 47 | +        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0  | 
 | 48 | +        with:  | 
 | 49 | +          submodules: recursive  | 
 | 50 | + | 
 | 51 | +      - name: Install Rust toolchain  | 
 | 52 | +        uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7  | 
 | 53 | +        with:  | 
 | 54 | +          profile: ${{ env.TOOLCHAIN_PROFILE }}  | 
 | 55 | +          toolchain: ${{ env.RUST_TOOLCHAIN }}  | 
 | 56 | +          override: true  | 
 | 57 | +          components: rust-src  | 
 | 58 | + | 
 | 59 | +      - name: Add x86_64-unknown-none target  | 
 | 60 | +        run: rustup target add x86_64-unknown-none  | 
 | 61 | +          | 
 | 62 | +      - name: Run preparation script  | 
 | 63 | +        run: bash sh_script/preparation.sh  | 
 | 64 | + | 
 | 65 | +      - name: Build MigTD with test features for emulation  | 
 | 66 | +        run: |  | 
 | 67 | +          echo "Building MigTD with AzCVMEmu and test features for emulation testing..."  | 
 | 68 | +          cargo build --release --features "AzCVMEmu,test_disable_ra_and_accept_all" --no-default-features  | 
 | 69 | +
  | 
 | 70 | +      - name: Verify emulation script and binary  | 
 | 71 | +        run: |  | 
 | 72 | +          if [[ ! -f "./migtdemu.sh" ]]; then  | 
 | 73 | +            echo "Error: migtdemu.sh not found"  | 
 | 74 | +            exit 1  | 
 | 75 | +          fi  | 
 | 76 | +          chmod +x ./migtdemu.sh  | 
 | 77 | +            | 
 | 78 | +          if [[ ! -f "./target/release/migtd" ]]; then  | 
 | 79 | +            echo "Error: migtd binary not found after build"  | 
 | 80 | +            exit 1  | 
 | 81 | +          fi  | 
 | 82 | +            | 
 | 83 | +          echo "Emulation script and binary are ready"  | 
 | 84 | +
  | 
 | 85 | +      - name: Run MigTD emulation tests  | 
 | 86 | +        id: emulation_test  | 
 | 87 | +        run: |  | 
 | 88 | +          echo "Running MigTD emulation tests with both source and destination..."  | 
 | 89 | +          echo "This will start destination, then source, and test the migration flow"  | 
 | 90 | +          echo "Command: ./migtdemu.sh --skip-ra --both --no-sudo --log-level info"  | 
 | 91 | +            | 
 | 92 | +          # Run the test with timeout and capture exit code  | 
 | 93 | +          set +e  | 
 | 94 | +          timeout 300 ./migtdemu.sh --skip-ra --both --no-sudo --log-level info  | 
 | 95 | +          EXIT_CODE=$?  | 
 | 96 | +          set -e  | 
 | 97 | +            | 
 | 98 | +          echo "Test completed with exit code: $EXIT_CODE"  | 
 | 99 | +            | 
 | 100 | +          if [[ $EXIT_CODE -eq 0 ]]; then  | 
 | 101 | +            echo "✅ Emulation test completed successfully"  | 
 | 102 | +            echo "test_status=success" >> $GITHUB_OUTPUT  | 
 | 103 | +          elif [[ $EXIT_CODE -eq 124 ]]; then  | 
 | 104 | +            echo "❌ Emulation test timed out after 300 seconds"  | 
 | 105 | +            echo "test_status=timeout" >> $GITHUB_OUTPUT  | 
 | 106 | +            exit 1  | 
 | 107 | +          else  | 
 | 108 | +            echo "❌ Emulation test failed with exit code $EXIT_CODE"  | 
 | 109 | +            echo "test_status=failed" >> $GITHUB_OUTPUT  | 
 | 110 | +            exit $EXIT_CODE  | 
 | 111 | +          fi  | 
 | 112 | +
  | 
 | 113 | +      - name: Check test outputs and logs  | 
 | 114 | +        if: always()  | 
 | 115 | +        run: |  | 
 | 116 | +          echo "=== Test Execution Summary ==="  | 
 | 117 | +          echo "Test status: ${{ steps.emulation_test.outputs.test_status || 'unknown' }}"  | 
 | 118 | +            | 
 | 119 | +          if [[ -f "dest.out.log" ]]; then  | 
 | 120 | +            DEST_LOG_SIZE=$(wc -l < dest.out.log)  | 
 | 121 | +            echo "Destination log found: $DEST_LOG_SIZE lines"  | 
 | 122 | +              | 
 | 123 | +            echo ""  | 
 | 124 | +            echo "=== Last 50 lines of destination log ==="  | 
 | 125 | +            tail -n 50 dest.out.log  | 
 | 126 | +              | 
 | 127 | +            echo ""  | 
 | 128 | +            echo "=== First 20 lines of destination log ==="  | 
 | 129 | +            head -n 20 dest.out.log  | 
 | 130 | +          else  | 
 | 131 | +            echo "No destination log file found"  | 
 | 132 | +          fi  | 
 | 133 | +            | 
 | 134 | +          # Check for any process dumps or error files  | 
 | 135 | +          if ls core* 1> /dev/null 2>&1; then  | 
 | 136 | +            echo ""  | 
 | 137 | +            echo "=== Core dumps found ==="  | 
 | 138 | +            ls -la core*  | 
 | 139 | +          fi  | 
 | 140 | +            | 
 | 141 | +          # Show summary of what was tested  | 
 | 142 | +          echo ""  | 
 | 143 | +          echo "=== Test Summary ==="  | 
 | 144 | +          echo "- Built MigTD with AzCVMEmu and test_disable_ra_and_accept_all features"  | 
 | 145 | +          echo "- Ran emulation test with both source and destination instances"  | 
 | 146 | +          echo "- Skip RA mode enabled (mock attestation, no TPM/Azure CVM required)"  | 
 | 147 | +
  | 
 | 148 | +      - name: Upload test artifacts on failure  | 
 | 149 | +        if: failure()  | 
 | 150 | +        uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0  | 
 | 151 | +        with:  | 
 | 152 | +          name: migtd-test-logs-${{ github.run_id }}  | 
 | 153 | +          path: |  | 
 | 154 | +            dest.out.log  | 
 | 155 | +            *.log  | 
 | 156 | +            core*  | 
 | 157 | +            target/release/migtd  | 
 | 158 | +          retention-days: 7  | 
 | 159 | +          if-no-files-found: ignore  | 
 | 160 | + | 
 | 161 | +      - name: Report final status  | 
 | 162 | +        if: always()  | 
 | 163 | +        run: |  | 
 | 164 | +          case "${{ steps.emulation_test.outputs.test_status }}" in  | 
 | 165 | +            "success")  | 
 | 166 | +              echo "🎉 MigTD PR tests passed successfully!"  | 
 | 167 | +              echo "✅ Build completed"  | 
 | 168 | +              echo "✅ Emulation tests passed"  | 
 | 169 | +              echo "The PR is ready for code review."  | 
 | 170 | +              ;;  | 
 | 171 | +            "timeout")  | 
 | 172 | +              echo "⏰ MigTD tests timed out"  | 
 | 173 | +              echo "✅ Build completed"  | 
 | 174 | +              echo "❌ Tests timed out after 5 minutes"  | 
 | 175 | +              echo "Check logs for hanging processes or infinite loops."  | 
 | 176 | +              ;;  | 
 | 177 | +            "failed"|*)  | 
 | 178 | +              echo "❌ MigTD tests failed"  | 
 | 179 | +              echo "✅ Build completed"  | 
 | 180 | +              echo "❌ Emulation tests failed"  | 
 | 181 | +              echo "Check the test logs above and uploaded artifacts for debugging details."  | 
 | 182 | +              ;;  | 
 | 183 | +          esac  | 
0 commit comments