Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST-1234 Add additional workflow files and vite frontend #16

Merged
merged 38 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b332f8c
TEST-1234 Update example.spec.ts
hwinther Apr 20, 2024
3445524
TEST-1234 Update playwright-env.yml
hwinther Apr 20, 2024
fbe0665
Add dotenv
hwinther May 3, 2024
3dd3ecc
Add frontend code and reusable workflow
hwinther May 3, 2024
925ad8e
Update action.yml
hwinther May 3, 2024
7984cac
Update action.yml
hwinther May 3, 2024
bedc361
Update action.yml
hwinther May 3, 2024
93a3de7
Add missing token
hwinther May 3, 2024
ed1bff7
Update action.yml
hwinther May 3, 2024
5913cc3
Update action.yml
hwinther May 3, 2024
65554e8
Update action.yml
hwinther May 3, 2024
6211170
Update action.yml
hwinther May 3, 2024
594ce84
Update action.yml
hwinther May 3, 2024
55b4a00
Change comment name
hwinther May 3, 2024
c667797
Remove component name
hwinther May 3, 2024
1afb022
Update action.yml
hwinther May 3, 2024
fbd9d18
Update action.yml
hwinther May 3, 2024
247532c
Update action.yml
hwinther May 3, 2024
729ac27
Update action.yml
hwinther May 3, 2024
16cbd7d
Update action.yml
hwinther May 3, 2024
e59efe5
Add warning
hwinther May 3, 2024
0bef136
Update dependabot
hwinther May 3, 2024
e5a6561
Add docker compose project and tests
hwinther May 3, 2024
015b2c9
Add action icons and missing properties
hwinther May 3, 2024
874be49
Fix backend issue after adding docker project
hwinther May 3, 2024
8e0d989
Add todo comments and dependabot docker scanning
hwinther May 3, 2024
941d74c
Update backend-ci.yml
hwinther May 3, 2024
fe744c0
Update action.yml
hwinther May 3, 2024
e7384e3
Fix ignore pattern
hwinther May 3, 2024
d8a2f9f
Update backend-ci.yml
hwinther May 3, 2024
a118ff4
Add permissions
hwinther May 3, 2024
7b90d47
Update backend-ci.yml
hwinther May 3, 2024
b3fbd2f
Update backend-ci.yml
hwinther May 3, 2024
56c8ab1
Update backend-ci.yml
hwinther May 3, 2024
d0ecc02
Update backend-ci.yml
hwinther May 3, 2024
7647539
Update backend-ci.yml
hwinther May 3, 2024
bdae467
Remove unused tests
hwinther May 3, 2024
0721037
Improve test coverage
hwinther May 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .github/actions/backend-deploy/action.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
name: "Backend deploy"
description: "Deploys backend component"
branding:
icon: server
color: black

inputs:
deploy_target:
required: true
type: string
description: prod|qa|test|dev
repo_name:
required: true
type: string
description: main|qa|test|dev (repo name defined separate because main maps to prod)
labels:
required: true
type: string
description: labels from conditions in trigger workflow
base_name:
required: true
type: string
description: basil|gsi|login|ext
project_type:
required: true
type: string
description: function|app
dockerfile_path:
required: true
type: string
description: path to dockerfile
docker_image_name:
required: true
type: string
description: docker image name
azure_resource_name:
required: true
type: string
description: azure resource name
skip_setup:
required: false
default: false
type: bool
default: "false"
description: if true skips setting up .net and nuget package restore

runs:
Expand Down
149 changes: 149 additions & 0 deletions .github/actions/frontend-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: "Frontend build"
description: "Frontend (node) build and linting"
branding:
icon: table
color: black

inputs:
working_directory:
required: true
description: root folder of the node project, e.g. ./src/frontend/
package_manager:
required: false
description: npm|yarn
default: "yarn"

runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
name: Setup node (npm)
if: inputs.working_directory == 'npm'
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: "${{ inputs.working_directory }}/package-lock.json"

- uses: actions/setup-node@v4
name: Setup node (yarn)
if: inputs.working_directory == 'yarn'
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: "${{ inputs.working_directory }}/yarn.lock"

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
echo "::group::Install dependencies"
[[ "${{ inputs.package_manager }}" == "npm" ]] && npm ci || true
[[ "${{ inputs.package_manager }}" == "yarn" ]] && yarn install --immutable --immutable-cache --check-cache || true
echo "::endgroup::"

