From 5f5fe7eb2927c09557d1f280303f19f384f0aaa9 Mon Sep 17 00:00:00 2001 From: jbajic <jure.bajic@memgraph.com> Date: Wed, 9 Nov 2022 10:39:29 +0100 Subject: [PATCH 1/3] Add python checks --- .github/workflows/diff.yaml | 31 ++++++++++++++++++++++++++++--- .pre-commit-config.yaml | 16 ++++++---------- init | 7 +++++++ pyproject.toml | 13 +++++++++++++ 4 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/diff.yaml b/.github/workflows/diff.yaml index ef5cf2ee2..e75cad88b 100644 --- a/.github/workflows/diff.yaml +++ b/.github/workflows/diff.yaml @@ -75,14 +75,39 @@ jobs: - name: Fetch all history for all tags and branches run: git fetch + - name: Initialize deps + run: | + # Activate toolchain. + source /opt/toolchain-v4/activate + # Initialize dependencies. + ./init + + - name: Set base branch + if: ${{ github.event_name == 'pull_request' }} + run: | + echo "BASE_BRANCH=origin/${{ github.base_ref }}" >> $GITHUB_ENV + + - name: Set base branch # if we manually dispatch or push to master + if: ${{ github.event_name != 'pull_request' }} + run: | + echo "BASE_BRANCH=origin/master" >> $GITHUB_ENV + + - name: Python code analysis + run: | + CHANGED_FILES=$(git diff -U0 ${{ env.BASE_BRANCH }}... --name-only) + for file in ${CHANGED_FILES}; do + echo ${file} + if [[ ${file} == *.py ]]; then + python3 -m black --check --diff ${file} + python3 -m isort --check-only --diff ${file} + fi + done + - name: Build combined ASAN, UBSAN and coverage binaries run: | # Activate toolchain. source /opt/toolchain-v4/activate - # Initialize dependencies. - ./init - cd build cmake -DTEST_COVERAGE=ON -DASAN=ON -DUBSAN=ON .. make -j$THREADS memgraph__unit diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 869991668..5abd746c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,18 +6,14 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.10.0 hooks: - id: black - args: # arguments to configure black - - --line-length=120 - - --include='\.pyi?$' - # these folders wont be formatted by black - - --exclude="""\.git | - \.__pycache__| - build| - libs| - .cache""" + - repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + name: isort (python) - repo: https://github.com/pre-commit/mirrors-clang-format rev: v13.0.0 hooks: diff --git a/init b/init index 313855963..2c0eb4784 100755 --- a/init +++ b/init @@ -140,5 +140,12 @@ done; python3 -m pip install pre-commit python3 -m pre_commit install +# Install py format tools +echo "Install black formatter" +python3 -m pip install black==22.10.* +echo "Install isort" +python3 -m pip install isort==5.10.* + + # Link `include/mgp.py` with `release/mgp/mgp.py` ln -v -f include/mgp.py release/mgp/mgp.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..b4f64f523 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,13 @@ + +[tool.black] +line-length = 120 +include = '\.pyi?$' +extend-exclude = ''' +/( + | .git + | .__pycache__ + | build + | libs + | .cache +)/ +''' From cba183898a67ebb88c5522714c333726ff75f4f2 Mon Sep 17 00:00:00 2001 From: jbajic <jure.bajic@memgraph.com> Date: Wed, 9 Nov 2022 10:40:46 +0100 Subject: [PATCH 2/3] Update actions versions --- .github/workflows/daily_benchmark.yaml | 2 +- .github/workflows/diff.yaml | 10 +++++----- .github/workflows/full_clang_tidy.yaml | 2 +- .github/workflows/package_all.yaml | 20 ++++++++++---------- .github/workflows/release_centos8.yaml | 16 ++++++++-------- .github/workflows/release_debian10.yaml | 20 ++++++++++---------- .github/workflows/release_docker.yaml | 2 +- .github/workflows/release_ubuntu2004.yaml | 16 ++++++++-------- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/.github/workflows/daily_benchmark.yaml b/.github/workflows/daily_benchmark.yaml index 4a27241b4..5842a3cf5 100644 --- a/.github/workflows/daily_benchmark.yaml +++ b/.github/workflows/daily_benchmark.yaml @@ -16,7 +16,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) diff --git a/.github/workflows/diff.yaml b/.github/workflows/diff.yaml index e75cad88b..95e1248ee 100644 --- a/.github/workflows/diff.yaml +++ b/.github/workflows/diff.yaml @@ -26,7 +26,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -64,7 +64,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -135,7 +135,7 @@ jobs: tar -czf code_coverage.tar.gz coverage.json html report.json summary.rmu - name: Save code coverage - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Code coverage" path: tools/github/generated/code_coverage.tar.gz @@ -170,7 +170,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -208,7 +208,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) diff --git a/.github/workflows/full_clang_tidy.yaml b/.github/workflows/full_clang_tidy.yaml index f63d4fbdf..abb48c860 100644 --- a/.github/workflows/full_clang_tidy.yaml +++ b/.github/workflows/full_clang_tidy.yaml @@ -14,7 +14,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) diff --git a/.github/workflows/package_all.yaml b/.github/workflows/package_all.yaml index 2183866e1..0a7cd891a 100644 --- a/.github/workflows/package_all.yaml +++ b/.github/workflows/package_all.yaml @@ -17,7 +17,7 @@ jobs: run: | ./release/package/run.sh package centos-7 - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: centos-7 path: build/output/centos-7/memgraph*.rpm @@ -34,7 +34,7 @@ jobs: run: | ./release/package/run.sh package centos-9 - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: centos-9 path: build/output/centos-9/memgraph*.rpm @@ -51,7 +51,7 @@ jobs: run: | ./release/package/run.sh package debian-10 - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: debian-10 path: build/output/debian-10/memgraph*.deb @@ -68,7 +68,7 @@ jobs: run: | ./release/package/run.sh package debian-11 - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: debian-11 path: build/output/debian-11/memgraph*.deb @@ -87,7 +87,7 @@ jobs: ./run.sh package debian-11 --for-docker ./run.sh docker - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: docker path: build/output/docker/memgraph*.tar.gz @@ -104,7 +104,7 @@ jobs: run: | ./release/package/run.sh package ubuntu-18.04 - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ubuntu-1804 path: build/output/ubuntu-18.04/memgraph*.deb @@ -121,7 +121,7 @@ jobs: run: | ./release/package/run.sh package ubuntu-20.04 - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ubuntu-2004 path: build/output/ubuntu-20.04/memgraph*.deb @@ -138,7 +138,7 @@ jobs: run: | ./release/package/run.sh package ubuntu-22.04 - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ubuntu-2204 path: build/output/ubuntu-22.04/memgraph*.deb @@ -155,7 +155,7 @@ jobs: run: | ./release/package/run.sh package debian-11 --for-platform - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: debian-11-platform path: build/output/debian-11/memgraph*.deb @@ -172,7 +172,7 @@ jobs: run: | ./release/package/run.sh package debian-11-arm - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: debian-11-arm path: build/output/debian-11-arm/memgraph*.deb diff --git a/.github/workflows/release_centos8.yaml b/.github/workflows/release_centos8.yaml index b3a678a60..cd54749e9 100644 --- a/.github/workflows/release_centos8.yaml +++ b/.github/workflows/release_centos8.yaml @@ -17,7 +17,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -55,7 +55,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -97,7 +97,7 @@ jobs: tar -czf code_coverage.tar.gz coverage.json html report.json summary.rmu - name: Save code coverage - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Code coverage" path: tools/github/generated/code_coverage.tar.gz @@ -112,7 +112,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -173,7 +173,7 @@ jobs: ./cppcheck_and_clang_format diff - name: Save cppcheck and clang-format errors - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Code coverage" path: tools/github/cppcheck_and_clang_format.txt @@ -189,7 +189,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -225,7 +225,7 @@ jobs: rpmlint memgraph*.rpm - name: Save enterprise RPM package - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Enterprise RPM package" path: build/output/memgraph*.rpm @@ -262,7 +262,7 @@ jobs: ./continuous_integration - name: Save quality assurance status - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "GQL Behave Status" path: | diff --git a/.github/workflows/release_debian10.yaml b/.github/workflows/release_debian10.yaml index 64d0e7f9a..e434a37ea 100644 --- a/.github/workflows/release_debian10.yaml +++ b/.github/workflows/release_debian10.yaml @@ -17,7 +17,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -55,7 +55,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -97,7 +97,7 @@ jobs: tar -czf code_coverage.tar.gz coverage.json html report.json summary.rmu - name: Save code coverage - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Code coverage" path: tools/github/generated/code_coverage.tar.gz @@ -112,7 +112,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -173,7 +173,7 @@ jobs: ./cppcheck_and_clang_format diff - name: Save cppcheck and clang-format errors - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Code coverage" path: tools/github/cppcheck_and_clang_format.txt @@ -189,7 +189,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -224,7 +224,7 @@ jobs: cpack -G DEB --config ../CPackConfig.cmake - name: Save enterprise DEB package - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Enterprise DEB package" path: build/output/memgraph*.deb @@ -261,7 +261,7 @@ jobs: ./continuous_integration - name: Save quality assurance status - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "GQL Behave Status" path: | @@ -324,7 +324,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -349,7 +349,7 @@ jobs: ./run.sh test --binary ../../build/memgraph --run-args "test-all --node-configs resources/node-config.edn" --ignore-run-stdout-logs --ignore-run-stderr-logs - name: Save Jepsen report - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: ${{ always() }} with: name: "Jepsen Report" diff --git a/.github/workflows/release_docker.yaml b/.github/workflows/release_docker.yaml index 34d5d869d..ff00ccbff 100644 --- a/.github/workflows/release_docker.yaml +++ b/.github/workflows/release_docker.yaml @@ -19,7 +19,7 @@ jobs: DOCKER_REPOSITORY_NAME: memgraph steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v1 diff --git a/.github/workflows/release_ubuntu2004.yaml b/.github/workflows/release_ubuntu2004.yaml index 4f8b94586..ab96159c6 100644 --- a/.github/workflows/release_ubuntu2004.yaml +++ b/.github/workflows/release_ubuntu2004.yaml @@ -17,7 +17,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -55,7 +55,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -97,7 +97,7 @@ jobs: tar -czf code_coverage.tar.gz coverage.json html report.json summary.rmu - name: Save code coverage - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Code coverage" path: tools/github/generated/code_coverage.tar.gz @@ -112,7 +112,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -173,7 +173,7 @@ jobs: ./cppcheck_and_clang_format diff - name: Save cppcheck and clang-format errors - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Code coverage" path: tools/github/cppcheck_and_clang_format.txt @@ -189,7 +189,7 @@ jobs: steps: - name: Set up repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Number of commits to fetch. `0` indicates all history for all # branches and tags. (default: 1) @@ -224,7 +224,7 @@ jobs: cpack -G DEB --config ../CPackConfig.cmake - name: Save enterprise DEB package - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "Enterprise DEB package" path: build/output/memgraph*.deb @@ -261,7 +261,7 @@ jobs: ./continuous_integration - name: Save quality assurance status - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: "GQL Behave Status" path: | From 51fb4a6e7a8bd1fa6d8619aaf219e8e370d55bc4 Mon Sep 17 00:00:00 2001 From: jbajic <jure.bajic@memgraph.com> Date: Wed, 9 Nov 2022 11:32:54 +0100 Subject: [PATCH 3/3] Remove empty line --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b4f64f523..73bcf866c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,3 @@ - [tool.black] line-length = 120 include = '\.pyi?$'