diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..4b852abd7 --- /dev/null +++ b/.flake8 @@ -0,0 +1,37 @@ +[flake8] +ignore = + E121, + E126, + E127, + E128, + E203, + E225, + E226, + E231, + E241, + E251, + E261, + E265, + E302, + E303, + E305, + E402, + E501, + E741, + W291, + W292, + W293, + W391, + W503, + W504, + F403, + B007, + B950, + W191, + E124, # closing bracket, irritating while writing QB code + E131, # continuation line unaligned for hanging indent + E123, # closing bracket does not match indentation of opening bracket's line + E101, # ensured by use of black + +max-line-length = 200 +exclude=.github/helper/semgrep_rules diff --git a/.github/helper/flake8.conf b/.github/helper/flake8.conf new file mode 100644 index 000000000..8a97e17c9 --- /dev/null +++ b/.github/helper/flake8.conf @@ -0,0 +1,74 @@ +[flake8] +ignore = + B001, + B007, + B009, + B010, + B950, + E101, + E111, + E114, + E116, + E117, + E121, + E122, + E123, + E124, + E125, + E126, + E127, + E128, + E131, + E201, + E202, + E203, + E211, + E221, + E222, + E223, + E224, + E225, + E226, + E228, + E231, + E241, + E242, + E251, + E261, + E262, + E265, + E266, + E271, + E272, + E273, + E274, + E301, + E302, + E303, + E305, + E306, + E402, + E501, + E502, + E701, + E702, + E703, + E741, + F401, + F403, + F405, + W191, + W291, + W292, + W293, + W391, + W503, + W504, + E711, + E129, + F841, + E713, + E712, + + +max-line-length = 200 \ No newline at end of file diff --git a/.github/helper/install_dependencies.sh b/.github/helper/install_dependencies.sh new file mode 100644 index 000000000..29fa06bca --- /dev/null +++ b/.github/helper/install_dependencies.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +echo "Setting Up System Dependencies..." + +sudo apt update +sudo apt remove mysql-server mysql-client +sudo apt install libcups2-dev redis-server mariadb-client-10.6 + +install_wkhtmltopdf() { + wget -q https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb + sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb +} +install_wkhtmltopdf & \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..c94d78c24 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,99 @@ + +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + name: Server + + services: + redis-cache: + image: redis:alpine + ports: + - 13000:6379 + redis-queue: + image: redis:alpine + ports: + - 11000:6379 + redis-socketio: + image: redis:alpine + ports: + - 12000:6379 + mariadb: + image: mariadb:10.6 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 + + steps: + - name: Clone + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + check-latest: true + + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml', '**/setup.py', '**/setup.cfg') }} + restore-keys: | + ${{ runner.os }}-pip- + ${{ runner.os }}- + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: 'echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT' + + - uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Setup + run: | + bash ${GITHUB_WORKSPACE}/.github/helper/install_dependencies.sh + pip install frappe-bench + bench init --skip-redis-config-generation --skip-assets --python "$(which python)" ~/frappe-bench + mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'" + mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" + + - name: Install + working-directory: /home/runner/frappe-bench + run: | + bench get-app https://github.com/The-Commit-Company/Raven.git $GITHUB_WORKSPACE + bench setup requirements + bench new-site --db-root-password root --admin-password admin test_site + bench --site test_site install-app raven + bench build + env: + CI: 'Yes' + + - name: Run Tests + working-directory: /home/runner/frappe-bench + run: | + bench --site test_site set-config allow_tests true + bench --site test_site run-tests --app raven + env: + TYPE: server \ No newline at end of file diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 000000000..1e1dc04ed --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,33 @@ +name: Linters + +on: + pull_request: + workflow_dispatch: + push: + branches: [main] + +jobs: + linters: + name: Semantic Commits + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install and Run Pre-commit + uses: pre-commit/action@v2.0.3 + + - name: Download Semgrep rules + run: git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules + + - name: Download semgrep + run: pip install semgrep + + - name: Run Semgrep rules + run: semgrep ci --config ./frappe-semgrep-rules/rules diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..b4d1f3f93 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,47 @@ +exclude: "node_modules|.git" +default_stages: [commit] +fail_fast: false + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + files: "raven.*" + exclude: ".*json$|.*txt$|.*csv|.*md|.*svg" + - id: check-yaml + - id: check-merge-conflict + - id: check-ast + - id: check-json + - id: check-toml + - id: debug-statements + + - repo: https://github.com/asottile/pyupgrade + rev: v2.34.0 + hooks: + - id: pyupgrade + args: ["--py310-plus"] + + - repo: https://github.com/adityahase/black + rev: 9cb0a69f4d0030cdf687eddf314468b39ed54119 + hooks: + - id: black + additional_dependencies: ["click==8.0.4"] + + - repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + additional_dependencies: ["flake8-bugbear", "flake8-tuple"] + args: ["--config", ".github/helper/flake8.conf"] + + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + exclude: ".*setup.py$" + +ci: + autoupdate_schedule: weekly + skip: [] + submodules: false diff --git a/.semgrepignore b/.semgrepignore new file mode 100644 index 000000000..7f5d2839b --- /dev/null +++ b/.semgrepignore @@ -0,0 +1 @@ +.devcontainer/docker-compose.yml \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 4a62fa6db..b40b70e7c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,4 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { diff --git a/api_docs/Chat Stream/Get Messages.bru b/api_docs/Chat Stream/Get Messages.bru new file mode 100644 index 000000000..019ec4e91 --- /dev/null +++ b/api_docs/Chat Stream/Get Messages.bru @@ -0,0 +1,21 @@ +meta { + name: Get Messages + type: http + seq: 1 +} + +get { + url: {{url}}:{{port}}/api/method/raven.api.chat_stream.get_messages?channel_id=general + body: none + auth: none +} + +query { + channel_id: general + ~channel_id: admin-private + ~channel_id: does-not-exist +} + +headers { + Authorization: token {{api_key}}:{{api_secret}} +} diff --git a/api_docs/environments/Dev.bru b/api_docs/environments/Dev.bru index b7088ce75..850b5afe2 100644 --- a/api_docs/environments/Dev.bru +++ b/api_docs/environments/Dev.bru @@ -1,7 +1,7 @@ vars { url: http://localhost port: 8000 - api_key: d0e4a68bf14f25d + api_key: a0fa913c5571c73 } vars:secret [ api_secret diff --git a/api_docs/login.bru b/api_docs/login.bru new file mode 100644 index 000000000..089eb03e7 --- /dev/null +++ b/api_docs/login.bru @@ -0,0 +1,16 @@ +meta { + name: login + type: http + seq: 1 +} + +get { + url: {{url}}:{{port}}/api/method/login?usr=Administrator&pwd=admin + body: none + auth: none +} + +query { + usr: Administrator + pwd: admin +} diff --git a/mobile/components.json b/mobile/components.json new file mode 100644 index 000000000..1c6facd2f --- /dev/null +++ b/mobile/components.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "default", + "rsc": false, + "tsx": true, + "tailwind": { + "config": "tailwind.config.js", + "css": "src/index.css", + "baseColor": "slate", + "cssVariables": true, + "prefix": "" + }, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils" + } +} \ No newline at end of file diff --git a/mobile/index.html b/mobile/index.html index 6667bf5fa..b74d0c2a7 100644 --- a/mobile/index.html +++ b/mobile/index.html @@ -5,7 +5,7 @@ - Raven + {{ app_name }} @@ -129,6 +129,9 @@ + + + - +