Skip to content

Commit

Permalink
set up cicd (#1)
Browse files Browse the repository at this point in the history
* set up cicd

* fix linting

* install dev deps in cicd

* update flake8

* add pytest

* use pdm in cicd

* add tests for specs

* add xarray
  • Loading branch information
leifdenby authored Apr 9, 2024
1 parent 42cd88f commit 53df4cb
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci-pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: linting

on:
push:
branches: "*"
pull_request:
branches: "*"

jobs:
linting:
name: "pre-commit hooks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
24 changes: 24 additions & 0 deletions .github/workflows/ci-pypi-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: package-release

on:
workflow_dispatch:
pull_request:
push:
branches:
- master
release:
types:
- published

jobs:
build:
name: build and upload release to pypi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: casperdcl/deploy-pypi@v2
with:
password: ${{ secrets.PYPI_TOKEN }}
pip: wheel -w dist/ --no-deps .
upload: ${{ github.event_name == 'release' && github.event.action == 'published' }}
22 changes: 22 additions & 0 deletions .github/workflows/python-package-pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test
on: [push, pull_request]

jobs:
test:
name: Test pip install python ${{ matrix.python-version }} on ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.9]
steps:
- uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
- name: Install package with pdm
run: |
pdm install
- name: Run tests
run: |
pdm run python -m pytest
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ repos:
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8
188 changes: 186 additions & 2 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies = [
"pyyaml>=6.0.1",
"loguru>=0.7.2",
"zarr>=2.17.2",
"xarray>=2024.3.0",
]
requires-python = ">=3.9"
readme = "README.md"
Expand All @@ -25,6 +26,7 @@ distribution = true
[tool.pdm.dev-dependencies]
dev = [
"pre-commit>=3.7.0",
"pytest>=8.1.1",
]

[tool.isort]
Expand Down
11 changes: 8 additions & 3 deletions src/mllam_data_interface/check.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import importlib
from pathlib import Path

import xarray as xr
import yaml
import importlib

SPECS_ROOT_PATH = Path(__file__).parent.parent.parent / "specs"

Expand Down Expand Up @@ -30,13 +30,18 @@ def load_spec(spec_identifier: str):
spec_name, spec_version = spec_identifier.split(":")

# fp = SPECS_ROOT_PATH / spec_name / f"{spec_version}.yaml"
fp = importlib.resources.files(__package__) / "specs" / spec_name / f"{spec_version}.yaml"
fp = (
importlib.resources.files(__package__)
/ "specs"
/ spec_name
/ f"{spec_version}.yaml"
)
if not fp.exists():
raise ValueError(f"Spec file {fp} for {spec_identifier} does not exist.")

with open(fp, "r") as f:
spec = yaml.safe_load(f)

return spec


Expand Down
Loading

0 comments on commit 53df4cb

Please sign in to comment.