Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 100
103 changes: 67 additions & 36 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,87 +4,112 @@ on: [push]

jobs:
lint:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python: ["3.9"]

runs-on: ${{ matrix.os }}
steps:
- name: Run black, flake8, mypy
uses: dls-controls/pipenv-run-action@v1
- name: Checkout Source
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup python
uses: actions/setup-python@v4
with:
pipenv-run: lint
python-version: ${{ matrix.python }}

- name: Install dependancies
run: |
python -m pip install --upgrade pip
pip install .[dev] -r requirements.txt
- name: Run black, flake8, mypy
run: |
pre-commit run --all-files --show-diff-on-failure --color=always -v

wheel:
sdist_wheel:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python: ["3.8"]
python: ["3.9"]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Checkout Source
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create Sdist and Wheel
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Build Sdist
# Set SOURCE_DATE_EPOCH from git commit for reproducible build
# https://reproducible-builds.org/
# Set group writable and umask to do the same to match inside DLS
run: |
chmod -R g+w .
umask 0002
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) pipx run build --sdist --wheel

- name: Upload Wheel and Sdist as artifacts
uses: actions/upload-artifact@v2
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) pipx run --python $(which python${{ matrix.python }}) build --sdist --wheel
- name: Upload Sdist as artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*

- name: Install minimum python version
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Install wheel in a venv and check cli works
# ${GITHUB_REPOSITORY##*/} is the repo name without org
# Replace this with the cli command if different to the repo name
run: pipx run --python $(which python${{ matrix.python }}) --spec dist/*.whl uvicorn --version

test:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
python: ["3.8", "3.9"] # maybe add 3.10 in future
pipenv: ["skip-lock"]
python: ["3.8", "3.9", "3.10"]
deploy: [false]

include:
# Add an extra Python3.8 runner to use the lockfile
- os: "ubuntu-latest"
python: "3.8"
pipenv: "deploy"
deploy: true

runs-on: ${{ matrix.os }}
env:
# https://github.com/pytest-dev/pytest/issues/2042
PY_IGNORE_IMPORTMISMATCH: "1"

steps:
- name: Setup repo and test
uses: dls-controls/pipenv-run-action@v1
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
pipenv-install: --dev --${{ matrix.pipenv }}
allow-editable-installs: ${{ matrix.pipenv == 'deploy' }}
pipenv-run: tests

- name: Install dependencies
if: ${{ !matrix.deploy }}
run: |
python -m pip install --upgrade pip
pip install .[dev]

# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v2
# with:
# name: ${{ matrix.python }}/${{ matrix.os }}/${{ matrix.pipenv }}
# files: cov.xml
- name: Install dependencies (deploy)
if: ${{ matrix.deploy }}
run: |
python -m pip install --upgrade pip
pip install .[dev] -r requirements.txt

- name: Run tests with pytest
run: |
pytest

release:
needs: [lint, wheel, test]
needs: [lint, sdist_wheel, test]
runs-on: ubuntu-latest
# upload to PyPI and make a release on every tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
Expand All @@ -103,3 +128,9 @@ jobs:
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: pipx run twine upload dist/*
21 changes: 16 additions & 5 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout Source
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup repo and test
uses: dls-controls/pipenv-run-action@v1
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.8
pipenv-install: --dev
pipenv-run: python src/diffcalc_API/openapi.py

- name: Install dependencies
if: ${{ !matrix.deploy }}
run: |
python -m pip install --upgrade pip
pip install .[dev] -r requirements.txt

- name: Make openapi.json
run: |
python src/diffcalc_API/openapi.py

- name: Upload
uses: actions/upload-artifact@v2
Expand Down
15 changes: 11 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,26 @@ repos:
name: Run black
stages: [commit]
language: system
entry: pipenv run black --check --diff
entry: black --check --diff
types: [python]

- id: flake8
name: Run flake8
stages: [commit]
language: system
entry: pipenv run flake8
entry: flake8
types: [python]

- id: pydocstyle
name: Run pydocstyle
stages: [commit]
language: system
entry: pydocstyle
files: ^(src\/).*\.py

- id: mypy
name: Run mypy
stages: [commit]
language: system
entry: pipenv run mypy src tests
pass_filenames: false
entry: mypy
files: ^(src\/|tests\/).*\.py
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"type": "shell",
"label": "Tests with coverage",
"command": "pipenv run tests",
"command": "pytest",
"options": {
"cwd": "${workspaceRoot}"
},
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ To get the source source code and run the unit tests, run::

$ git clone git://github.com/dls-controls/diffcalc_API.git
$ cd diffcalc_API
$ pipenv install --dev
$ pipenv run tests
$ pip install -e .[dev]
$ pytest

While 100% code coverage does not make a library bug-free, it significantly
reduces the number of easily caught bugs! Please make sure coverage remains the
Expand All @@ -36,12 +36,12 @@ The code in this repository conforms to standards set by the following tools:
These checks will be run by pre-commit_. You can either choose to run these
tests on all files tracked by git::

$ pipenv run lint
$ pre-commit run --all-files --show-diff-on-failure --color=always -v

Or you can install a pre-commit hook that will run each time you do a ``git
commit`` on just the files that have changed::

$ pipenv run pre-commit install
$ pre-commit install

.. _black: https://github.com/psf/black
.. _flake8: https://flake8.pycqa.org/en/latest/
Expand Down Expand Up @@ -88,7 +88,7 @@ Docs follow the underlining convention::

You can build the docs from the project directory by running::

$ pipenv run docs
$ sphinx-build -EWT --keep-going docs build/html
$ firefox build/html/index.html

Release Process
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ WORKDIR ${ENV_DIR}
COPY . ${ENV_DIR}

#Install dependencies
RUN pip install pipenv; \
pipenv install --system --python 3.8; \
pip uninstall diffcalc-core -y; \
pip install git+https://github.com/DiamondLightSource/diffcalc-core.git
RUN pip install . -c requirements.txt


#Run the API
Expand Down
17 changes: 0 additions & 17 deletions Pipfile

This file was deleted.

Loading