From 48850463f5eef54e276e0ef3c1d00b405e2d20a4 Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 22:49:47 +0200 Subject: [PATCH 01/10] TEST-1234 Add build issue --- src/backend/WebApi/Controllers/WeatherForecastController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/WebApi/Controllers/WeatherForecastController.cs b/src/backend/WebApi/Controllers/WeatherForecastController.cs index 5f75962d..03a31343 100644 --- a/src/backend/WebApi/Controllers/WeatherForecastController.cs +++ b/src/backend/WebApi/Controllers/WeatherForecastController.cs @@ -24,6 +24,8 @@ public IEnumerable Get() { logger.LogInformation("GetWeatherForecast was called"); + var i = 0; + return Enumerable.Range(1, 5) .Select(static index => new WeatherForecast { From e44d76398776c129ea27bdf20e0d8e080b11aea2 Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 22:50:03 +0200 Subject: [PATCH 02/10] TEST-1234 Add backend linting --- .github/workflows/backend-ci.yml | 49 ++++++++++++++++++++++++++++++++ .github/workflows/playwright.yml | 24 ++++++++-------- 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 6bd880b9..619b48dc 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -35,6 +35,7 @@ concurrency: env: DOTNET_VERSION: "8.0.x" BACKEND_SOLUTION_PATH: "src/backend" + WORKFLOW_SHORT_NAME: "backend-ci" jobs: build: @@ -65,3 +66,51 @@ jobs: - name: dotnet build run: dotnet build -c Release --no-restore + + - name: Build + id: npm-build + run: | + dotnet build -c Release --no-restore --nologo -consoleLoggerParameters:NoSummary -verbosity:quiet 1>build.out 2>&1 || (exit 0) + grep "): error " build.out > build.err || (exit 0) + + if [ ! -s build.err ] + then + echo "## ✅ Build successful" > build.md + else + # Reformat error output as github error annotations + error_regex="(.+)\(([0-9]+),[0-9]+\): error (.+)" + cat build.err | while read line + do + if [[ $line =~ $error_regex ]]; then + echo "::error file=${BASH_REMATCH[1]},line=${BASH_REMATCH[2]}::${BASH_REMATCH[3]}" + fi + done + + cp build.err build.md + sed -i '/^$/d' build.md # removes empty lines + sed -i -e 's/^/- ❌ /' build.md # prefix with markdown list item and cross mark emoji + echo "## ❌ The following build issues should be fixed:" | cat - build.md > build.md.temp && mv build.md.temp build.md + fi + + echo "result<> $GITHUB_OUTPUT + cat build.md >> $GITHUB_STEP_SUMMARY + + if [ -s build.err ] + then + exit 1 + fi + + - name: "Create or Update PR Comment" + uses: im-open/update-pr-comment@v1.2.2 + if: ${{ always() && github.event_name == 'pull_request' }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + comment-identifier: "${{ env.WORKFLOW_SHORT_NAME }}-build-results" + comment-content: ${{ steps.npm-build.outputs.result }} + + # - name: Inspect code + # uses: muno92/resharper_inspectcode@v1 + # with: + # solutionPath: ${{ env.BACKEND_SOLUTION_PATH }} + # include: | + # **.cs diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 0ea450c8..e2857e13 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -60,32 +60,32 @@ jobs: - name: Build id: npm-build run: | - npm run build 1>npm-npm.out 2>&1 || (exit 0) - grep "): error " npm-npm.out > npm-npm.err || (exit 0) + npm run build 1>build.out 2>&1 || (exit 0) + grep "): error " build.out > build.err || (exit 0) - if [ ! -s npm-npm.err ] + if [ ! -s build.err ] then - echo "## ✅ Build successful" > npm-npm.md + echo "## ✅ Build successful" > build.md else # Reformat error output as github error annotations error_regex="(.+)\(([0-9]+),[0-9]+\): error (.+)" - cat npm-npm.err | while read line + cat build.err | while read line do if [[ $line =~ $error_regex ]]; then echo "::error file=${BASH_REMATCH[1]},line=${BASH_REMATCH[2]}::${BASH_REMATCH[3]}" fi done - cp npm-npm.err npm-npm.md - sed -i '/^$/d' npm-npm.md # removes empty lines - sed -i -e 's/^/- ❌ /' npm-npm.md # prefix with markdown list item and cross mark emoji - echo "## ❌ The following build issues should be fixed:" | cat - npm-npm.md > npm-npm.md.temp && mv npm-npm.md.temp npm-npm.md + cp build.err build.md + sed -i '/^$/d' build.md # removes empty lines + sed -i -e 's/^/- ❌ /' build.md # prefix with markdown list item and cross mark emoji + echo "## ❌ The following build issues should be fixed:" | cat - build.md > build.md.temp && mv build.md.temp build.md fi - echo "result<> $GITHUB_OUTPUT - cat npm-npm.md >> $GITHUB_STEP_SUMMARY + echo "result<> $GITHUB_OUTPUT + cat build.md >> $GITHUB_STEP_SUMMARY - if [ -s npm-npm.err ] + if [ -s build.err ] then exit 1 fi From 1236242935fc291a50dd6b88f77a1c16001a18be Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 22:53:38 +0200 Subject: [PATCH 03/10] TEST-1234 Add tools file --- .github/workflows/backend-ci.yml | 3 --- src/backend/.config/dotnet-tools.json | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 src/backend/.config/dotnet-tools.json diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 619b48dc..e2eee79e 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -64,9 +64,6 @@ jobs: - name: dotnet restore run: dotnet restore --locked-mode - - name: dotnet build - run: dotnet build -c Release --no-restore - - name: Build id: npm-build run: | diff --git a/src/backend/.config/dotnet-tools.json b/src/backend/.config/dotnet-tools.json new file mode 100644 index 00000000..677ed3f7 --- /dev/null +++ b/src/backend/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "8.0.4", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file From 51cd63a149e73cde3af4cf2a282a260c473fe7b6 Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 23:07:52 +0200 Subject: [PATCH 04/10] TEST-1234 Fix regex --- .github/workflows/backend-ci.yml | 6 +++-- .github/workflows/playwright.yml | 38 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index e2eee79e..5c03c3fd 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -36,6 +36,7 @@ env: DOTNET_VERSION: "8.0.x" BACKEND_SOLUTION_PATH: "src/backend" WORKFLOW_SHORT_NAME: "backend-ci" + WORKFLOW_AGENT_PATH: "TODO" jobs: build: @@ -75,11 +76,12 @@ jobs: echo "## ✅ Build successful" > build.md else # Reformat error output as github error annotations - error_regex="(.+)\(([0-9]+),[0-9]+\): error (.+)" + error_regex="(.+)\(([0-9]+),([0-9]+)\): error (.+) \[(.+)\]" + # Capture groups: 1=file path 2=line 3=character 4=warn: message 5=project path cat build.err | while read line do if [[ $line =~ $error_regex ]]; then - echo "::error file=${BASH_REMATCH[1]},line=${BASH_REMATCH[2]}::${BASH_REMATCH[3]}" + echo "::error file=${BASH_REMATCH[1]},line=${BASH_REMATCH[2]}::${BASH_REMATCH[4]}" fi done diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index e2857e13..46ed93fe 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -203,25 +203,25 @@ jobs: job-summary: true icon-style: "emojis" - - name: Convert markdown to slack format - uses: denis-trofimov/slackify-markdown-action@v1.0.0 - if: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target' || github.event_name == 'push') && always() }} - id: slackify-markdown - with: - text: ${{ steps.playwright-report-summary.outputs.summary }} - - - name: Send custom JSON data to Slack workflow - if: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target' || github.event_name == 'push') && always() }} - id: slack - uses: slackapi/slack-github-action@v1.25.0 - with: - payload: | - { - "message": "${{ steps.slackify-markdown.outputs.text }}", - "deploy_target": "${{ inputs.deploy_target }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + # - name: Convert markdown to slack format + # uses: denis-trofimov/slackify-markdown-action@v1.0.0 + # if: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target' || github.event_name == 'push') && always() }} + # id: slackify-markdown + # with: + # text: ${{ steps.playwright-report-summary.outputs.summary }} + + # - name: Send custom JSON data to Slack workflow + # if: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target' || github.event_name == 'push') && always() }} + # id: slack + # uses: slackapi/slack-github-action@v1.25.0 + # with: + # payload: | + # { + # "message": "${{ steps.slackify-markdown.outputs.text }}", + # "deploy_target": "${{ inputs.deploy_target }}" + # } + # env: + # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - uses: actions/upload-artifact@v4 if: always() From 82584230f191d20ab95f0a63e473ce49ed4c1499 Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 23:12:08 +0200 Subject: [PATCH 05/10] TEST-1234 Add inspection --- .github/workflows/backend-ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 5c03c3fd..261f4dda 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -107,9 +107,11 @@ jobs: comment-identifier: "${{ env.WORKFLOW_SHORT_NAME }}-build-results" comment-content: ${{ steps.npm-build.outputs.result }} - # - name: Inspect code - # uses: muno92/resharper_inspectcode@v1 - # with: - # solutionPath: ${{ env.BACKEND_SOLUTION_PATH }} - # include: | - # **.cs + - name: Inspect code + uses: muno92/resharper_inspectcode@v1 + if: always() + with: + solutionPath: ${{ env.BACKEND_SOLUTION_PATH }} + dotnetVersion: ${{ env.DOTNET_VERSION }} + include: | + **.cs From 832b7b5226468a2814c09c4716e86989c05bcc05 Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 23:17:29 +0200 Subject: [PATCH 06/10] TEST-1234 Fix relative path in pr comment --- .github/workflows/backend-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 261f4dda..02428b8c 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -36,7 +36,7 @@ env: DOTNET_VERSION: "8.0.x" BACKEND_SOLUTION_PATH: "src/backend" WORKFLOW_SHORT_NAME: "backend-ci" - WORKFLOW_AGENT_PATH: "TODO" + WORKFLOW_AGENT_PATH: "/home/runner/work/test/test/" jobs: build: @@ -85,7 +85,7 @@ jobs: fi done - cp build.err build.md + cat build.err | sed 's|${{ env.WORKFLOW_AGENT_PATH }}||' ; 's|${{ env.WORKFLOW_AGENT_PATH }}||' > build.md sed -i '/^$/d' build.md # removes empty lines sed -i -e 's/^/- ❌ /' build.md # prefix with markdown list item and cross mark emoji echo "## ❌ The following build issues should be fixed:" | cat - build.md > build.md.temp && mv build.md.temp build.md From 2b8ec79a78ecc27f33a52fb81b9421c9d1c943cc Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 23:19:00 +0200 Subject: [PATCH 07/10] TEST-1234 Fix replacement --- .github/workflows/backend-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 02428b8c..7fb61811 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -85,7 +85,7 @@ jobs: fi done - cat build.err | sed 's|${{ env.WORKFLOW_AGENT_PATH }}||' ; 's|${{ env.WORKFLOW_AGENT_PATH }}||' > build.md + cat build.err | sed 's|${{ env.WORKFLOW_AGENT_PATH }}|| ; s|${{ env.WORKFLOW_AGENT_PATH }}||' > build.md sed -i '/^$/d' build.md # removes empty lines sed -i -e 's/^/- ❌ /' build.md # prefix with markdown list item and cross mark emoji echo "## ❌ The following build issues should be fixed:" | cat - build.md > build.md.temp && mv build.md.temp build.md From 3fdd61eff62e8c7fa19c216825cb3c6b4655dcaa Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 23:22:05 +0200 Subject: [PATCH 08/10] TEST-1234 Fix inspection path --- .github/workflows/backend-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 7fb61811..af08a0c9 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -1,4 +1,4 @@ -name: "Backend CI - placeholder" +name: "Backend CI" on: workflow_dispatch: @@ -111,7 +111,8 @@ jobs: uses: muno92/resharper_inspectcode@v1 if: always() with: - solutionPath: ${{ env.BACKEND_SOLUTION_PATH }} + workingDirectory: ${{ env.BACKEND_SOLUTION_PATH }} + solutionPath: Backend.sln dotnetVersion: ${{ env.DOTNET_VERSION }} include: | **.cs From 4001e2f539d77e55e8cd0617ed0aca2dcc7f6975 Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 23:25:14 +0200 Subject: [PATCH 09/10] TEST-1234 Fix error --- src/backend/WebApi/Controllers/WeatherForecastController.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/backend/WebApi/Controllers/WeatherForecastController.cs b/src/backend/WebApi/Controllers/WeatherForecastController.cs index 03a31343..5f75962d 100644 --- a/src/backend/WebApi/Controllers/WeatherForecastController.cs +++ b/src/backend/WebApi/Controllers/WeatherForecastController.cs @@ -24,8 +24,6 @@ public IEnumerable Get() { logger.LogInformation("GetWeatherForecast was called"); - var i = 0; - return Enumerable.Range(1, 5) .Select(static index => new WeatherForecast { From a19155907bb4becd072ddc0b458845d7377796f4 Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Fri, 19 Apr 2024 23:27:01 +0200 Subject: [PATCH 10/10] TEST-1234 Add no fail to code inspection --- .github/workflows/backend-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index af08a0c9..deb55c84 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -114,5 +114,6 @@ jobs: workingDirectory: ${{ env.BACKEND_SOLUTION_PATH }} solutionPath: Backend.sln dotnetVersion: ${{ env.DOTNET_VERSION }} + failOnIssue: false include: | **.cs