-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ait-energy/dev
Set up basic CI
- Loading branch information
Showing
10 changed files
with
102 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Run Python tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
run_tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
- name: Setup a local virtual environment (if no poetry.toml file) | ||
run: | | ||
poetry config virtualenvs.create true --local | ||
poetry config virtualenvs.in-project true --local | ||
- uses: actions/cache@v3 | ||
name: Define a cache for the virtual environment based on the dependencies lock file | ||
with: | ||
path: ./.venv | ||
key: venv-${{ hashFiles('poetry.lock') }} | ||
- name: Install the project dependencies | ||
run: poetry install --with test | ||
- name: Run the automated tests | ||
run: poetry run pytest | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4.0.1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: ait-energy/iesopt |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Tests & Code Quality | ||
|
||
## Format and lint | ||
|
||
Use | ||
|
||
```bash | ||
black . | ||
ruff . | ||
``` | ||
|
||
Commit pure formatting changes using `chore: formatting`. | ||
|
||
## Running tests | ||
|
||
```bash | ||
pytest | ||
``` | ||
|
||
This will print a coverage report, which looks like | ||
|
||
```text | ||
Name Stmts Miss Cover | ||
-------------------------------------------------- | ||
src/iesopt/__init__.py 33 4 88% | ||
src/iesopt/general.py 0 0 100% | ||
... | ||
src/iesopt/util/logging.py 7 0 100% | ||
src/iesopt/util/util.py 5 0 100% | ||
-------------------------------------------------- | ||
TOTAL 417 172 59% | ||
``` | ||
|
||
and tells you roughly how good each file is covered by automated tests. Further it creates a `coverage.xml` file in the project root folder, that you can use. In `VSCode`, the extension [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) allows inspecting test coverage directly in your code editor. If you have it installed and loaded, simply hit `Ctrl + Shift + 8` (if you are using default keybinds) to enable watching the coverage. | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
from .general import initialize | ||
|
||
from .util import jl_safe_seval, jl_import | ||
from .general import initialize as initialize | ||
from .util import jl_import as jl_import |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
from .logging import logger | ||
from .util import set_iesopt_module_attr, get_iesopt_module_attr | ||
from .logging import logger as logger | ||
from .util import ( | ||
set_iesopt_module_attr as set_iesopt_module_attr, | ||
get_iesopt_module_attr as get_iesopt_module_attr, | ||
) |
This file contains 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