- name: Build
id: node-build
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
echo "::group::Build"
[[ "${{ inputs.package_manager }}" == "npm" ]] && npm run build 1>build.out 2>&1 || (exit 0)
[[ "${{ inputs.package_manager }}" == "yarn" ]] && yarn build 1>build.out 2>&1 || (exit 0)
echo -e "\nBuild output:\n"
cat build.out

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<<EOF"$'\n'"$(cat build.md)"$'\n'EOF >> $GITHUB_OUTPUT
cat build.md >> $GITHUB_STEP_SUMMARY

if [ -s build.err ]
then
exit 1
fi
echo "::endgroup::"

- name: Lint
if: always()
id: node-lint
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
echo "::group::Lint"
[[ "${{ inputs.package_manager }}" == "npm" ]] && npm run lint -- -f compact 1>lint.out 2>&1 || (exit 0)
[[ "${{ inputs.package_manager }}" == "yarn" ]] && yarn lint -f compact 1>lint.out 2>&1 || (exit 0)
echo -e "\nLint output:\n"
cat lint.out

cat lint.out | grep ": line " | sed -e 's|${{ env.TRAILING_AGENT_WORK_PATH }}||' >lint.err || (exit 0)
if [ ! -s lint.err ]
then
echo "## βœ… No linting issues 🎊" > lint.md
else
# Reformat lint output as github error annotations
error_regex="(.+): line ([0-9]+), col [0-9]+, [A-Za-z]+ - (.+)"
cat lint.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 lint.err lint.md
sed -i '/^$/d' lint.md # removes empty lines
sed -i -e 's/^/- ❌ /' lint.md # prefix with markdown list item and cross mark emoji
echo "## ❌ The following linting issues should be fixed:" | cat - lint.md > lint.md.temp && mv lint.md.temp lint.md
fi

echo "result<<EOF"$'\n'"$(cat lint.md)"$'\n'EOF >> $GITHUB_OUTPUT
cat lint.md >> $GITHUB_STEP_SUMMARY

if [ -s lint.err ]
then
exit 1
fi
echo "::endgroup::"

- name: Combine outputs to single PR comment
if: always()
id: pr-comment-combiner
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
echo "# ${{ env.WORKFLOW_SHORT_NAME }}" > combined.md
cat build.md >> combined.md
cat lint.md >> combined.md
echo "result<<EOF"$'\n'"$(cat combined.md)"$'\n'EOF >> $GITHUB_OUTPUT

- name: "Create or Update PR Comment"
uses: im-open/[email protected]
if: always() && github.event_name == 'pull_request'
with:
github-token: ${{ env.GH_TOKEN }}
comment-identifier: "${{ env.WORKFLOW_SHORT_NAME }}-results"
comment-content: ${{ steps.pr-comment-combiner.outputs.result }}

- name: Create Todo Comments
uses: gkampitakis/github-action-todo-commenter@v1
with:
github-token: ${{ env.GH_TOKEN }}
review-message: "Please take a look :eyes:"
tags: "TODO:,FIXME:,BUG:"
10 changes: 5 additions & 5 deletions .github/actions/platform-deploy/action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: "Backend deploy"
name: "Platform deploy"
description: "Deploys platform component"
branding:
icon: layers
color: black

inputs:
deploy_target:
required: true
type: string
description: prod|qa|test|dev
working_directory:
required: true
type: string
description: root folder where the main terraform plan resides, e.g. ./templates/terraform/
config_path:
required: true
type: string
description: .conf file relative to working_directory
var_path:
required: true
type: string
description: .var file path relative to working_directory

runs:
Expand Down
33 changes: 33 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ updates:
assignees:
- "hwinther"

- package-ecosystem: "docker"
directory: "/"
open-pull-requests-limit: 20
target-branch: "dev"
schedule:
interval: "daily"
assignees:
- "hwinther"

- package-ecosystem: "nuget"
directory: "/src/backend"
open-pull-requests-limit: 20
Expand Down Expand Up @@ -54,3 +63,27 @@ updates:
- "@typescript-eslint/*"
- "*/eslint-plugin"
- "*/eslint-plugin-*"

