From cc6a4d200c8d5e84a0a09b409646881b96c3798a Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Tue, 22 Dec 2020 12:48:36 -0800 Subject: [PATCH] Add analyze segment - thanks to @ksunden --- .github/workflows/codeql-analysis.yml | 55 +++++++++++++++++++++++++++ .github/workflows/main.yml | 42 +++++++++++++------- pyqtgraph/tests/image_testing.py | 4 +- 3 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..4cdc0155 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,55 @@ +name: analyze pyqtgraph + +on: pull_request + +jobs: + analyze: + name: analyze + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install PyQt5 numpy scipy six + echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: 'python' + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + queries: +security-and-quality + setup-python-dependencies: false + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 653f9acb..e4c7f10c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,9 @@ name: test pyqtgraph -on: [push] +on: [push, pull_request] jobs: - build: + test: runs-on: ${{ matrix.os }} timeout-minutes: 30 strategy: @@ -82,41 +82,54 @@ jobs: if: runner.os != 'Linux' - name: Run Tests run: | + mkdir $SCREENSHOT_DIR pytest . -v \ -n auto \ --junitxml=junit/test-results.xml \ --cov pyqtgraph --cov-report=xml --cov-report=html shell: bash - env: - AZURE: 1 + - name: Upload Screenshots + uses: actions/upload-artifact@v2 + with: + name: Screenshots (Python ${{ matrix.python-version }} - Qt-Bindings ${{ matrix.qt-lib }} - OS ${{ matrix.os }}) + path: $SCREENSHOT_DIR + if-no-files-found: ignore - name: Upload Unit Test Results if: always() uses: actions/upload-artifact@v2 with: name: Unit Test Results (Python ${{ matrix.python-version }} - Qt-Bindings ${{ matrix.qt-lib }} - OS ${{ matrix.os }}) path: junit/test-results.xml + env: + SCREENSHOT_DIR: ./screenshots build-docs: - # Name the Job - name: Build Docs - # Set the type of machine to run on + name: build docs runs-on: ubuntu-latest steps: - # Checks out a copy of your repository on the ubuntu-latest machine - uses: actions/checkout@v2 - name: Setup Python 3.9 uses: actions/setup-python@v2 with: python-version: '3.9' - - name: Build Docs + - name: Install Dependencies run: | cd doc python -m pip install -r requirements.txt + - name: Build Documentation + run: | + cd doc make html SPHINXOPTS='-W -v' + - name: Upload Build Docs + uses: actions/upload-artifact@v2 + with: + name: html-docs + path: | + doc/build/html linting: - name: Linting + name: check linting runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -124,14 +137,15 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.9' - # Runs the Super-Linter action - - name: Style check + - name: "Install Dependencies" run: | pip install flake8 + - name: "Check Linting" + run: | python -m flake8 . build-wheel: - name: Build Wheel + name: build wheel runs-on: ubuntu-latest steps: @@ -149,4 +163,4 @@ jobs: with: name: wheel path: | - dist \ No newline at end of file + dist diff --git a/pyqtgraph/tests/image_testing.py b/pyqtgraph/tests/image_testing.py index cfb62bb9..12101b2c 100644 --- a/pyqtgraph/tests/image_testing.py +++ b/pyqtgraph/tests/image_testing.py @@ -212,7 +212,7 @@ def assertImageApproved(image, standardFile, message=None, **kwargs): else: if os.getenv('TRAVIS') is not None: saveFailedTest(image, stdImage, standardFile, upload=True) - elif os.getenv('AZURE') is not None: + elif os.getenv('CI') is not None: standardFile = os.path.join(os.getenv("SCREENSHOT_DIR", "screenshots"), standardFile) saveFailedTest(image, stdImage, standardFile) print(graphstate) @@ -509,7 +509,7 @@ def getTestDataRepo(): if not os.path.isdir(parentPath): os.makedirs(parentPath) - if os.getenv('TRAVIS') is not None or os.getenv('AZURE') is not None: + if os.getenv('TRAVIS') is not None or os.getenv('CI') is not None: # Create a shallow clone of the test-data repository (to avoid # downloading more data than is necessary) os.makedirs(dataPath)