Validate properties on assignment #753
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| - pull_request | |
| jobs: | |
| base_coverage: | |
| continue-on-error: true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ github.base_ref }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.12 | |
| - name: Install Dependencies | |
| run: pip install -e . -r dev-requirements.txt | |
| - name: Test with pytest | |
| run: | | |
| pytest --cov=src --cov-report=lcov | |
| mv coverage.lcov base-coverage.lcov | |
| - name: Upload code coverage for base branch | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: base-coverage.lcov | |
| path: ./base-coverage.lcov | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Install Dependencies | |
| run: pip install -e . -r dev-requirements.txt | |
| - name: Print installed packages | |
| run: pip freeze | |
| - name: Lint with Ruff | |
| run: ruff check . | |
| - name: Format with Ruff | |
| run: ruff format --check . | |
| - name: Check spelling | |
| run: codespell . | |
| - name: Lint with Flake8 (for docstrings) | |
| if: ${{ contains('3.12,3.13', matrix.python) }} | |
| # Flake8 crashes on Python < 3.12, so we exclude those versions. | |
| # Flake8 is primarily here to lint the docstrings, which | |
| # does not need to happen under multiple versions. | |
| run: flake8 src | |
| - name: Test with pytest | |
| run: pytest --cov=src --cov-report=lcov | |
| - name: Upload code coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-${{ matrix.python }} | |
| path: ./coverage.lcov | |
| - name: Analyse with MyPy | |
| run: mypy | |
| test-with-unpinned-deps: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Install Dependencies | |
| run: pip install -e .[dev] | |
| - name: Print installed packages | |
| run: pip freeze | |
| - name: Lint with Ruff | |
| run: ruff check . | |
| - name: Format with Ruff | |
| if: success() || failure() | |
| run: ruff format --check . | |
| - name: Analyse with MyPy | |
| if: success() || failure() | |
| run: mypy | |
| - name: Test with pytest | |
| if: success() || failure() | |
| run: pytest --cov=src --cov-report=lcov | |
| - name: Check quickstart, including installation | |
| if: success() || failure() | |
| run: bash ./docs/source/quickstart/test_quickstart_example.sh | |
| coverage: | |
| runs-on: ubuntu-latest | |
| needs: [base_coverage, test] | |
| steps: | |
| - name: Download code coverage report | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage-3.12 | |
| - name: Download code coverage report for base branch | |
| id: download-base-coverage | |
| continue-on-error: true | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: base-coverage.lcov | |
| - name: Generate Code Coverage report | |
| # Note, due to continue on error (to make job pass) we need to check the | |
| # Status of the step directly not just use success() or failure() | |
| if: steps.download-base-coverage.outcome == 'success' | |
| id: code-coverage | |
| uses: barecheck/code-coverage-action@v1 | |
| with: | |
| barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }} | |
| lcov-file: "./coverage.lcov" | |
| base-lcov-file: "./base-coverage.lcov" | |
| minimum-ratio: 0 | |
| send-summary-comment: true | |
| show-annotations: "warning" | |
| - name: Generate Code Coverage report if base job fails | |
| if: steps.download-base-coverage.outcome == 'failure' | |
| id: code-coverage-without-base | |
| uses: barecheck/code-coverage-action@v1 | |
| with: | |
| barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }} | |
| lcov-file: "./coverage.lcov" | |
| minimum-ratio: 0 | |
| send-summary-comment: true | |
| show-annotations: "warning" | |
| test-against-ofm-v3: | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| defaults: | |
| run: | |
| working-directory: ../openflexure-microscope-server/ | |
| env: | |
| REF: v3 | |
| steps: &test-against-ofm-steps | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Clone OpenFlexure Microscope Server | |
| working-directory: .. # This step creates the default working directory | |
| run: | | |
| git clone https://gitlab.com/openflexure/openflexure-microscope-server.git | |
| - name: Check out OpenFlexure Microscope Server | |
| run: "git checkout $REF" | |
| - name: Install OpenFlexure Microscope Server | |
| run: "pip install -e ../openflexure-microscope-server/[dev]" | |
| - name: Install LabThings-FastAPI | |
| run: "pip install -e ../labthings-fastapi" | |
| - name: Print installed packages | |
| run: "pip freeze" | |
| - name: Configure Git identity | |
| run: | | |
| git config --global user.name "Sir Unit of Test" | |
| git config --global user.email "bogus@email.com" | |
| - name: Pull OFM web app | |
| run: python ./pull_webapp.py | |
| - name: Run OFM unit tests | |
| run: pytest | |
| - name: Run OFM integration tests | |
| run: pytest tests/integration_tests | |
| - name: Run OFM lifecycle test | |
| run: tests/lifecycle_test/testfile.py | |
| - name: Type check with `mypy` | |
| run: mypy src | |
| check-for-ofm-feature-branch: | |
| # This job runs only if a feature branch is specified in the merge request description. | |
| # The line below looks for a line starting with `OFM Feature Branch:`. This should | |
| # match the `grep` command in the step script. | |
| if: contains(toJson(github.event.pull_request.body), '\r\nOFM Feature Branch:') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| feature-branch: ${{ steps.determine-feature-branch.outputs.feature-branch}} | |
| steps: | |
| - name: Determine feature branch | |
| env: | |
| PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} | |
| # The `if:` block for this job has already checked we will have a matching line. | |
| # The logic below will first extract the matching line from the PR description, | |
| # then remove the prefix so we're left with only the branch name, which we check | |
| # out. | |
| run: | | |
| matching_line=$(echo "$PULL_REQUEST_BODY" | grep "^OFM Feature Branch:") | |
| feature_branch="${matching_line##"OFM Feature Branch: "}" | |
| echo "Using feature branch '$feature_branch'" | |
| echo "feature-branch=$feature_branch" >> "$GITHUB_OUTPUT" | |
| id: determine-feature-branch | |
| test-against-ofm-feature-branch: | |
| # This job uses the feature branch found by the previous job. | |
| # It is split from that job in order to allow re-use of the steps from | |
| # test-against-ofm-v3 | |
| needs: check-for-ofm-feature-branch | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| defaults: | |
| run: | |
| working-directory: ../openflexure-microscope-server/ | |
| env: | |
| REF: ${{ needs.check-for-ofm-feature-branch.outputs.feature-branch }} | |
| steps: *test-against-ofm-steps | |