- package-ecosystem: "npm"
directory: "/tests/playwright"
open-pull-requests-limit: 20
target-branch: "dev"
schedule:
interval: "weekly"
day: "sunday"
assignees:
- "hwinther"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
groups:
types:
patterns:
- "@types/*"
eslint:
patterns:
- "eslint"
- "eslint-*"
- "@typescript-eslint/*"
- "*/eslint-plugin"
- "*/eslint-plugin-*"
28 changes: 26 additions & 2 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ permissions:
contents: read
checks: write
pull-requests: write
actions: read # for super-linter
statuses: write # for super-linter

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
Expand All @@ -35,6 +37,7 @@ concurrency:
env:
DOTNET_VERSION: "8.0.x"
BACKEND_SOLUTION_PATH: "src/backend"
BACKEND_SOLUTION_FILE: "Backend.sln"
WORKFLOW_SHORT_NAME: "backend-ci"
WORKFLOW_AGENT_PATH: "/home/runner/work/test/test/"

Expand Down Expand Up @@ -63,15 +66,15 @@ jobs:
key: nuget-${{ hashFiles('**/packages.lock.json') }}

- name: dotnet restore
run: dotnet restore --locked-mode
run: dotnet restore --locked-mode ${{ env.BACKEND_SOLUTION_FILE }}

- name: dotnet tool restore
run: dotnet tool restore

- name: Build
id: dotnet-build
run: |
dotnet build -c Release --no-restore --nologo -consoleLoggerParameters:NoSummary -verbosity:quiet 1>build.out 2>&1 || (exit 0)
dotnet build ${{ env.BACKEND_SOLUTION_FILE }} -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 ]
Expand Down Expand Up @@ -110,6 +113,27 @@ jobs:
comment-identifier: "${{ env.WORKFLOW_SHORT_NAME }}-build-results"
comment-content: ${{ steps.dotnet-build.outputs.result }}

- name: Create Todo Comments
uses: gkampitakis/github-action-todo-commenter@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
review-message: "Please take a look :eyes:"
tags: "TODO:,FIXME:,BUG:"

# # TODO: move?
# - name: Super-linter
# uses: super-linter/[email protected]
# env:
# # To report GitHub Actions status checks
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# CREATE_LOG_FILE: true
# LOG_FILE: super-linter.out
# DISABLE_ERRORS: true

# - run: |
# ls -la ${{ env.WORKFLOW_AGENT_PATH }}
# sudo cat ${{ env.WORKFLOW_AGENT_PATH }}super-linter.out >> $GITHUB_STEP_SUMMARY

- name: WebApi Tests
run: dotnet test ../../tests/backend/WebApi.Tests --no-restore --collect:"XPlat Code Coverage" --logger "trx;LogFileName=test-results.trx" /p:CollectCoverage=true /p:CoverletOutput="../../tests/backend/WebApi.Tests/TestResults/" /p:CoverletOutputFormat=cobertura

Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Frontend CI"

on:
workflow_dispatch:
push:
branches:
- dev
tags:
- "v*"
paths:
- "src/frontend/**"
pull_request:
branches:
- main
- test
- dev
paths:
- "src/frontend/**"
- ".github/workflows/frontend-ci.yml"
types: [opened, reopened, labeled, synchronize, ready_for_review]

# Sets permissions of the GITHUB_TOKEN to allow creating checks and updating PR
permissions:
contents: read
checks: write
pull-requests: write

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

env:
NODE_VERSION: "20"
WORKFLOW_SHORT_NAME: "frontend"
FRONTEND_PATH: "src/frontend"
TRAILING_AGENT_WORK_PATH: "/home/runner/work/test/test/"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
defaults:
run:
working-directory: ${{ env.FRONTEND_PATH }}
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: ./.github/actions/frontend-build
with:
working_directory: ${{ env.FRONTEND_PATH }}
3 changes: 3 additions & 0 deletions .github/workflows/playwright-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- test
pull_request:
branches:
- main
- qa
- test
- dev
- "feature/*"
- "bugfix/*"
Expand Down
Loading
Loading