|
| 1 | +name: wolfBoot Visual Studio |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + # TODO: branches: [ 'master', 'main', 'release/**' ] |
| 6 | + branches: [ '*' ] |
| 7 | + pull_request: |
| 8 | + branches: [ '*' ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + name: Visual Studio Keytools Tests |
| 13 | + runs-on: windows-latest |
| 14 | + |
| 15 | + env: |
| 16 | + CONFIG: Debug |
| 17 | + PLATFORM: x64 |
| 18 | + ASYM: ecc256 |
| 19 | + HASH: sha256 |
| 20 | + |
| 21 | + steps: |
| 22 | + # Adds MSBuild to PATH |
| 23 | + - uses: microsoft/setup-msbuild@v2 |
| 24 | + with: |
| 25 | + msbuild-architecture: x64 |
| 26 | + |
| 27 | + - name: Checkout (with submodules) |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + submodules: true |
| 31 | + |
| 32 | + - name: Fetch test target.h |
| 33 | + shell: cmd |
| 34 | + working-directory: .\ |
| 35 | + run: | |
| 36 | + :: Ensure there's a target.h |
| 37 | +
|
| 38 | + echo Current directory: |
| 39 | + echo %cd% |
| 40 | +
|
| 41 | + :: echo Copying tools\unit-tests\target.h to src\target.h |
| 42 | +
|
| 43 | + :: copy /Y tools\unit-tests\target.h src\target.h |
| 44 | +
|
| 45 | + echo Copying tools\unit-tests\target.h to include\target.h |
| 46 | +
|
| 47 | + copy /Y tools\unit-tests\target.h include\target.h |
| 48 | +
|
| 49 | + # Step 1 Build keygen, then run it |
| 50 | + - name: Build KeygenTool keygen.exe |
| 51 | + shell: cmd |
| 52 | + working-directory: .\ |
| 53 | + run: | |
| 54 | + echo Current directory: |
| 55 | + echo %cd% |
| 56 | +
|
| 57 | + pushd tools\keytools\ |
| 58 | +
|
| 59 | + msbuild wolfBootKeygenTool.vcxproj ^ |
| 60 | + /t:Rebuild ^ |
| 61 | + /m ^ |
| 62 | + /p:Configuration=%CONFIG% ^ |
| 63 | + /p:Platform=%PLATFORM% ^ |
| 64 | + /p:PreferredToolArchitecture=x64 ^ |
| 65 | + /v:m |
| 66 | +
|
| 67 | + popd |
| 68 | +
|
| 69 | + - name: Run KeygenTool keygen.exe |
| 70 | + shell: cmd |
| 71 | + working-directory: .\ |
| 72 | + run: | |
| 73 | + :: Run keygen.exe |
| 74 | +
|
| 75 | + echo Current directory: |
| 76 | + echo %cd% |
| 77 | +
|
| 78 | + .\tools\keytools\%PLATFORM%\%CONFIG%\keygen.exe --ecc256 -g wolfboot_signing_private_key.der |
| 79 | + if errorlevel 1 ( |
| 80 | + echo keygen.exe failed with ERRORLEVEL %ERRORLEVEL% |
| 81 | + exit /b %ERRORLEVEL% |
| 82 | + ) |
| 83 | +
|
| 84 | + echo "wolfboot_signing_private_key.der file:" |
| 85 | + dir wolfboot_signing_private_key.der /s |
| 86 | +
|
| 87 | + echo "keystore.c file:" |
| 88 | + dir keystore.c /s |
| 89 | +
|
| 90 | + # Step 2 Build signing tool, then run it |
| 91 | + - name: Build SignTool sign.exe |
| 92 | + shell: cmd |
| 93 | + working-directory: .\ |
| 94 | + run: | |
| 95 | + pushd tools\keytools\ |
| 96 | +
|
| 97 | + msbuild wolfBootSignTool.vcxproj ^ |
| 98 | + /t:Rebuild ^ |
| 99 | + /m ^ |
| 100 | + /p:Configuration=%CONFIG% ^ |
| 101 | + /p:Platform=%PLATFORM% ^ |
| 102 | + /p:PreferredToolArchitecture=x64 ^ |
| 103 | + /v:m |
| 104 | +
|
| 105 | + popd |
| 106 | +
|
| 107 | + - name: Create a file to sign |
| 108 | + shell: cmd |
| 109 | + working-directory: .\ |
| 110 | + run: | |
| 111 | + :: Create a test.bin file |
| 112 | +
|
| 113 | + echo Creating a new test.bin |
| 114 | + echo "Test" > test.bin |
| 115 | +
|
| 116 | + - name: Run SignTool sign.exe |
| 117 | + shell: cmd |
| 118 | + working-directory: .\ |
| 119 | + run: | |
| 120 | + :: Run sign.exe |
| 121 | +
|
| 122 | + echo Current directory: |
| 123 | + echo %cd% |
| 124 | +
|
| 125 | + echo Running .\tools\keytools\%PLATFORM%\%CONFIG%\sign.exe --%ASYM% --%HASH% test.bin wolfboot_signing_private_key.der 1 |
| 126 | +
|
| 127 | + .\tools\keytools\%PLATFORM%\%CONFIG%\sign.exe --%ASYM% --%HASH% test.bin wolfboot_signing_private_key.der 1 |
| 128 | +
|
| 129 | + if errorlevel 1 ( |
| 130 | + echo sign.exe failed with ERRORLEVEL %ERRORLEVEL% |
| 131 | + exit /b %ERRORLEVEL% |
| 132 | + ) |
| 133 | +
|
| 134 | + echo wolfboot_signing_private_key.der file: |
| 135 | + dir wolfboot_signing_private_key.der /s |
| 136 | +
|
| 137 | + echo "keystore.c file:" |
| 138 | + dir keystore.c /s |
| 139 | +
|
| 140 | + echo test.bin file: |
| 141 | + dir test.bin /s |
| 142 | +
|
| 143 | + echo test_v1_signed.bin file: |
| 144 | + dir test_v1_signed.bin /s |
| 145 | +
|
| 146 | + # Step 3 Build Test tool, then run it |
| 147 | + - name: Build Library Test test-lib.exe |
| 148 | + shell: cmd |
| 149 | + working-directory: .\ |
| 150 | + run: | |
| 151 | + pushd tools\keytools\ |
| 152 | +
|
| 153 | + msbuild wolfBootTestLib.vcxproj ^ |
| 154 | + /t:Rebuild ^ |
| 155 | + /m ^ |
| 156 | + /p:Configuration=%CONFIG% ^ |
| 157 | + /p:Platform=%PLATFORM% ^ |
| 158 | + /p:PreferredToolArchitecture=x64 ^ |
| 159 | + /v:m |
| 160 | +
|
| 161 | + popd |
| 162 | +
|
| 163 | + - name: Run Library Test test-lib.exe |
| 164 | + shell: cmd |
| 165 | + working-directory: .\ |
| 166 | + run: | |
| 167 | + :: Run sign.exe |
| 168 | +
|
| 169 | + echo Current directory: |
| 170 | + echo %cd% |
| 171 | +
|
| 172 | + :: A missing target.h is a common build failure on GitHub. |
| 173 | + :: See above where we copy one from [WOLFBOOT_ROOT]\tools\unit-tests\ |
| 174 | + :: echo Where is the target.h? |
| 175 | + :: dir target.h /s |
| 176 | +
|
| 177 | + dir test_v1_signed.bin /s |
| 178 | +
|
| 179 | + echo Running .\tools\keytools\%PLATFORM%\%CONFIG%\test-lib.exe .\test_v1_signed.bin |
| 180 | +
|
| 181 | + if errorlevel 1 ( |
| 182 | + echo test-lib.exe failed with ERRORLEVEL %ERRORLEVEL% |
| 183 | + exit /b %ERRORLEVEL% |
| 184 | + ) |
| 185 | +
|
| 186 | + .\tools\keytools\%PLATFORM%\%CONFIG%\test-lib.exe .\test_v1_signed.bin |
| 187 | +
|
| 188 | + echo Done! |
0 commit comments