diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index fb66af702..2d4b4b1f0 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,6 +1,10 @@ +--- + name: Python build and test -on: [push, pull_request] +on: # yamllint disable-line rule:truthy + pull_request: + push: jobs: build-linux: @@ -8,9 +12,10 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: ["3.10"] #, "3.9", "3.10"] + python-version: ["3.10"] # Skip `pull_request` runs on local PRs for which `push` runs are already triggered + # yamllint disable-line rule:line-length if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository # Service containers to run with `container-job` diff --git a/.github/workflows/bump_version_and_tag.yml b/.github/workflows/bump_version_and_tag.yml index d474affc1..951793605 100644 --- a/.github/workflows/bump_version_and_tag.yml +++ b/.github/workflows/bump_version_and_tag.yml @@ -1,94 +1,100 @@ +--- + +# yamllint disable rule:line-length + name: Create/Update Tag -on: + +on: # yamllint disable-line rule:truthy push: branches: - develop + jobs: create-version-tag: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - token: ${{ secrets.CI_TOKEN }} - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: Update version - id: update-version - run: | + - uses: actions/checkout@v3 + with: + token: ${{ secrets.CI_TOKEN }} + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Update version + id: update-version + run: | + pip install --upgrade pip + pip install poetry + poetry version minor + git config --global user.email "oscarsso@esrf.fr" + git config --global user.name "Marcus Oskarsson" + git add -A + git commit -m "[skip ci] Bumped minor version" + git push -f + poetry build + - name: Publish package to PyPI + id: publish-pacakge + run: | + poetry config pypi-token.pypi ${{ secrets.PYPI }} + poetry publish + - name: Read package version + id: set-tag + run: | pip install --upgrade pip - pip install poetry - poetry version minor - git config --global user.email "oscarsso@esrf.fr" - git config --global user.name "Marcus Oskarsson" - git add -A - git commit -m "[skip ci] Bumped minor version" - git push -f - poetry build - - name: Publish package to PyPI - id: publish-pacakge - run: | - poetry config pypi-token.pypi ${{ secrets.PYPI }} - poetry publish - - name: Read package version - id: set-tag - run: | - pip install --upgrade pip - pip install toml - echo ::set-output name=tag_name::v$(python -c 'import toml; print(toml.load("./pyproject.toml")["tool"]["poetry"]["version"])') - - name: Check tag exists - id: check-tag-exists - uses: actions/github-script@v6 - env: - TAG: ${{ steps.set-tag.outputs.tag_name }} - with: - github-token: ${{ github.token }} - script: | - // https://github.com/mukunku/tag-exists-action - var exists = 'false'; - try { - const getRefResponse = await github.rest.git.getRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}" - }); + pip install toml + echo ::set-output name=tag_name::v$(python -c 'import toml; print(toml.load("./pyproject.toml")["tool"]["poetry"]["version"])') + - name: Check tag exists + id: check-tag-exists + uses: actions/github-script@v6 + env: + TAG: ${{ steps.set-tag.outputs.tag_name }} + with: + github-token: ${{ github.token }} + script: | + // https://github.com/mukunku/tag-exists-action + var exists = 'false'; + try { + const getRefResponse = await github.rest.git.getRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}" + }); - if (getRefResponse.status === 200) { - console.log("Tag was found"); - exists = 'true'; - } - } catch(error) { - console.log("Tag was not found"); - } - core.setOutput('exists', exists); + if (getRefResponse.status === 200) { + console.log("Tag was found"); + exists = 'true'; + } + } catch(error) { + console.log("Tag was not found"); + } + core.setOutput('exists', exists); - - name: Update tag - uses: actions/github-script@v6 - if: steps.check-tag-exists.outputs.exists == 'true' - env: - TAG: ${{ steps.set-tag.outputs.tag_name }} - with: - github-token: ${{ github.token }} - script: | - github.rest.git.updateRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}", - sha: context.sha - }) + - name: Update tag + uses: actions/github-script@v6 + if: steps.check-tag-exists.outputs.exists == 'true' + env: + TAG: ${{ steps.set-tag.outputs.tag_name }} + with: + github-token: ${{ github.token }} + script: | + github.rest.git.updateRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}", + sha: context.sha + }) - - name: Create tag - uses: actions/github-script@v6 - if: steps.check-tag-exists.outputs.exists != 'true' - env: - TAG: ${{ steps.set-tag.outputs.tag_name }} - with: - github-token: ${{ github.token }} - script: | - github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}", - sha: context.sha - }) + - name: Create tag + uses: actions/github-script@v6 + if: steps.check-tag-exists.outputs.exists != 'true' + env: + TAG: ${{ steps.set-tag.outputs.tag_name }} + with: + github-token: ${{ github.token }} + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}", + sha: context.sha + }) diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index dc7c1f1e1..1597ca5b6 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -6,7 +6,7 @@ name: "Pages" concurrency: group: "pages" -on: +on: # yamllint disable-line rule:truthy pull_request: push: diff --git a/.github/workflows/ui.yml b/.github/workflows/ui.yml index c3699ed25..59452a1f1 100644 --- a/.github/workflows/ui.yml +++ b/.github/workflows/ui.yml @@ -1,6 +1,12 @@ +--- + +# yamllint disable rule:line-length + name: UI -on: [push, pull_request] +on: # yamllint disable-line rule:truthy + pull_request: + push: jobs: format: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 962b4cc42..767357ee1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,23 @@ +--- + default_language_version: python: python3.10 + + repos: + + - repo: https://github.com/adrienverge/yamllint + rev: v1.35.1 + hooks: + - id: yamllint + args: + - --strict + - repo: https://github.com/python-poetry/poetry rev: 1.5.0 hooks: - id: poetry-check - # - id: poetry-lock + - repo: https://github.com/myint/autoflake rev: v1.6.0 hooks: @@ -17,11 +29,13 @@ repos: - --in-place - --remove-duplicate-keys - --ignore-pass-after-docstring + - repo: https://github.com/psf/black rev: 22.8.0 hooks: - - id: black - name: Black + - id: black + name: Black + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: @@ -37,18 +51,10 @@ repos: exclude: ^.drone\.yml|meta.yaml - id: mixed-line-ending args: ["--fix=lf"] - # - repo: https://github.com/PyCQA/isort - # rev: 5.10.1 - # hooks: - # - id: isort - # name: Import Sort - # args: - # - --settings=. + - repo: https://github.com/PyCQA/flake8 rev: 4.0.1 hooks: - - id: flake8 - name: Flake8 -# Not using bugbear for now -# additional_dependencies: ["flake8-bugbear==22.9.11"] - exclude: (ui/|test/) + - id: flake8 + name: Flake8 + exclude: (ui/|test/) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 9ca8d8b8a..d7d5d79b9 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -25,6 +25,7 @@ build: - "git fetch --unshallow || true" - "mamba env create --file conda-environment.yml --force" - "mamba run --name mxcubeweb poetry install --only=docs,main" + # yamllint disable-line rule:line-length - "(mamba run --name mxcubeweb redis-server &) && mamba run --name mxcubeweb python -m sphinx -T -E -b html -d _build/doctrees -c docs docs/source ${READTHEDOCS_OUTPUT}/html && mamba run --name mxcubeweb redis-cli shutdown" diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 000000000..bd66e95b6 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,11 @@ +--- + +extends: default + +ignore: | + ui/pnpm-lock.yaml + +rules: + # Match line length to the one set by `black` the Python formatter + line-length: + max: 88 diff --git a/conda-environment.yml b/conda-environment.yml index 2b7f560a2..213763f51 100644 --- a/conda-environment.yml +++ b/conda-environment.yml @@ -1,3 +1,5 @@ +--- + name: mxcubeweb channels: diff --git a/meta.yaml b/meta.yaml index 4b827c987..372027c0e 100644 --- a/meta.yaml +++ b/meta.yaml @@ -1,9 +1,10 @@ -{% set data = load_setup_py_data(setup_file="./setup.py", - from_recipe_dir=True) %} +--- + +# {% set data = load_setup_py_data(setup_file="./setup.py", from_recipe_dir=True) %} package: - name: {{ data.get('name') }} - version: {{ data.get('version') }} + name: {{data.get('name')}} + version: {{data.get('version')}} source: path: . @@ -51,8 +52,8 @@ test: - {{data.get('name')}} about: - home: {{ data.get('url')}} - license: {{ data.get('license')}} - summary: {{ data.get('description')}} - author: {{ data.get('author')}} - description: {{ data.get('description')}} + home: {{data.get('url')}} + license: {{data.get('license')}} + summary: {{data.get('description')}} + author: {{data.get('author')}} + description: {{data.get('description')}} diff --git a/test/HardwareObjectsMockup.xml/beamline_config.yml b/test/HardwareObjectsMockup.xml/beamline_config.yml index c3c6f5f16..f9b140a68 100644 --- a/test/HardwareObjectsMockup.xml/beamline_config.yml +++ b/test/HardwareObjectsMockup.xml/beamline_config.yml @@ -1,3 +1,5 @@ +--- + # The class to initialise, and init parameters _initialise_class: class: mxcubecore.HardwareObjects.Beamline.Beamline @@ -39,7 +41,7 @@ _objects: - sample_changer: sc.xml - sample_changer_maintenance: sc_maint.xml - # The 2 lines up have to be used for SC and the two line below for the plate manipulator + # The 2 lines up have to be used for SC and the 2 line below for the plate manipulator # - sample_changer: plate_manipulator.xml # - sample_changer_maintenance: plate_manipulator_maint.xml @@ -89,14 +91,14 @@ default_acquisition_parameters: default: # Default values, also used for standard acquisition. # Values not given in other dictionaries are taken from here - exp_time: 0.02 # exposure time - osc_start: 0.0 # Only used if no current angle can be found + exp_time: 0.02 # exposure time + osc_start: 0.0 # Only used if no current angle can be found osc_range: 0.1 num_passes: 1 first_image: 1 overlap: 0 num_images: 1 - detector_mode: 1 # Remove as not in practice used ? + detector_mode: 1 # Remove as not in practice used ? inverse_beam: false take_dark_current: true skip_existing_images: true @@ -110,7 +112,7 @@ default_acquisition_parameters: characterisation: # Defaults for chareacterisation. Missing values are taken from default - exp_time: 0.05 # exposure time + exp_time: 0.05 # exposure time osc_range: 1 overlap: -89 num_images: 4 @@ -118,7 +120,7 @@ default_acquisition_parameters: mesh: # Defaults for 'advanced' acquisition. Missing values are taken from default - exp_time: 10 # exposure time + exp_time: 10 # exposure time range: 10 num_images: 100 cell_counting: zig-zag @@ -144,15 +146,15 @@ acquisition_limit_values: - 240.0 available_methods: - datacollection: True - characterisation: True - helical: True - xrf_spectrum: True - energy_scan: True - mesh: True - ssx_chip_collection: True - gphlworkflow: True - test_collection: True + datacollection: true + characterisation: true + helical: true + xrf_spectrum: true + energy_scan: true + mesh: true + ssx_chip_collection: true + gphlworkflow: true + test_collection: true undulators: - type: PPU35C_GAP diff --git a/test/HardwareObjectsMockup.xml/gphl/gphl-setup.yml b/test/HardwareObjectsMockup.xml/gphl/gphl-setup.yml index a072b5c8d..6b5c8c351 100644 --- a/test/HardwareObjectsMockup.xml/gphl/gphl-setup.yml +++ b/test/HardwareObjectsMockup.xml/gphl/gphl-setup.yml @@ -1,3 +1,8 @@ +--- + +# yamllint disable rule:comments +# yamllint disable rule:comments-indentation +# yamllint disable rule:line-length _initialise_class: class: mxcubecore.HardwareObjects.Gphl.GphlWorkflowConnection.GphlWorkflowConnection diff --git a/test/HardwareObjectsMockup.xml/gphl/gphl-workflow.yml b/test/HardwareObjectsMockup.xml/gphl/gphl-workflow.yml index 1111dc72c..146987263 100644 --- a/test/HardwareObjectsMockup.xml/gphl/gphl-workflow.yml +++ b/test/HardwareObjectsMockup.xml/gphl/gphl-workflow.yml @@ -1,3 +1,10 @@ +--- + +# yamllint disable rule:comments-indentation +# yamllint disable rule:hyphens +# yamllint disable rule:indentation +# yamllint disable rule:line-length + _initialise_class: class: mxcubecore.HardwareObjects.Gphl.GphlWorkflow.GphlWorkflow diff --git a/test/HardwareObjectsMockup.xml/mxcube-web/server.yaml b/test/HardwareObjectsMockup.xml/mxcube-web/server.yaml index b9ef4e482..9212dac5f 100644 --- a/test/HardwareObjectsMockup.xml/mxcube-web/server.yaml +++ b/test/HardwareObjectsMockup.xml/mxcube-web/server.yaml @@ -1,9 +1,11 @@ +--- + server: SECRET_KEY: "ASECRETKEY" SECURITY_PASSWORD_SALT: "ASALT" PERMANENT_SESSION_LIFETIME: 60 - DEBUG: False + DEBUG: false ALLOWED_CORS_ORIGINS: - "http://localhost:8081" @@ -11,7 +13,7 @@ server: - "ws://localhost:8000" mxcube: - USE_EXTERNAL_STREAMER: True + USE_EXTERNAL_STREAMER: true VIDEO_FORMAT: MPEG1 VIDEO_STREAM_URL: "ws://localhost:8000/ws" @@ -22,7 +24,7 @@ mxcube: usermanager: class: UserManager - inhouse_is_staff: True + inhouse_is_staff: true users: - username: opid291 role: staff diff --git a/test/HardwareObjectsMockup.xml/mxcube-web/ui.yaml b/test/HardwareObjectsMockup.xml/mxcube-web/ui.yaml index 02ab6e23e..672b8bda8 100644 --- a/test/HardwareObjectsMockup.xml/mxcube-web/ui.yaml +++ b/test/HardwareObjectsMockup.xml/mxcube-web/ui.yaml @@ -1,3 +1,5 @@ +--- + sample_view: id: sample_view components: diff --git a/test/HardwareObjectsMockup.xml/xray_centring2.yml b/test/HardwareObjectsMockup.xml/xray_centring2.yml index 072b39a3f..ed6ccc3dc 100644 --- a/test/HardwareObjectsMockup.xml/xray_centring2.yml +++ b/test/HardwareObjectsMockup.xml/xray_centring2.yml @@ -1,2 +1,4 @@ +--- + _initialise_class: class: mxcubecore.HardwareObjects.mockup.XrayCentringMockup.XrayCentringMockup