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 #3

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "0.2",
"language": "en",
"words": [
"githubusercontent",
"commitlint",
"EDITMSG",
"codespell"
]
}
29 changes: 29 additions & 0 deletions .github/hooks/todo-warning.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

ORANGE='\033[0;33m'
NC='\033[0m'
BOLD='\033[1m'
NORMAL='\033[0m'


echo $GIT_COMMIT

check_file() {
local file=$1
local match_pattern=$2

local file_changes_with_context=$(git diff -U999999999 -p --cached --color=always -- $file)
local matched_additions=$(echo "$file_changes_with_context" | grep -C4 $'^\e\\[32m\+.*'"$match_pattern")

if [ -n "$matched_additions" ]; then
echo -e "${ORANGE}[WARNING]${NC} ${BOLD}$file${NORMAL} contains some $match_pattern."
echo "$matched_additions"
echo -e "\n"
fi
}


for file in `git diff --cached -p --name-status | cut -c3-`; do
check_file $file 'TODO'
done
exit
72 changes: 72 additions & 0 deletions .github/workflows/validate-pr-title.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Validate PR Title
on:
pull_request:
types: [opened, edited, synchronize]
permissions:
pull-requests: write
contents: read
jobs:
lint:
name: 'Lint'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Install Commitlint and CSpell
run: npm install --save-dev @commitlint/{config-conventional,cli} cspell
- run: echo "${{ github.event.pull_request.title }}" > pr-title.txt
- name: Run Commitlint
id: commitlint
run: npx commitlint --edit pr-title.txt > commitlint_output.txt 2>&1
if: always()
- name: Run CSpell
id: cspell
run: npx cspell --config .cspell.json pr-title.txt > cspell_output.txt 2>&1
if: always()
- name: Delete Old Bot Comments
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch all comments on the PR
COMMENTS=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments --jq '.[] | select(.user.login == "github-actions[bot]") | .id')

# Delete comments authored by the bot
for COMMENT_ID in $COMMENTS; do
gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID -X DELETE
done
- name: Post PR Comment
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Initialize status messages
STATUS_COMMITLINT="PASSED"
STATUS_CSPELL="PASSED"
COMMITLINT_OUTPUT=$(cat commitlint_output.txt)
CSPELL_OUTPUT=$(cat cspell_output.txt)
COMMENT_BODY="### Found Issues In PR Title\n"

if [ "${{ steps.commitlint.outcome }}" == "failure" ]; then
STATUS_COMMITLINT="FAILED"
fi

if [ "${{ steps.cspell.outcome }}" == "failure" ]; then
STATUS_CSPELL="FAILED"
fi

if [ "$STATUS_COMMITLINT" == "FAILED" ]; then
COMMENT_BODY+="**❌ Conventional Commit Format**\n"
COMMENT_BODY+="\n\`\`\`\n$COMMITLINT_OUTPUT\n\`\`\`\n"
fi
if [ "$STATUS_CSPELL" == "FAILED" ]; then
COMMENT_BODY+="**❌ Spelling Error**\n"
COMMENT_BODY+="\n\`\`\`\n$CSPELL_OUTPUT\n\`\`\`\n"
COMMENT_BODY+="\n> If you believe the spelling error is a false positive, please add the word in **cspell.json** file.\n"
fi

if [ "$STATUS_COMMITLINT" == "FAILED" ] || [ "$STATUS_CSPELL" == "FAILED" ]; then
# Post the comment
echo -e "$COMMENT_BODY" | gh pr comment ${{ github.event.pull_request.number }} --body-file -
fi
32 changes: 30 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,38 @@ repos:
- id: check-toml
- id: check-yaml


- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- id: ruff-format

- repo: local
hooks:
- id: commitlint
name: check commit message format
entry: npx commitlint --edit .git/COMMIT_EDITMSG
language: system
stages: [commit-msg]
always_run: true

- id: cspell-commit-msg
name: check commit message spelling
entry: npx cspell --config .cspell.json .git/COMMIT_EDITMSG
language: system
stages: [commit-msg]
always_run: true

- id: cspell-modified-files
name: check spelling of files
entry: sh -c "npx cspell --config .cspell.json `git diff --cached -p --name-status | cut -c3- | tr '\n' ' '`"
language: system
stages: [pre-commit]

