diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 113dbe1695f..56155898225 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,57 @@ name: CI -on: [push, pull_request] - +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize] jobs: + + commit-lint: + runs-on: ubuntu-latest + steps: + - name: find the prev warning if exist + uses: peter-evans/find-comment@v1 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: "github-actions[bot]" + body-includes: "bad commit message" + - name: Delete comment if exist + if: ${{ steps.fc.outputs.comment-id != 0 }} + uses: actions/github-script@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: ${{ steps.fc.outputs.comment-id }}, + }) + - uses: actions/checkout@v2.5.0 + with: + fetch-depth: 0 + - run: 'echo "module.exports = {extends: [''@commitlint/config-conventional'']}" > commitlint.config.js' + - uses: wagoid/commitlint-github-action@v1 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: if lint failed + if: ${{ failure() }} + uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Thanks for your contribution :heart: + :broken_heart: Unfortunately, this PR has one ore more **bad commit messages**, it can not be merged. To fix this problem, please refer to: + - [Commit Message Guideline for the First Time Contributor](https://github.com/jina-ai/jina/issues/553) + - [Contributing Guideline](https://github.com/jina-ai/jina/blob/master/CONTRIBUTING.md) + + Note, other CI tests will *not* *start* until the commit messages get fixed. + + This message will be deleted automatically when the commit messages get fixed. + reaction-type: "eyes" + lint-ruff: runs-on: ubuntu-latest steps: @@ -35,7 +84,7 @@ jobs: python -m pip install --upgrade pip python -m pip install poetry poetry install --only dev - poetry run black . + poetry run black --check . env: CHANGED_FILES: ${{ steps.file_changes.outputs.added_modified }} @@ -74,7 +123,7 @@ jobs: # prep-testbed: # runs-on: ubuntu-latest -# needs: [lint-flake-8, check-black, import-test] +# needs: [lint-ruff, check-black, import-test] # steps: # - uses: actions/checkout@v2.5.0 # - id: set-matrix @@ -86,7 +135,7 @@ jobs: # matrix: ${{ steps.set-matrix.outputs.matrix }} docarray-test: - needs: [lint-flake-8, check-black, import-test] + needs: [lint-ruff, check-black, import-test] runs-on: ubuntu-latest strategy: fail-fast: false @@ -129,7 +178,7 @@ jobs: # just for blocking the merge until all parallel core-test are successful success-all-test: - needs: [docarray-test] + needs: [docarray-test, check-mypy, commit-lint] if: always() runs-on: ubuntu-latest steps: diff --git a/tests/integrations/typing/tensor.py b/tests/integrations/typing/tensor.py index 0d17207e667..880e1df65a8 100644 --- a/tests/integrations/typing/tensor.py +++ b/tests/integrations/typing/tensor.py @@ -1,11 +1,10 @@ import numpy as np -from docarray.typing import Tensor from docarray import Document +from docarray.typing import Tensor def test_set_tensor(): - class MyDocument(Document): tensor: Tensor