Skip to content

Commit

Permalink
TEST-1234 Add backend ci (#9)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description 💬
<!--- Describe your changes in detail -->

## Motivation and Context 🥅
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How has this been tested? 🧪
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how
-->
<!--- your change affects other areas of the code, etc. -->
- [x] Local build ⚒️
- [ ] Local tests 🧪
- [ ] (optional) Local run and endpoint tested in swagger 🚀

## Screenshots (if appropriate) 💻

## Types of changes 🌊
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)

## Checklist ☑️

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [x] The pull request title starts with the jira case number (when
applicable), e.g. "TEST-1234 Add some feature"
- [x] The person responsible for following up on requested review
changes has been assigned to the pull request
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.

## Highly optional checks, only use these if you have a reason to do so
✔️

- [ ] This PR changes the database so I have added the *create-diagram*
label to assist reviewers with a db diagram
- [ ] This PR changes platform or backend and I need others to be able
to test against these changes before merging to dev, so I have added the
*deploy-azure* label to deploy before merging the PR

## Checklist for the approver ✅

- [ ] I've checked the files view for spelling issues, code quality
warnings and similar
- [ ] I've waited until all checks have passed (green check/without
error)
- [ ] I've checked that only the intended files are changed
  • Loading branch information
hwinther authored Apr 19, 2024
1 parent 6b82d78 commit 127b0d6
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 34 deletions.
58 changes: 55 additions & 3 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Backend CI - placeholder"
name: "Backend CI"

on:
workflow_dispatch:
Expand Down Expand Up @@ -35,6 +35,8 @@ concurrency:
env:
DOTNET_VERSION: "8.0.x"
BACKEND_SOLUTION_PATH: "src/backend"
WORKFLOW_SHORT_NAME: "backend-ci"
WORKFLOW_AGENT_PATH: "/home/runner/work/test/test/"

jobs:
build:
Expand Down Expand Up @@ -63,5 +65,55 @@ 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: |
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 (.+) \[(.+)\]"
# 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[4]}"
fi
done
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
fi
echo "result<<EOF"$'\n'"$(cat build.md)"$'\n'EOF >> $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/[email protected]
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
if: always()
with:
workingDirectory: ${{ env.BACKEND_SOLUTION_PATH }}
solutionPath: Backend.sln
dotnetVersion: ${{ env.DOTNET_VERSION }}
failOnIssue: false
include: |
**.cs
62 changes: 31 additions & 31 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF"$'\n'"$(cat npm-npm.md)"$'\n'EOF >> $GITHUB_OUTPUT
cat npm-npm.md >> $GITHUB_STEP_SUMMARY
echo "result<<EOF"$'\n'"$(cat build.md)"$'\n'EOF >> $GITHUB_OUTPUT
cat build.md >> $GITHUB_STEP_SUMMARY
if [ -s npm-npm.err ]
if [ -s build.err ]
then
exit 1
fi
Expand Down Expand Up @@ -203,25 +203,25 @@ jobs:
job-summary: true
icon-style: "emojis"

- name: Convert markdown to slack format
uses: denis-trofimov/[email protected]
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/[email protected]
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/[email protected]
# 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/[email protected]
# 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()
Expand Down
12 changes: 12 additions & 0 deletions src/backend/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.4",
"commands": [
"dotnet-ef"
]
}
}
}

0 comments on commit 127b0d6

Please sign in to comment.