- id: todo-warning
name: check todos
entry: .github/hooks/todo-warning.sh
language: script
stages: [pre-commit]
verbose: true
28 changes: 7 additions & 21 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
module.exports = {
parserPreset: 'conventional-changelog-conventionalcommits',
extends: ['@commitlint/config-conventional'],
rules: {
'subject-empty': [2, 'never'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
],
],
'header-max-length': [2, 'always', 72],
'subject-case': [2, 'always', 'sentence-case'],
'scope-case': [2, 'always', 'kebab-case'],
'body-case': [2, 'always', 'sentence-case'],
'body-leading-blank': [2, 'always'],
'footer-leading-blank': [2, 'always'],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div class="flex h-60 flex-col items-center justify-center gap-1">
<p class="text-base text-gray-700">
Performance Schema is not enabled on database server
</p>
<p class="text-base text-gray-700">
Please reach out to
<a href="https://support.frappe.io/" target="_blank" class="underline"
>support</a
>
to enable it
</p>
</div>
</template>
<script>
export default {
name: 'DatabasePerformanceSchemaDisabledNotice'
};
</script>
82 changes: 53 additions & 29 deletions dashboard/src2/components/site/performance/SiteDeadlockReport.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<PerformanceReport :site="name" :reportOptions="deadlockReportOptions" />
<PerformanceReport
title="Query Deadlocks"
:site="name"
:reportOptions="deadlockReportOptions"
/>
</template>

<script>
Expand All @@ -14,9 +18,9 @@ export default {
},
data() {
return {
today: dayjs().format('YYYY-MM-DD HH:mm:ss'),
yesterday: dayjs().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'),
max_lines: 20
start_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
stop_datetime: dayjs().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'),
max_log_size: 500
};
},
computed: {
Expand All @@ -26,20 +30,34 @@ export default {
return {
url: 'press.api.analytics.deadlock_report',
makeParams: params => {
// need to return params if it exists for filterControls to work
// for filterControls to work
if (params) return params;

return {
site: this.name,
start: this.yesterday,
end: this.today,
max_lines: this.max_lines
name: this.name,
start_datetime: this.start_datetime,
stop_datetime: this.stop_datetime,
max_log_size: parseInt(this.max_log_size ?? '')
};
},
auto: true,
initialData: []
initialData: [],
transform: data => {
return data.map(record => {
// Handle null values
// because some records can be empty as well, to keep a blank line after two deadlock records
record.timestamp = record.timestamp
? this.$format.date(record.timestamp, 'YYYY-MM-DD HH:mm:ss')
: '';
record.transaction_id = record.transaction_id || '';
record.table = record.table || '';
record.query = record.query || '';
return record;
});
}
};
},
emptyStateMessage: 'No query deadlock records found',
columns: [
{
label: 'Timestamp',
Expand All @@ -49,37 +67,43 @@ export default {
return this.$format.date(value, 'YYYY-MM-DD HH:mm:ss');
}
},
{ label: 'Query', fieldname: 'query', class: 'font-mono' }
{
label: 'Txn ID',
fieldname: 'transaction_id',
align: 'left',
width: '100px'
},
{
label: 'Table',
fieldname: 'table',
class: 'text-gray-600',
align: 'left',
width: '200px'
},
{
label: 'Query',
fieldname: 'query',
class: 'font-mono'
}
],
actions: () => {
return [
{
label: 'Back',
icon: 'arrow-left',
onClick: () => {
this.$router.push({ name: 'Site Detail Performance' });
}
}
];
},
filterControls: () => {
return [
{
type: 'datetime-local',
label: 'Start Time',
fieldname: 'start',
default: this.yesterday
fieldname: 'start_datetime',
default: this.start_datetime
},
{
type: 'datetime-local',
label: 'End Time',
fieldname: 'end',
default: this.today
fieldname: 'stop_datetime',
default: this.stop_datetime
},
{
label: 'Max Lines',
fieldname: 'max_lines',
default: this.max_lines
label: 'Max Log Lines',
fieldname: 'max_log_size',
default: this.max_log_size
}
];
}
Expand Down
10 changes: 5 additions & 5 deletions dashboard/src2/components/site/performance/SitePerformance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export default {
description:
'Identify and optimize slow-running database queries to improve performance.',
route: 'Site Performance Slow Queries'
},
{
title: 'Deadlock Report',
description: 'Shows database conflicts that block transactions.',
route: 'Site Performance Deadlock Report'
}
// {
// title: 'Deadlock Report',
// description: 'Shows database conflicts that block transactions.',
// route: 'Site Performance Deadlock Report'
// }
],
columns: [
{
Expand Down
Loading
Loading