Skip to content

Commit

Permalink
switch to pre-commit, part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswilm committed Oct 24, 2024
1 parent c18039d commit 53eb8da
Show file tree
Hide file tree
Showing 6 changed files with 460 additions and 72 deletions.
149 changes: 78 additions & 71 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,82 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v4
- uses: nanasess/setup-chromedriver@master
- name: Install dependencies
run: |
sudo apt update
sudo apt install libjpeg-dev python3-dev python3-pip gettext zlib1g-dev git nodejs build-essential
wget https://github.com/jgm/pandoc/releases/download/3.2.1/pandoc-3.2.1-1-amd64.deb -O pandoc.deb
sudo dpkg -i pandoc.deb
cd fiduswriter
mv ../ci/configuration.py ./
pip install requests[security]
pip install coverage
pip install coveralls
pip install packaging
pip install webdriver-manager
pip install selenium
pip install wheel
pip install pip --upgrade
if grep version ../pyproject.toml | grep -q "dev";
then pip install https://github.com/fiduswriter/fiduswriter/archive/develop.zip;
else pip install https://github.com/fiduswriter/fiduswriter/archive/main.zip;
fi
coverage run $(which fiduswriter) setup --no-static
- name: Run pandoc server
run: pandoc server &
- name: Run test pandoc
uses: nick-invision/retry@v3
with:
timeout_minutes: 8
max_attempts: 3
retry_on: error
command: |
cd fiduswriter
coverage run $(which fiduswriter) test pandoc
- name: Upload failed test screenshots
if: ${{ failure() }}
uses: actions/[email protected]
with:
name: failure-artifacts
path: ${{ github.workspace }}/fiduswriter/screenshots/
- name: Coveralls
run: |
cd fiduswriter
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
run: curl "https://coveralls.io/webhook?repo_token=${{ secrets.GITHUB_TOKEN }}&repo_name=${{ github.repository }}" -d "payload[build_num]=${{ github.run_id }}&payload[status]=done"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: "3.13"
- uses: pre-commit/[email protected]
test:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- uses: actions/checkout@v4
- uses: nanasess/setup-chromedriver@master
- name: Install dependencies
run: |
sudo apt update
sudo apt install libjpeg-dev python3-dev python3-pip gettext zlib1g-dev git nodejs build-essential
wget https://github.com/jgm/pandoc/releases/download/3.2.1/pandoc-3.2.1-1-amd64.deb -O pandoc.deb
sudo dpkg -i pandoc.deb
cd fiduswriter
mv ../ci/configuration.py ./
pip install requests[security]
pip install coverage
pip install coveralls
pip install packaging
pip install webdriver-manager
pip install selenium
pip install wheel
pip install pip --upgrade
if grep version ../pyproject.toml | grep -q "dev";
then pip install https://github.com/fiduswriter/fiduswriter/archive/develop.zip;
else pip install https://github.com/fiduswriter/fiduswriter/archive/main.zip;
fi
coverage run $(which fiduswriter) setup --no-static
- name: Run pandoc server
run: pandoc server &
- name: Run test pandoc
uses: nick-invision/retry@v3
with:
timeout_minutes: 8
max_attempts: 3
retry_on: error
command: |
cd fiduswriter
coverage run $(which fiduswriter) test pandoc
- name: Upload failed test screenshots
if: ${{ failure() }}
uses: actions/[email protected]
with:
name: failure-artifacts
path: ${{ github.workspace }}/fiduswriter/screenshots/
- name: Coveralls
run: |
cd fiduswriter
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
run: curl "https://coveralls.io/webhook?repo_token=${{ secrets.GITHUB_TOKEN }}&repo_name=${{ github.repository }}" -d "payload[build_num]=${{ github.run_id }}&payload[status]=done"
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
hooks:
- id: black
args: [--line-length=79]
language_version: python3.13
- repo: https://github.com/pycqa/flake8
rev: '7.1.1'
hooks:
- id: flake8
entry: flake8 --extend-ignore E203,E501
- repo: https://github.com/biomejs/pre-commit
rev: "75149f4e3b63c4df805860d7b04186d56dcbc05c"
hooks:
- id: biome-check
#entry: biome check --files-ignore-unknown=true --no-errors-on-unmatched --fix --unsafe
additional_dependencies: ["@biomejs/[email protected]"]
- repo: https://github.com/awebdeveloper/pre-commit-stylelint
rev: "4200758f4cb2f53dd06898dd8dca35e4b8cfb785"
hooks:
- id: stylelint
additional_dependencies:
[
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
]
- repo: local
hooks:
- id: django-import-resolver
name: Django Import Resolver
entry: node lint/django_import_resolver.js
language: node
files: \.js$
additional_dependencies: ["[email protected]"]
170 changes: 170 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 4,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto",
"bracketSpacing": true,
"ignore": [
"**/.transpile-cache/",
"**/venv/",
"**/static-transpile/",
"**/static-libs/",
"**/static-collected/",
"**/node-modules/",
"**/testing/",
"**/.eslintrc.mjs",
"**/*.json",
"**/*.html",
"**/.direnv",
"**/venv",
"**/.transpile",
"**/.babelrc",
"**/sw-template.js"
]
},
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "off",
"noUselessConstructor": "off",
"noUselessLabel": "error",
"noUselessLoneBlockStatements": "error",
"noUselessRename": "error",
"noUselessStringConcat": "error",
"noUselessTernary": "off",
"noUselessUndefinedInitialization": "error",
"noVoid": "error",
"noWith": "error",
"useLiteralKeys": "off"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noInvalidUseBeforeDeclaration": "off",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "error",
"useArrayLiterals": "error",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
},
"security": { "noGlobalEval": "error" },
"style": {
"noArguments": "off",
"noCommaOperator": "error",
"noNegationElse": "off",
"noParameterAssign": "off",
"noRestrictedGlobals": { "level": "error", "options": {} },
"noVar": "error",
"noYodaExpression": "off",
"useBlockStatements": "error",
"useCollapsedElseIf": "off",
"useConsistentBuiltinInstantiation": "error",
"useConst": "warn",
"useDefaultSwitchClause": "off",
"useNumericLiterals": "error",
"useShorthandAssign": "off",
"useSingleVarDeclarator": "off",
"useTemplate": "off"
},
"suspicious": {
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "off",
"noDebugger": "error",
"noDoubleEquals": "off",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "off",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noLabelVar": "error",
"noMisleadingCharacterClass": "error",
"noPrototypeBuiltins": "off",
"noRedeclare": "error",
"noSelfCompare": "error",
"noShadowRestrictedNames": "error",
"noSparseArray": "error",
"noUnsafeNegation": "error",
"useAwait": "error",
"useGetterReturn": "error",
"useValidTypeof": "error"
}
},
"ignore": [
"**/.transpile-cache/",
"**/venv/",
"**/static-transpile/",
"**/static-libs/",
"**/static-collected/",
"**/testing/",
"**/manifest.json",
"**/sw-template.js"
]
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "none",
"semicolons": "asNeeded",
"indentWidth": 4,
"arrowParentheses": "asNeeded",
"bracketSameLine": true,
"quoteStyle": "double",
"attributePosition": "auto",
"bracketSpacing": false
},
"globals": [
"settings_MEDIA_MAX_SIZE",
"settings_SOCIALACCOUNT_OPEN",
"settings_REGISTRATION_OPEN",
"gettext",
"interpolate",
"settings_USE_SERVICE_WORKER",
"transpile_VERSION",
"settings_TEST_SERVER",
"settings_DEBUG",
"settings_SOURCE_MAPS",
"settings_STATIC_URL",
"settings_PASSWORD_LOGIN",
"process",
"staticUrl",
"settings_CONTACT_EMAIL",
"settings_IS_FREE",
"settings_FOOTER_LINKS",
"settings_BRANDING_LOGO"
]
}
}
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pre-commit==4.0.1
Loading

0 comments on commit 53eb8da

Please sign in to comment.