Minor updates in viewer project #320
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test MainRepo1 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: # Allows manual triggering | |
| env: | |
| # Main repository directory: | |
| # Placeholder: ${{ env.REPO_DIR }} | |
| REPO_DIR: IGLibCore | |
| # Main source project directory: | |
| # Placeholder: ${{ env.SOURCE_DIR }} | |
| SOURCE_DIR: IGLibCore/src/IGLib.Core | |
| # Whether failed tests are ignored (should normally be false): | |
| # Placeholder: ${{ env.IGNORE_TEST_ERRORS }} | |
| IGNORE_TEST_ERRORS: false | |
| jobs: | |
| build-and-test: | |
| runs-on: windows-latest # use Windows for .NET Framework support | |
| # runs-on: ubuntu-latest # runs on GitHub-hosted Ubuntu | |
| strategy: | |
| matrix: | |
| dotnet-version: [ '10.0' ] | |
| steps: | |
| # CHECKOUT Main Repository | |
| - name: Clone Main Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ajgorhoe/IGLib.modules.${{ env.REPO_DIR }} | |
| path: ${{ env.REPO_DIR }} | |
| ref: main | |
| # Important: set fetch-depth 0 to avoid shallow clones (needed | |
| # for GitVersion): | |
| fetch-depth: 0 | |
| # Temporary token created automatically for the main repo (owner of the workflow) | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| # CONFIGURE GIT to use access token for owned repos | |
| - name: CONFIGURE GIT credentials for private repos | |
| shell: pwsh | |
| run: | | |
| # # Option 1 - via configuration file | |
| # # Because Git may have different idea of the location of home | |
| # # directory (and of config. file .git-credentials) than PowerShell, | |
| # # we explicitly define where the location of config. is. | |
| # if ($IsWindows) { | |
| # $credPath = "$env:USERPROFILE\.git-credentials" | |
| # } else { | |
| # $credPath = "$HOME/.git-credentials" | |
| # } | |
| # git config --global credential.helper "store --file=$credPath" | |
| # " https://x-access-token:${{ secrets.PAT_ACTIONS_IGLIB_READONLY }}@github.com" | Out-File -FilePath $credPath -Encoding ascii | |
| # git config --global credential.useHttpPath true | |
| # # Option 2 - Inject credentials directly into Git’s configuration for the current session: | |
| git config --global url."https://x-access-token:${{ secrets.PAT_ACTIONS_IGLIB_READONLY }}@github.com/".insteadOf "https://github.com/" | |
| # CLONE DEPENDENCY repositories: | |
| - name: CLONE DEPENDENCY repos | |
| shell: pwsh | |
| continue-on-error: false | |
| # Important: set --depth 0 to avoid shallow clones (needed | |
| # for GitVersion) | |
| run: | | |
| echo "Cloning dependencies via repo's own script (UpdateDependencyReposExtended.ps1)`n`n..." | |
| ./${{ env.REPO_DIR }}/scripts/UpdateDependencyReposExtended.ps1 | |
| # CHECKOUT IGLibScripting | |
| - name: Clone IGLibScripting | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ajgorhoe/IGLib.modules.IGLibScripting | |
| path: IGLibScripting | |
| ref: main | |
| # Use automatically generated token (private repo, same owner) | |
| token: ${{ secrets.PAT_ACTIONS_IGLIB_READONLY }} | |
| # CLONE IGLibScripting | |
| - name: Clone IGLibScripting Dependency | |
| shell: pwsh | |
| # Important: set --depth 0 to avoid shallow clones (needed | |
| # for GitVersion) | |
| run: | | |
| git clone https://${{ secrets.PAT_ACTIONS_IGLIB_READONLY }}@github.com/ajgorhoe/IGLib.modules.IGLibScripting ` | |
| IGLibScripting1 | |
| # Print out tree view of the base directory, in order to verify that | |
| # all checkouts were performed correctly. Tune the depth and including | |
| # hidden files to get the information needed. | |
| - name: CHECK DIRECTORY STRUCTURE | |
| shell: pwsh | |
| run: | | |
| Write-Host "`n`nChecking directory structure...`n" | |
| Write-Host "Current directory: $(Get-Location)`n" | |
| Write-Host "Directory Contents:`n" | |
| ${{ env.REPO_DIR }}/scripts/ShowDirectoryTree.ps1 -Path . -MaxDepth 2 -IncludeHidden | |
| - name: SET UP .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| # INSTALL global DOTNET TOOLS | |
| - name: INSTALL global DOTNET TOOLS (GitVersion) | |
| run: | | |
| dotnet tool install --global GitVersion.Tool | |
| - name: Setup MSBuild for .NET Framework | |
| uses: microsoft/setup-msbuild@v1 # Needed for .NET Framework builds | |
| # RUN PRE-BUILD SCRIPT (PowerShell) | |
| - name: Run Pre-Build PowerShell Script | |
| run: pwsh -File ${{ env.REPO_DIR }}/scripts/PrintEnv.ps1 | |
| # Verify .NET SDK version and global tools to insure everything we need is installed: | |
| - name: VERIFY .NET SDK and global tools | |
| shell: pwsh | |
| run: | | |
| Write-Host "Checking .NET SDK version..." | |
| dotnet --version | |
| Write-Host "Listing global dotnet tools..." | |
| dotnet tool list --global | |
| # Verify that GitVersion works properly & printing the calculated version of the current commit: | |
| # Remark: malfunctioning of GitVersion (likely due to misconfiguration) is often a cause for | |
| # subsequent build to fail. | |
| - name: CHECK GitVersion | |
| shell: pwsh | |
| run: | | |
| Write-Host "Verifying GitVersion and printing version of the current commit..." | |
| cd ${{ env.REPO_DIR }} | |
| Write-Host "Directory for getting the version:`n $($(Get-Location).Path)" | |
| Write-Host "Running: 'dotnet gitversion /showvariable FullSemVer'" | |
| Write-Host "Repository VERSION returned by GitVersion:" | |
| dotnet gitversion /showvariable FullSemVer | |
| # RESTORE DEPENDENCIES | |
| - name: Restore NuGet packages | |
| shell: pwsh | |
| run: | | |
| Write-Host "Restoring NuGet packages for ${{ env.REPO_DIR }}/${{ env.REPO_DIR }}.sln ... `n" | |
| dotnet restore ${{ env.REPO_DIR }}/${{ env.REPO_DIR }}.sln | |
| # BUILD Main Project & Test Project in Release Mode | |
| - name: Build Solution | |
| shell: pwsh | |
| run: | | |
| Write-Host "Building solution: ${{ env.REPO_DIR }}/${{ env.REPO_DIR }}.sln ... `n" | |
| dotnet build ${{ env.REPO_DIR }}/${{ env.REPO_DIR }}.sln --configuration Release --no-restore | |
| # RUN TESTS & COLLECT RESULTS | |
| - name: Run Tests | |
| id: teststep | |
| # shell: pwsh | |
| # Remark: we use the solution instead of projects. | |
| shell: pwsh | |
| continue-on-error: true # ToDo: set to false later! | |
| run: | | |
| Write-Host "Running tests for ${{ env.REPO_DIR }}/${{ env.REPO_DIR }}.sln ... `n" | |
| dotnet test ${{ env.REPO_DIR }}/${{ env.REPO_DIR }}.sln --configuration Release --logger trx --results-directory TestResults | |
| # ${{ env.IGNORE_TEST_ERRORS }} | |
| - name: Upload test results | |
| if: always() # runs even if previous step failed | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| # Name of the uploaded artifact (arbitrary): | |
| name: TestResults | |
| # Path (relative to the workspace) of the file(s) or folder(s) to | |
| # upload as artifact: | |
| path: ./TestResults | |
| # Report tests failure | |
| - name: Report tests failure | |
| if: steps.teststep.outcome == 'failure' | |
| run: echo "⚠️ Some tests failed, but the pipeline will continue." | |
| # UPLOAD BUILD OUTPUT (DLLs, EXEs, etc.) | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: BuildArtifacts | |
| path: ${{ env.SOURCE_DIR }}/bin/Release/ | |
| # RUN a TEST SCRIPT (PowerShell) | |
| - name: Run Post-Build PowerShell Script | |
| run: pwsh -File ${{ env.REPO_DIR }}/scripts/PrintEnv.ps1 | |