Revision fb87d7dff80139f56f3dd3c37b58e1e9cc79f02d authored by Andrey Zhavoronkov on 14 June 2023, 21:13:38 UTC, committed by GitHub on 14 June 2023, 21:13:38 UTC
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->
Manually with docker-compose.https.yml config enabled

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [ ] I have added a description of my changes into the
[CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the documentation accordingly
- [ ] I have added tests to cover my changes
- [ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.

---------

Co-authored-by: Nikita Manovich <nikita@cvat.ai>
1 parent b19e925
Raw File
black.yml
name: Black
on: pull_request
jobs:
  Linter:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - id: files
        uses: tj-actions/changed-files@v35.9.2
        with:
          files: |
              cvat-sdk/**/*.py
              cvat-cli/**/*.py
              tests/python/**/*.py
              cvat/apps/quality_control/**/*.py
          dir_names: true

      - name: Run checks
        env:
          PR_FILES_AM: ${{ steps.files.outputs.added_modified }}
          PR_FILES_RENAMED: ${{ steps.files.outputs.renamed }}
        run: |
          # If different modules use different Black configs,
          # we need to run Black for each python component group separately.
          # Otherwise, they all will use the same config.

          UPDATED_DIRS="${{steps.files.outputs.all_changed_files}}"

          if [[ ! -z $UPDATED_DIRS ]]; then
            sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
            python3 -m venv .env
            . .env/bin/activate
            pip install -U pip wheel setuptools
            pip install $(egrep "black.*" ./cvat-cli/requirements/development.txt)
            mkdir -p black_report

            echo "Black version: "$(black --version)
            echo "The dirs will be checked: $UPDATED_DIRS"
            EXIT_CODE=0
            for DIR in $UPDATED_DIRS; do
              black --check --diff $DIR >> ./black_report/black_checks.txt || EXIT_CODE=$(($? | $EXIT_CODE)) || true
            done
            deactivate
            exit $EXIT_CODE
          else
            echo "No files with the \"py\" extension found"
          fi

      - name: Upload artifacts
        if: failure()
        uses: actions/upload-artifact@v3.1.1
        with:
          name: black_report
          path: black_report
back to top