diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 0000000..e134121 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,38 @@ +language: en-US +reviews: + profile: chill + poem: false + path_filters: [] + path_instructions: + - path: "dashboard-deployments/**" + instructions: >- + This directory contains server-side dashboard examples for visualizing data from + FixedIT Data Agent running on Axis devices. These are primarily for DevOps/IT + professionals comfortable with deploying Grafana dashboards and InfluxDB servers. + Some dashboards work directly with bundled agent configurations, others can be + customized. Licensed under Elastic License 2.0. Review for deployment complexity, + dashboard usability, and proper licensing compliance. We should make sure that + dashboards are portable and does not check in specific host names, or refer to + other specific data from a single deployment. + - path: "**/*.md" + instructions: >- + Documentation files should clearly communicate the dual audience: (1) server-side + dashboard users who want to keep agent with bundled configs, and (2) edge device + developers who want to customize agent behavior. Ensure examples and instructions + are appropriate for the intended skill level and use case. Since this is a public + repository, we should not include any sensitive information, the instructions + should be easily understandable for a wide audience, and we should avoid using + any jargon or technical terms that are not commonly used. + - path: "**/*" + instructions: >- + This repository serves FixedIT Data Agent users across a spectrum from plug-and-play + dashboard deployment to advanced edge device customization. Consider whether changes + maintain accessibility for both DevOps professionals (server-side focus) and + developers (edge customization focus). If new features are added or existing ones + changed significantly, ensure documentation clearly explains the intended audience + and usage level. We use prettier for formatting of common file formats like markdown, + yaml, json, etc. + auto_review: + enabled: true + auto_incremental_review: true + base_branches: [".*"] diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 0000000..2335269 --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,75 @@ +name: Prettier Format Check + +on: + push: + pull_request: + +permissions: + contents: read + pull-requests: write + +jobs: + prettier: + runs-on: ubuntu-latest + env: + # List of files patterns that should be formatted by prettier. This should normally include: + # workflow files (yml) and any other json/yml/markdown files, including hidden config files for tools. + PRETTIER_FILES: '"**/*.{json,yml,yaml,md}" ".github/**/*.{json,yml,yaml,md}" ".*.{yml,yaml}"' + # Pin Prettier version to ensure deterministic CI runs and avoid unpredictable failures + PRETTIER_VERSION: "3.6.0" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Run prettier check + run: | + # Format JSON, YAML (including workflow files), and Markdown files + npx prettier@${{ env.PRETTIER_VERSION }} --check ${{ env.PRETTIER_FILES }} --ignore-unknown + + - name: Get files that need formatting (on failure) + if: failure() && github.event_name == 'pull_request' + id: format_files + run: | + # Get list of files that need formatting + FILES_NEEDING_FORMAT=$(npx prettier@${{ env.PRETTIER_VERSION }} --check ${{ env.PRETTIER_FILES }} --ignore-unknown --list-different 2>/dev/null || true) + echo "files_list<> $GITHUB_OUTPUT + echo "$FILES_NEEDING_FORMAT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Comment on PR (on failure) + if: failure() && github.event_name == 'pull_request' && steps.format_files.outputs.files_list != '' + uses: actions/github-script@v7 + with: + script: | + const filesList = `${{ steps.format_files.outputs.files_list }}`.trim(); + + if (filesList) { + const files = filesList.split('\n').filter(f => f.trim()); + const comment = `## 🎨 Code Formatting Required + + Some files in this PR need to be formatted with Prettier. + + This includes JSON, YAML (workflow files), and Markdown files. + + **Files that need formatting:** + ${files.map(file => `- \`${file}\``).join('\n')} + + **To fix this:** + 1. Format the files: \`npx prettier@${{ env.PRETTIER_VERSION }} --write ${{ env.PRETTIER_FILES }} --ignore-unknown\` + 2. Commit and push the changes + + The formatting check will automatically pass once these files are properly formatted.`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); + } diff --git a/README.md b/README.md index 88cb5d4..2aa93bc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # fixedit-data-agent-dashboards + This repository contains an InfluxDB + Grafana stack with provisioned dashboards for Axis camera monitoring with the FixedIT Data Agent edge application.