Skip to content
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
10 changes: 5 additions & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ jobs:
file: dockerfiles/Dockerfile
load: true
- name: Run ruff check
run: docker run --rm ${{ steps.build.outputs.imageid }} poetry run ruff check
run: docker run --rm ${{ steps.build.outputs.imageid }} ruff check
- name: Run format check
run: docker run --rm ${{ steps.build.outputs.imageid }} poetry run ruff format --check
run: docker run --rm ${{ steps.build.outputs.imageid }} ruff format --check
- name: Run mypy
run: docker run --rm ${{ steps.build.outputs.imageid }} poetry run mypy .
run: docker run --rm ${{ steps.build.outputs.imageid }} mypy .
- name: Unit tests
run: docker run --rm ${{ steps.build.outputs.imageid }} poetry run pytest
run: docker run --rm ${{ steps.build.outputs.imageid }} pytest
- name: Run coverage
run: docker run --rm ${{ steps.build.outputs.imageid }} sh -c "poetry run coverage run && poetry run coverage report"
run: docker run --rm ${{ steps.build.outputs.imageid }} sh -c "coverage run && coverage report"
- name: Docs test
run: docker run --rm ${{ steps.build.outputs.imageid }} bash build_docs.sh
2 changes: 1 addition & 1 deletion .github/workflows/nova-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
file: dockerfiles/Dockerfile
load: true
- name: Publish
run: docker run --rm ${{ steps.build.outputs.imageid }} poetry publish -u __token__ -p ${PYPI_API_TOKEN}
run: docker run --rm ${{ steps.build.outputs.imageid }} sh -c "hatch build && hatch publish -u __token__ -a ${PYPI_API_TOKEN}"
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
hooks:
- id: mypy
name: mypy
entry: poetry run mypy .
entry: pixi run mypy .
language: system
types: [python]
verbose: true
Expand Down
23 changes: 10 additions & 13 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ the NOVA Common project.

## Starting from the template

- Add other Python dependencies you project need with `poetry add xxx` or `poetry add --dev xxx`
- Add other Python dependencies you project need with [Pixi add](https://pixi.sh/dev/reference/cli/pixi/add/#pixi-add).
- Modify Dockerfile as needed. Please make sure it can still run as non-root (we use it in GitHub Actions and in general this
is a good practice).
- install pre-commit (if not already installed) - `pip install pre-commit`
- activate `pre-commit` for your project: `cd <project folder> && pre-commit install`
- install pre-commit (if not already installed) - `pixi run pre-commit install`
- finally, clear the content of this section and add the description of your project. You can keep/adjust instructions
below

Expand All @@ -23,30 +22,28 @@ to create an issue [in this repo](https://code.ornl.gov/ndip/project-templates/p
## Installation

```commandline
pip install poetry

poetry install
pixi install
```

## Formatting
```commandline
poetry run ruff format
pixi run ruff format
```

## Linting
```commandline
poetry run ruff check
poetry run mypy .
pixi run ruff check
pixi run mypy .
```

## Testing
```commandline
poetry run pytest
pixi run pytest
```
or, with coverage
```commandline
poetry run coverage run
poetry run coverage report
pixi run coverage run
pixi run coverage report
```

## Updating project from template
Expand All @@ -55,7 +52,7 @@ This project was created from a [template](https://code.ornl.gov/ndip/project-te
can try to update the project to incorporate these changes. Just enter the project folder, make sure `git status`
shows it clean, and run:
```
poetry run copier update
copier update
```
See [here](https://copier.readthedocs.io/en/stable/updating/#updating-a-project) for more information.

Expand Down
4 changes: 2 additions & 2 deletions build_docs.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SPHINX_APIDOC_OPTIONS=members,show-inheritance poetry run sphinx-apidoc -o docs/source src
poetry run sphinx-build -M html docs docs/_build
SPHINX_APIDOC_OPTIONS=members,show-inheritance sphinx-apidoc -o docs/source src
sphinx-build -M html docs docs/_build
29 changes: 21 additions & 8 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
FROM --platform=amd64 python:3.10-slim AS source

Check warning on line 1 in dockerfiles/Dockerfile

View workflow job for this annotation

GitHub Actions / build-and-test

FROM --platform flag should not use a constant value

FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "amd64" More info: https://docs.docker.com/go/dockerfile/rule/from-platform-flag-const-disallowed/

# make sure image can run as non-root user
ENV POETRY_CACHE_DIR=/poetry/.cache
ENV POETRY_CONFIG_DIR=/poetry/.config
ENV POETRY_HOME=/poetry
RUN apt update && apt install -y curl wget

RUN pip install poetry
COPY . /src
WORKDIR /src

RUN poetry install
RUN poetry build --format=wheel
RUN curl -fsSL https://pixi.sh/install.sh | sh
ENV PATH="/root/.pixi/bin:${PATH}"
RUN pixi install
SHELL [ "pixi", "run" ]
ENTRYPOINT [ "pixi", "run" ]

RUN chmod og+rwX -R /src

FROM --platform=amd64 python:3.10-slim AS package

Check warning on line 16 in dockerfiles/Dockerfile

View workflow job for this annotation

GitHub Actions / build-and-test

FROM --platform flag should not use a constant value

FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "amd64" More info: https://docs.docker.com/go/dockerfile/rule/from-platform-flag-const-disallowed/

RUN apt update && apt install -y curl

COPY . /src
WORKDIR /src

RUN curl -fsSL https://pixi.sh/install.sh | sh
ENV PATH="/root/.pixi/bin:${PATH}"
RUN pixi install -e production
SHELL [ "pixi", "run" ]
ENTRYPOINT [ "pixi", "run" ]

RUN chmod og+rwX -R /poetry
RUN chmod og+rwX -R /src
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
copyright = "2024, ORNL"
with open("../pyproject.toml", "rb") as toml_file:
toml_dict = tomli.load(toml_file)
release = toml_dict["tool"]["poetry"]["version"]
release = toml_dict["project"]["version"]

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
Loading