From 47ec05e3c1be4c22c8587cd49a7227b738a5625e Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Tue, 16 Jan 2024 12:05:07 +0530 Subject: [PATCH] ci: update workflow deps --- .editorconfig | 6 + .eslintignore | 3 + .eslintrc | 124 ++++++++++++++++++ .flake8 | 1 + .github/workflows/frappe.yaml | 10 +- .github/workflows/lint.yaml | 10 +- .github/workflows/release.yaml | 5 +- .pre-commit-config.yaml | 33 +++-- .../file_association/file_association.py | 1 + cloud_storage/tests/test_file_association.py | 3 +- pyproject.toml | 5 +- 11 files changed, 176 insertions(+), 25 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc diff --git a/.editorconfig b/.editorconfig index b72767b..50d1755 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,9 @@ charset = utf-8 indent_style = tab indent_size = 2 max_line_length = 99 + +# JSON files - mostly doctype schema files +[{*.json}] +insert_final_newline = false +indent_style = space +indent_size = 2 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..3127e88 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +cloud_storage/public/js/lib/* +cloud_storage/templates/includes/* +cloud_storage/www/website_script.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..d4b870b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,124 @@ +{ + "env": { + "browser": true, + "node": true, + "es2022": true + }, + "parserOptions": { + "sourceType": "module" + }, + "extends": "eslint:recommended", + "rules": { + "indent": "off", + "brace-style": "off", + "no-mixed-spaces-and-tabs": "off", + "no-useless-escape": "off", + "space-unary-ops": ["error", { "words": true }], + "linebreak-style": "off", + "quotes": ["off"], + "semi": "off", + "camelcase": "off", + "no-unused-vars": "off", + "no-console": ["warn"], + "no-extra-boolean-cast": ["off"], + "no-control-regex": ["off"] + }, + "root": true, + "globals": { + "frappe": true, + "Vue": true, + "SetVueGlobals": true, + "__": true, + "repl": true, + "Class": true, + "locals": true, + "cint": true, + "cstr": true, + "cur_frm": true, + "cur_dialog": true, + "cur_page": true, + "cur_list": true, + "cur_tree": true, + "msg_dialog": true, + "is_null": true, + "in_list": true, + "has_common": true, + "posthog": true, + "has_words": true, + "validate_email": true, + "open_web_template_values_editor": true, + "validate_name": true, + "validate_phone": true, + "validate_url": true, + "get_number_format": true, + "format_number": true, + "format_currency": true, + "comment_when": true, + "open_url_post": true, + "toTitle": true, + "lstrip": true, + "rstrip": true, + "strip": true, + "strip_html": true, + "replace_all": true, + "flt": true, + "precision": true, + "CREATE": true, + "AMEND": true, + "CANCEL": true, + "copy_dict": true, + "get_number_format_info": true, + "strip_number_groups": true, + "print_table": true, + "Layout": true, + "web_form_settings": true, + "$c": true, + "$a": true, + "$i": true, + "$bg": true, + "$y": true, + "$c_obj": true, + "refresh_many": true, + "refresh_field": true, + "toggle_field": true, + "get_field_obj": true, + "get_query_params": true, + "unhide_field": true, + "hide_field": true, + "set_field_options": true, + "getCookie": true, + "getCookies": true, + "get_url_arg": true, + "md5": true, + "$": true, + "jQuery": true, + "moment": true, + "hljs": true, + "Awesomplete": true, + "Sortable": true, + "Showdown": true, + "Taggle": true, + "Gantt": true, + "Slick": true, + "Webcam": true, + "PhotoSwipe": true, + "PhotoSwipeUI_Default": true, + "io": true, + "JsBarcode": true, + "L": true, + "Chart": true, + "DataTable": true, + "Cypress": true, + "cy": true, + "it": true, + "describe": true, + "expect": true, + "context": true, + "before": true, + "beforeEach": true, + "after": true, + "qz": true, + "localforage": true, + "extend_cscript": true + } +} diff --git a/.flake8 b/.flake8 index 2de7a15..e783fbb 100644 --- a/.flake8 +++ b/.flake8 @@ -69,6 +69,7 @@ ignore = F841, E713, E712, + B028, max-line-length = 200 exclude=,test_*.py diff --git a/.github/workflows/frappe.yaml b/.github/workflows/frappe.yaml index c542260..74bbbd3 100644 --- a/.github/workflows/frappe.yaml +++ b/.github/workflows/frappe.yaml @@ -8,7 +8,7 @@ on: pull_request: concurrency: - group: develop-cloud_storage-${{ github.event.number }} + group: version-15-cloud_storage-${{ github.event.number }} cancel-in-progress: true jobs: @@ -31,15 +31,15 @@ jobs: steps: - name: Clone - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 check-latest: true @@ -75,7 +75,7 @@ jobs: - name: Install working-directory: /home/runner/frappe-bench run: | - bench get-app cloud_storage $GITHUB_WORKSPACE + bench get-app cloud_storage $GITHUB_WORKSPACE --resolve-deps bench setup requirements --dev bench new-site --db-root-password root --admin-password admin test_site bench --site test_site install-app cloud_storage diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index f1f94e7..c3d22bf 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -15,13 +15,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} fetch-depth: 2 - name: Setup Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: '3.10' @@ -40,7 +40,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} fetch-depth: 2 @@ -55,7 +55,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.ref }} fetch-depth: 2 @@ -118,7 +118,7 @@ jobs: py_json_merge: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Fetch validator run: git clone --depth 1 https://gist.github.com/f1bf2c11f78331b2417189c385022c28.git validate_json diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1b5b08e..b9c3392 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,8 +1,10 @@ name: Release + on: push: branches: - version-15 + jobs: release: name: Release @@ -11,9 +13,10 @@ jobs: permissions: id-token: write contents: write + steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Python Semantic Release diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f3d4aa..442e8e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: debug-statements - repo: https://github.com/asottile/pyupgrade - rev: v2.34.0 + rev: v3.9.0 hooks: - id: pyupgrade args: ['--py38-plus'] @@ -34,26 +34,41 @@ repos: rev: v2.7.1 hooks: - id: prettier - types_or: [javascript] + types_or: [javascript, vue, scss] # Ignore any files that might contain jinja / bundles exclude: | (?x)^( - .*boilerplate.*| - .*node_modules.*| - cloud_storage/public/dist/.*| - cloud_storage/public/js/lib/.*| - cloud_storage/templates/includes/.*| - cloud_storage/www/website_script.js + .*node_modules.*| + cloud_storage/public/dist/.*| + cloud_storage/public/js/lib/.*| + cloud_storage/templates/includes/.*| + cloud_storage/www/website_script.js )$ + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.44.0 + hooks: + - id: eslint + types_or: [javascript] + args: ['--quiet'] + # Ignore any files that might contain jinja / bundles + exclude: | + (?x)^( + .*node_modules.*| + cloud_storage/public/dist/.*| + cloud_storage/public/js/lib/.*| + cloud_storage/templates/includes/.*| + cloud_storage/www/website_script.js + )$ + - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: ['flake8-bugbear',] diff --git a/cloud_storage/cloud_storage/doctype/file_association/file_association.py b/cloud_storage/cloud_storage/doctype/file_association/file_association.py index 35abb31..d123311 100644 --- a/cloud_storage/cloud_storage/doctype/file_association/file_association.py +++ b/cloud_storage/cloud_storage/doctype/file_association/file_association.py @@ -4,5 +4,6 @@ # import frappe from frappe.model.document import Document + class FileAssociation(Document): pass diff --git a/cloud_storage/tests/test_file_association.py b/cloud_storage/tests/test_file_association.py index 5f3bd2b..ec01b31 100644 --- a/cloud_storage/tests/test_file_association.py +++ b/cloud_storage/tests/test_file_association.py @@ -1,11 +1,10 @@ from io import BytesIO from pathlib import Path +import frappe import pytest from moto import mock_s3 -import frappe - @pytest.fixture def example_file_record_0(): diff --git a/pyproject.toml b/pyproject.toml index 0fd89de..3abea04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,12 +4,11 @@ authors = [ { name = "AgriTheory", email = "support@agritheory.com"} ] description = "Frappe App for integrating with cloud storage applications" -requires-python = ">=3.8" +requires-python = ">=3.10" readme = "README.md" dynamic = ["version"] dependencies = [ - "boto3~=1.28.10", - "botocore~=1.29.41", + "boto3==1.28.10", "python-magic~=0.4.27", "pytest", 'moto[s3]'