From 2f6cb3bd10262549ad1e513222fa48890bf681e9 Mon Sep 17 00:00:00 2001 From: LaBani Said Date: Thu, 28 Nov 2024 20:57:56 +0100 Subject: [PATCH] Rvert changes --- .github/workflows/build.cmd | 7 --- .github/workflows/build.ps1 | 81 ------------------------ .github/workflows/build.sh | 74 ---------------------- .github/workflows/build.yml | 119 ++++++----------------------------- .github/workflows/codeql.yml | 50 --------------- 5 files changed, 20 insertions(+), 311 deletions(-) delete mode 100644 .github/workflows/build.cmd delete mode 100644 .github/workflows/build.ps1 delete mode 100644 .github/workflows/build.sh delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/build.cmd b/.github/workflows/build.cmd deleted file mode 100644 index b08cc59..0000000 --- a/.github/workflows/build.cmd +++ /dev/null @@ -1,7 +0,0 @@ -:; set -eo pipefail -:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) -:; ${SCRIPT_DIR}/build.sh "$@" -:; exit $? - -@ECHO OFF -powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* diff --git a/.github/workflows/build.ps1 b/.github/workflows/build.ps1 deleted file mode 100644 index f21bd61..0000000 --- a/.github/workflows/build.ps1 +++ /dev/null @@ -1,81 +0,0 @@ -[CmdletBinding()] -Param( - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$BuildArguments -) - -Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" - -Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } -$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent - -########################################################################### -# CONFIGURATION -########################################################################### - -$BuildProjectFile = "$PSScriptRoot\build\_build.csproj" -$TempDirectory = "$PSScriptRoot\.nuke\temp" - -$DotNetGlobalFile = "$PSScriptRoot\global.json" -$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" -$DotNetChannel = "Current" - -$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 -$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 -$env:DOTNET_MULTILEVEL_LOOKUP = 0 -$env:DOTNET_ROLL_FORWARD = "Major" -$env:NUKE_TELEMETRY_OPTOUT = 1 -$env:DOTNET_CLI_UI_LANGUAGE = "en-US" - -########################################################################### -# EXECUTION -########################################################################### - -function ExecSafe([scriptblock] $cmd) { - & $cmd - if ($LASTEXITCODE) { exit $LASTEXITCODE } -} - -# Print environment variables -# WARNING: Make sure that secrets are actually scrambled in build log -# Get-Item -Path Env:* | Sort-Object -Property Name | ForEach-Object {"{0}={1}" -f $_.Name,$_.Value} - -# Check if any dotnet is installed -if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue)) { - ExecSafe { & dotnet --info } -} - -# If dotnet CLI is installed globally and it matches requested version, use for execution -if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` - $(dotnet --version) -and $LASTEXITCODE -eq 0) { - $env:DOTNET_EXE = (Get-Command "dotnet").Path -} -else { - # Download install script - $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" - New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) - - # If global.json exists, load expected version - if (Test-Path $DotNetGlobalFile) { - $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) - if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { - $DotNetVersion = $DotNetGlobal.sdk.version - } - } - - # Install by channel or version - $DotNetDirectory = "$TempDirectory\dotnet-win" - if (!(Test-Path variable:DotNetVersion)) { - ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } - } else { - ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } - } - $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" -} - -Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" - -ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary } -ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh deleted file mode 100644 index d691404..0000000 --- a/.github/workflows/build.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash - -bash --version 2>&1 | head -n 1 - -set -eo pipefail -SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) - -########################################################################### -# CONFIGURATION -########################################################################### - -BUILD_PROJECT_FILE="$SCRIPT_DIR/Build/_build.csproj" -TEMP_DIRECTORY="$SCRIPT_DIR/.nuke/temp" - -DOTNET_GLOBAL_FILE="$SCRIPT_DIR/global.json" -DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" -DOTNET_CHANNEL="Current" - -export DOTNET_CLI_TELEMETRY_OPTOUT=1 -export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -export DOTNET_MULTILEVEL_LOOKUP=0 -export DOTNET_ROLL_FORWARD="Major" -export NUKE_TELEMETRY_OPTOUT=1 -export DOTNET_CLI_UI_LANGUAGE="en-US" - -########################################################################### -# EXECUTION -########################################################################### - -function FirstJsonValue { - perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" -} - -# Print environment variables -# WARNING: Make sure that secrets are actually scrambled in build log -# env | sort - -# Check if any dotnet is installed -if [[ -x "$(command -v dotnet)" ]]; then - dotnet --info -fi - -# If dotnet CLI is installed globally and it matches requested version, use for execution -if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then - export DOTNET_EXE="$(command -v dotnet)" -else - # Download install script - DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" - mkdir -p "$TEMP_DIRECTORY" - curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" - chmod +x "$DOTNET_INSTALL_FILE" - - # If global.json exists, load expected version - if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then - DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") - if [[ "$DOTNET_VERSION" == "" ]]; then - unset DOTNET_VERSION - fi - fi - - # Install by channel or version - DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" - if [[ -z ${DOTNET_VERSION+x} ]]; then - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path - else - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path - fi - export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" -fi - -echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" - -"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary -"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 232e413..4d831a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,111 +1,32 @@ -name: Build +name: Build & Test -on: [push, pull_request] +on: + workflow_call: + inputs: + dotnet-version: + type: string + required: true + default: 8.0.x jobs: build: - name: "Build, Test, Analyze and Publish" - runs-on: windows-latest - env: - DOTNET_NOLOGO: true - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup .NET SDKs - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 7.0.x - 8.0.x - - - name: Cache .nuke/temp - uses: actions/cache@v4 - with: - path: | - .nuke/temp - key: ${{ runner.os }}-${{ hashFiles('NodeVersion') }} - - - name: Run NUKE - run: ./build.ps1 - env: - NuGetApiKey: ${{ secrets.NUGETAPIKEY }} - - - name: Check for 'lcov.info' existence - id: check_files - uses: andstor/file-existence-action@v3 - with: - files: "TestResults/reports/lcov.info" - - - name: coveralls - uses: coverallsapp/github-action@v2 - if: steps.check_files.outputs.files_exists == 'true' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - file: TestResults/reports/lcov.info - - - name: Upload artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: windows-artifacts - path: | - ./Artifacts/* - ./TestResults/*.trx - - only-unit-tests: - name: "Run Unit Tests Only" - strategy: - matrix: - os: [ubuntu-24.04, macos-15] - - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Chceckout code + uses: actions/checkout@v4 - - name: Setup .NET SDKs + - name: Setup .NET uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 7.0.x - 8.0.x + with: + dotnet-version: ${{ inputs.dotnet-version }} - - name: Run NUKE - run: ./build.sh UnitTests + - name: Restore dependencies + run: dotnet restore - - name: Upload artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: ${{ runner.os }}-artifacts - path: | - ./TestResults/*.trx - - publish-test-results: - name: "Publish Tests Results" - needs: [ build, only-unit-tests ] - runs-on: ubuntu-latest - permissions: - checks: write - pull-requests: write - if: always() - - steps: - - name: Download Artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts + - name: Build code + run: dotnet build --no-restore - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - comment_mode: always - files: "artifacts/**/**/*.trx" + - name: Test code + run: dotnet test --no-build --verbosity normal \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 6148f34..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ "develop", "main" ] - pull_request: - branches: [ "develop", "main" ] - schedule: - - cron: '00 15 * * 1' - -jobs: - analyze: - name: Analyze - runs-on: 'ubuntu-latest' - timeout-minutes: 360 - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'csharp' ] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - name: Build - run: | - dotnet restore FluentAssertions.sln --configfile nuget.config - dotnet build FluentAssertions.sln --configuration CI --no-restore - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}"