From a1ad8a50c03da40e44b7d52a508f4dc8900458ab Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sun, 16 Oct 2022 17:55:08 +0200 Subject: [PATCH 1/6] Initial build workflow setup --- .github/workflows/build.yml | 118 ++++++++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 119 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..cafcff750 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,118 @@ +name: Build + +on: + push: + paths-ignore: + - '*.md' + - '*.txt' + - '.editorconfig' + - lic/* + branches: + - master + pull_request: + workflow_dispatch: + +env: + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + SKIP_TEST_BUILD: true + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022, ubuntu-22.04, macos-11] + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: '14' + + - name: Install ECLint + run: npm install -g eclint + + - name: Delete EditorConfig file + run: git rm .editorconfig + + - name: Check Final New-Line + run: eclint check -n "**/*.{cs,tt,cmd,sh,md,txt,yml}" + + - name: Check Trailing Whitespace + run: eclint check -w "**/*.{cs,tt,cmd,sh,md,txt,yml,json,sln,csproj,shfbproj}" + + - name: Restore Checkout + run: git reset --hard + + - name: Setup .NET SDK per "global.json" + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + + - name: Setup .NET SDK 7.0 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + + - name: Setup .NET SDK 6.0 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + + - name: .NET Information + run: dotnet --info + + - name: Check Unit Tests Never Import "System.Linq" + shell: pwsh + run: | + grep --extended-regexp '^[[:space:]]*using[[:space:]]+System\.Linq;' (dir -Recurse -File -Filter *Test.cs MoreLinq.Test) + if ($LASTEXITCODE -eq 0) { + throw 'Unit tests should not import System.Linq' + } else { + $LASTEXITCODE = 0 + } + + - name: Build & Pack (Windows) + shell: cmd + if: runner.os == 'Windows' + run: call pack.cmd + + - name: Build & Pack (Linux/macOS) + if: runner.os != 'Windows' + run: ./pack.sh + + - name: Check Uncommitted Changes + shell: pwsh + run: | + $diff = git diff --ignore-all-space --exit-code 2>&1 + $diff | % { if ($_ -is [string]) { $_ } else { [string]$_ } } | echo + if ($LASTEXITCODE -ne 0) { + throw "New code was generated during build that's not been committed." + } + + - name: Validate NuGet Packages + shell: pwsh + run: | + dir dist\*.nupkg | % { + dotnet meziantou.validate-nuget-package --excluded-rules IconMustBeSet $_ + if ($LASTEXITCODE) { + throw "Package validation failed: $_" + } + } + + - name: Test (Windows) + shell: cmd + if: runner.os == 'Windows' + run: call test.cmd + + - name: Test (Linux/macOS) + if: runner.os != 'Windows' + run: ./test.sh + + - name: Publish Coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index 68976a434..0ea80d0b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.opencover.xml **/TestResults/ +.actrc ### VisualStudio ### ## Ignore Visual Studio temporary files, build results, and From 60675e519af293c65844c5b2529eaf61f3613956 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 20 Jan 2024 16:47:47 +0100 Subject: [PATCH 2/6] Skip building on AppVeyor if GitHub Actions workflow changes --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 98a25c24b..77148f19f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,6 +7,9 @@ environment: DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true SKIP_TEST_BUILD: true +skip_commits: + files: + - .github/* for: - matrix: From cbb72787270faba2cc7e9ed2c5d952e7e1967256 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 20 Jan 2024 16:51:16 +0100 Subject: [PATCH 3/6] Fix ignored paths --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cafcff750..24d83c2f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,6 @@ on: paths-ignore: - '*.md' - '*.txt' - - '.editorconfig' - - lic/* branches: - master pull_request: From 920bec4255c97862c79c9e8a21f993864d80f939 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 20 Jan 2024 16:55:02 +0100 Subject: [PATCH 4/6] Configure concurrency for cancellation --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24d83c2f3..02aaa2930 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,10 @@ on: pull_request: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true From a3deae822e45ffad5d165ea913e61ded61792426 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 20 Jan 2024 16:59:03 +0100 Subject: [PATCH 5/6] Set trigger for PR activity types --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02aaa2930..105aa1427 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ on: branches: - master pull_request: + types: [opened, reopened, synchronize] workflow_dispatch: concurrency: From 7f04882da300cc9f393e19e1f5209cd39f6d8df1 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 20 Jan 2024 17:00:44 +0100 Subject: [PATCH 6/6] Fix files filter --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 77148f19f..407dd2f0a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ environment: SKIP_TEST_BUILD: true skip_commits: files: - - .github/* + - .github/** for: - matrix: