From e74e4dfc2b0c9c2c0713af8b86db99780c22a155 Mon Sep 17 00:00:00 2001 From: SinghRajenM Date: Sat, 2 Nov 2024 10:34:04 +0530 Subject: [PATCH 1/5] Improve build workflow --- .github/workflows/ci_build.yml | 79 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index f40bdec..2cd032a 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -8,7 +8,6 @@ on: jobs: build: - runs-on: windows-latest strategy: fail-fast: false @@ -17,45 +16,45 @@ jobs: build_platform: [Win32, x64, ARM64] steps: - # Step 1: Check out the code from the repo - - name: Checkout repo - uses: actions/checkout@v4 - with: - submodules: recursive - - # Step 2: Prepare for build - - name: Pre Build - uses: microsoft/setup-msbuild@v2 + # Step 1: Check out the code from the repo + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: recursive + + # Step 2: Prepare for build + - name: Pre Build + uses: microsoft/setup-msbuild@v2 - # Step 3: Build projects and unit test - - name: Build - working-directory: src - run: msbuild NppJSONViewer.sln /m /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset="v143" - - # Step 4: Upload build binary artifacts - - name: Archive binaries artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.build_platform}}_${{ matrix.build_configuration}} - path: src\Build\Bin\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.dll - - # Step 5: Upload build pdb artifacts - - name: Archive symbols artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.build_platform}}_${{ matrix.build_configuration}}_pdb + # Step 3: Build projects and unit test + - name: Build code + working-directory: src + run: msbuild NppJSONViewer.sln /m /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset="v143" + + # Step 4: Upload build binary artifacts for deployment + - name: Archive binaries artifacts + uses: actions/upload-artifact@v4 + with: + name: NppJSONViewer_${{ matrix.build_platform}}_${{ matrix.build_configuration}} + path: src\Build\Bin\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.dll + + # Step 5: Upload build pdb artifacts + - name: Archive symbols artifacts + uses: actions/upload-artifact@v4 + with: + name: NppJSONViewer_${{ matrix.build_platform}}_${{ matrix.build_configuration}}_pdb path: src\Build\Bin\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.pdb - # Step 6: Run unit tests for x86 | Release - - name: Run tests x86 | Release - if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Release' - run: | - cd src\Build\Bin\Release\Win32 - ./UnitTest.exe - - # Step 7: Run unit tests for x64 | Release - - name: Run tests x64 | Release - if: matrix.build_platform == 'x64' && matrix.build_configuration == 'Release' - run: | - cd src\Build\Bin\Release\x64 - ./UnitTest.exe + # Step 6: Run unit tests for x86 | Release + - name: Run unit tests x86 | Release + if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Release' + run: | + cd src\Build\Bin\Release\Win32 + ./UnitTest.exe + + # Step 7: Run unit tests for x64 | Release + - name: Run unit tests x64 | Release + if: matrix.build_platform == 'x64' && matrix.build_configuration == 'Release' + run: | + cd src\Build\Bin\Release\x64 + ./UnitTest.exe From 6736af364ae019bae055743c11eee62551616838 Mon Sep 17 00:00:00 2001 From: SinghRajenM Date: Sat, 2 Nov 2024 11:33:32 +0530 Subject: [PATCH 2/5] Upload full artifacts --- .github/workflows/ci_build.yml | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index 2cd032a..a0eba28 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -58,3 +58,61 @@ jobs: run: | cd src\Build\Bin\Release\x64 ./UnitTest.exe + + upload-full-artifacts: + # Trigger this job only after all 'build' jobs are complete + needs: build + runs-on: windows-latest + strategy: + fail-fast: true + + steps: + # Step 8: Download all artifacts from all build jobs + - name: Download Release Win32 binaries and PDBs + uses: actions/download-artifact@v4 + with: + path: all_artifacts/Release/win32 + pattern: NppJSONViewer_Win32_Rel* + merge-multiple: true + + - name: Download Debug Win32 binaries and PDBs + uses: actions/download-artifact@v4 + with: + path: all_artifacts/Debug/win32 + pattern: NppJSONViewer_Win32_Deb* + merge-multiple: true + + - name: Download Release x64 binaries and PDBs + uses: actions/download-artifact@v4 + with: + path: all_artifacts/Release/x64 + pattern: NppJSONViewer_x64_Rel* + merge-multiple: true + + - name: Download Debug x64 binaries and PDBs + uses: actions/download-artifact@v4 + with: + path: all_artifacts/Debug/x64 + pattern: NppJSONViewer_x64_Deb* + merge-multiple: true + + - name: Download Release ARM64 binaries and PDBs + uses: actions/download-artifact@v4 + with: + path: all_artifacts/Release/ARM64 + pattern: NppJSONViewer_ARM64_Rel* + merge-multiple: true + + - name: Download Debug ARM64 binaries and PDBs + uses: actions/download-artifact@v4 + with: + path: all_artifacts/Debug/ARM64 + pattern: NppJSONViewer_ARM64_Deb* + merge-multiple: true + + # Step 9: Upload full artifact + - name: Upload full artifacts + uses: actions/upload-artifact@v4 + with: + name: NppJSONViewer_ALL + path: all_artifacts\** From ac0ebfce20fd1bf0ea4d8814eb30ce62eb8c19cf Mon Sep 17 00:00:00 2001 From: SinghRajenM Date: Sat, 2 Nov 2024 13:03:09 +0530 Subject: [PATCH 3/5] Run unit test for both debug and release for x86 and x64 --- .github/workflows/ci_build.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index a0eba28..23474f4 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -45,18 +45,11 @@ jobs: name: NppJSONViewer_${{ matrix.build_platform}}_${{ matrix.build_configuration}}_pdb path: src\Build\Bin\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.pdb - # Step 6: Run unit tests for x86 | Release - - name: Run unit tests x86 | Release - if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Release' + # Step 6: Run unit tests for x86 and x64 + - name: Run unit tests + if: matrix.build_platform == 'Win32' || matrix.build_platform == 'x64' run: | - cd src\Build\Bin\Release\Win32 - ./UnitTest.exe - - # Step 7: Run unit tests for x64 | Release - - name: Run unit tests x64 | Release - if: matrix.build_platform == 'x64' && matrix.build_configuration == 'Release' - run: | - cd src\Build\Bin\Release\x64 + cd src\Build\Bin\${{ matrix.build_configuration }}\${{ matrix.build_platform }} ./UnitTest.exe upload-full-artifacts: From bbe39a1430faf7f7b9cffb52a8e8c1b3404720f5 Mon Sep 17 00:00:00 2001 From: SinghRajenM Date: Sat, 2 Nov 2024 13:21:07 +0530 Subject: [PATCH 4/5] Relace hardcoded values with variable --- .github/workflows/ci_build.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index 23474f4..0a8674b 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -1,4 +1,4 @@ -name: Build and test +name: Build and Test on: push: @@ -6,6 +6,10 @@ on: pull_request: branches: [ "master" ] +env: + BUILD_DIR: src\Build\Bin + MSBUILD_TOOLSET: v143 + jobs: build: runs-on: windows-latest @@ -20,36 +24,36 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 with: - submodules: recursive + submodules: recursive # Step 2: Prepare for build - - name: Pre Build + - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 # Step 3: Build projects and unit test - name: Build code working-directory: src - run: msbuild NppJSONViewer.sln /m /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset="v143" + run: msbuild NppJSONViewer.sln /m /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset=${{ env.MSBUILD_TOOLSET }} # Step 4: Upload build binary artifacts for deployment - name: Archive binaries artifacts uses: actions/upload-artifact@v4 with: - name: NppJSONViewer_${{ matrix.build_platform}}_${{ matrix.build_configuration}} - path: src\Build\Bin\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.dll + name: NppJSONViewer_${{ matrix.build_platform}}_${{ matrix.build_configuration}} + path: ${{ env.BUILD_DIR }}\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.dll # Step 5: Upload build pdb artifacts - name: Archive symbols artifacts uses: actions/upload-artifact@v4 with: name: NppJSONViewer_${{ matrix.build_platform}}_${{ matrix.build_configuration}}_pdb - path: src\Build\Bin\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.pdb + path: ${{ env.BUILD_DIR }}\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.pdb # Step 6: Run unit tests for x86 and x64 - name: Run unit tests if: matrix.build_platform == 'Win32' || matrix.build_platform == 'x64' run: | - cd src\Build\Bin\${{ matrix.build_configuration }}\${{ matrix.build_platform }} + cd ${{ env.BUILD_DIR }}\${{ matrix.build_configuration }}\${{ matrix.build_platform }} ./UnitTest.exe upload-full-artifacts: From 03fe4ad2eb6d8e93cc9f8e7632eddffc7f71730a Mon Sep 17 00:00:00 2001 From: SinghRajenM Date: Sat, 2 Nov 2024 13:33:24 +0530 Subject: [PATCH 5/5] Try similifying consolidated artfact upload #fixes #205, #closes #205 --- .github/workflows/ci_build.yml | 63 ++++++++-------------------------- 1 file changed, 14 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index 0a8674b..38051e8 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -9,6 +9,7 @@ on: env: BUILD_DIR: src\Build\Bin MSBUILD_TOOLSET: v143 + ARTIFACT_PREFIX: NppJSONViewer_ jobs: build: @@ -33,27 +34,27 @@ jobs: # Step 3: Build projects and unit test - name: Build code working-directory: src - run: msbuild NppJSONViewer.sln /m /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset=${{ env.MSBUILD_TOOLSET }} + run: msbuild NppJSONViewer.sln /m /p:configuration="${{matrix.build_configuration}}" /p:platform="${{matrix.build_platform}}" /p:PlatformToolset=${{env.MSBUILD_TOOLSET}} # Step 4: Upload build binary artifacts for deployment - name: Archive binaries artifacts uses: actions/upload-artifact@v4 with: - name: NppJSONViewer_${{ matrix.build_platform}}_${{ matrix.build_configuration}} - path: ${{ env.BUILD_DIR }}\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.dll + name: ${{env.ARTIFACT_PREFIX}}${{matrix.build_platform}}_${{matrix.build_configuration}} + path: ${{env.BUILD_DIR }}\${{matrix.build_configuration}}\${{matrix.build_platform}}\NPPJSONViewer.dll # Step 5: Upload build pdb artifacts - name: Archive symbols artifacts uses: actions/upload-artifact@v4 with: - name: NppJSONViewer_${{ matrix.build_platform}}_${{ matrix.build_configuration}}_pdb - path: ${{ env.BUILD_DIR }}\${{ matrix.build_configuration}}\${{ matrix.build_platform}}\NPPJSONViewer.pdb + name: ${{env.ARTIFACT_PREFIX}}${{matrix.build_platform}}_${{matrix.build_configuration}}_pdb + path: ${{env.BUILD_DIR }}\${{matrix.build_configuration}}\${{matrix.build_platform}}\NPPJSONViewer.pdb # Step 6: Run unit tests for x86 and x64 - name: Run unit tests if: matrix.build_platform == 'Win32' || matrix.build_platform == 'x64' run: | - cd ${{ env.BUILD_DIR }}\${{ matrix.build_configuration }}\${{ matrix.build_platform }} + cd ${{env.BUILD_DIR}}\${{matrix.build_configuration}}\${{matrix.build_platform}} ./UnitTest.exe upload-full-artifacts: @@ -64,52 +65,16 @@ jobs: fail-fast: true steps: - # Step 8: Download all artifacts from all build jobs - - name: Download Release Win32 binaries and PDBs + # Step 7: Download all artifacts from the build job + - name: Download all artifacts uses: actions/download-artifact@v4 with: - path: all_artifacts/Release/win32 - pattern: NppJSONViewer_Win32_Rel* - merge-multiple: true + pattern: ${{env.ARTIFACT_PREFIX}}* + path: all_artifacts\ - - name: Download Debug Win32 binaries and PDBs - uses: actions/download-artifact@v4 - with: - path: all_artifacts/Debug/win32 - pattern: NppJSONViewer_Win32_Deb* - merge-multiple: true - - - name: Download Release x64 binaries and PDBs - uses: actions/download-artifact@v4 - with: - path: all_artifacts/Release/x64 - pattern: NppJSONViewer_x64_Rel* - merge-multiple: true - - - name: Download Debug x64 binaries and PDBs - uses: actions/download-artifact@v4 - with: - path: all_artifacts/Debug/x64 - pattern: NppJSONViewer_x64_Deb* - merge-multiple: true - - - name: Download Release ARM64 binaries and PDBs - uses: actions/download-artifact@v4 - with: - path: all_artifacts/Release/ARM64 - pattern: NppJSONViewer_ARM64_Rel* - merge-multiple: true - - - name: Download Debug ARM64 binaries and PDBs - uses: actions/download-artifact@v4 - with: - path: all_artifacts/Debug/ARM64 - pattern: NppJSONViewer_ARM64_Deb* - merge-multiple: true - - # Step 9: Upload full artifact - - name: Upload full artifacts + # Step 8: Upload consolidated artifacts as a single artifact + - name: Upload full artifact uses: actions/upload-artifact@v4 with: - name: NppJSONViewer_ALL + name: ${{env.ARTIFACT_PREFIX}}ALL path: all_artifacts\**