|
| 1 | +name: ContinuousIntegration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "master" ] |
| 8 | + types: [opened, reopened, synchronize] |
| 9 | + |
| 10 | +jobs: |
| 11 | + ContinuousIntegration: |
| 12 | + runs-on: windows-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Checkout master branch |
| 21 | + run: git checkout master |
| 22 | + |
| 23 | + - name: Copy files from master branch to temporary folder |
| 24 | + run: | |
| 25 | + mkdir "${{github.workspace}}\master_temp" |
| 26 | +
|
| 27 | + robocopy "${{github.workspace}}\" "${{github.workspace}}\master_temp" /NFL /E /XD "${{github.workspace}}\master_temp" |
| 28 | + # Robocopy will return 1 if successful, so we need to exit with 0 to avoid triggering a failure for this step |
| 29 | + if ($LastExitCode -eq 1) { |
| 30 | + echo "All files were copied successfully. Continuing..." |
| 31 | + exit 0 |
| 32 | + } elseif ($LastExitCode -gt 7) { |
| 33 | + echo "An error occurred during file copying. Exiting..." |
| 34 | + exit $LastExitCode |
| 35 | + } |
| 36 | +
|
| 37 | + - name: Checkout tests branch |
| 38 | + run: git checkout tests |
| 39 | + |
| 40 | + - name: Copy master branch files from temporary folder to MasterBranchCode folder |
| 41 | + run: | |
| 42 | + robocopy "${{github.workspace}}\master_temp" "${{github.workspace}}\MasterBranchCode" /NFL /E |
| 43 | + # Robocopy will return 1 if successful, so we need to exit with 0 to avoid triggering a failure for this step |
| 44 | + if ($LastExitCode -eq 1) { |
| 45 | + echo "All files were copied successfully. Continuing..." |
| 46 | + exit 0 |
| 47 | + } elseif ($LastExitCode -gt 7) { |
| 48 | + echo "An error occurred during file copying. Exiting..." |
| 49 | + exit $LastExitCode |
| 50 | + } |
| 51 | + |
| 52 | + - name: Configure CMake |
| 53 | + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release |
| 54 | + |
| 55 | + - name: Build |
| 56 | + run: cmake --build ${{github.workspace}}/build --config Release |
| 57 | + |
| 58 | + - name: Ensure all files are in place |
| 59 | + run: | |
| 60 | + Move "${{github.workspace}}\build\Release\Visual_Node_System_Tests.exe" "${{github.workspace}}\Visual_Node_System_Tests.exe" |
| 61 | + |
| 62 | + - name: Run test |
| 63 | + run: | |
| 64 | + $processStartInfo = New-Object System.Diagnostics.ProcessStartInfo |
| 65 | + $processStartInfo.FileName = "Visual_Node_System_Tests.exe" |
| 66 | + |
| 67 | + Write-Host "Starting the executable..." |
| 68 | + $process = New-Object System.Diagnostics.Process |
| 69 | + $process.StartInfo = $processStartInfo |
| 70 | + $process.Start() | Out-Null |
| 71 | + Write-Host "Executable started." |
| 72 | + |
| 73 | + Write-Host "Waiting for the process to exit..." |
| 74 | + $process.WaitForExit(10000) # 10 seconds |
| 75 | + if ($process.ExitCode -ne 0) { |
| 76 | + Write-Host "Some tests failed. Please check the test results." |
| 77 | + exit 1 |
| 78 | + } |
| 79 | + |
| 80 | + - name: Print additional test results if failed |
| 81 | + if: failure() |
| 82 | + run: | |
| 83 | + Get-Content "Results.xml" | ForEach-Object { |
| 84 | + Write-Host $_ |
| 85 | + } |
0 commit comments