Skip to content

Commit 7965ca5

Browse files
committed
Initial commit
0 parents  commit 7965ca5

111 files changed

Lines changed: 69011 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
*.py text eol=lf
3+
*.sh text eol=lf

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build Check
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
name: Verify Package Build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v4
22+
with:
23+
enable-cache: true
24+
cache-dependency-glob: "pyproject.toml"
25+
26+
- name: Build package
27+
run: uv build --sdist --wheel --out-dir dist/
28+
29+
- name: List distribution file sizes
30+
run: du -h dist/*
31+
32+
- name: Check distribution metadata
33+
run: uv run --with twine twine check --strict dist/*
34+
35+
- name: Install wheel into isolated directory
36+
run: |
37+
mkdir ./tmp_install
38+
uv pip install --target=./tmp_install $(find dist -type f -name "*.whl" | head -1)
39+
40+
- name: Verify package imports
41+
run: |
42+
PYTHONPATH=./tmp_install uv run python -c "import solarfarmer; print(solarfarmer.__version__)"

.github/workflows/docs.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: false
16+
17+
jobs:
18+
deploy:
19+
name: Deploy Documentation
20+
if: github.repository == 'dnv-opensource/solarfarmer-python-sdk'
21+
runs-on: ubuntu-latest
22+
23+
environment:
24+
name: github-pages
25+
url: ${{ steps.deployment.outputs.page_url }}
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Configure GitHub Pages
32+
uses: actions/configure-pages@v5
33+
34+
- name: Set up Python with uv
35+
uses: astral-sh/setup-uv@v4
36+
with:
37+
python-version: "3.11"
38+
39+
- name: Set cache key
40+
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
41+
42+
- name: Cache dependencies
43+
uses: actions/cache@v4
44+
with:
45+
key: uv-solarfarmer-${{ env.cache_id }}
46+
path: ~/.cache/uv
47+
restore-keys: |
48+
uv-solarfarmer-
49+
50+
- name: Install documentation dependencies
51+
run: uv sync --extra docs
52+
53+
- name: Determine version from git
54+
id: version
55+
run: |
56+
# Use tag version if on a tagged commit, otherwise use dev
57+
if git describe --tags --exact-match 2>/dev/null; then
58+
VERSION=$(git describe --tags --exact-match | sed 's/^v//')
59+
else
60+
VERSION="dev"
61+
fi
62+
echo "DOCS_VERSION=$VERSION" >> $GITHUB_ENV
63+
echo "Building documentation with version: $VERSION"
64+
65+
- name: Build documentation
66+
run: uv run zensical build --clean
67+
68+
- name: Validate build output
69+
run: |
70+
if [ ! -d "site" ]; then
71+
echo "Error: site/ directory not found"
72+
exit 1
73+
fi
74+
if [ -z "$(ls -A site)" ]; then
75+
echo "Error: site/ directory is empty"
76+
exit 1
77+
fi
78+
echo "Build validation successful"
79+
80+
- name: Upload Pages artifact
81+
uses: actions/upload-pages-artifact@v4
82+
with:
83+
path: site
84+
85+
- name: Deploy to GitHub Pages
86+
id: deployment
87+
uses: actions/deploy-pages@v4

.github/workflows/lint.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
name: Ruff Lint & Format
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python with uv
23+
uses: astral-sh/setup-uv@v4
24+
with:
25+
python-version: "3.11"
26+
enable-cache: true
27+
cache-dependency-glob: "pyproject.toml"
28+
29+
- name: Install dependencies
30+
run: uv sync --extra dev
31+
32+
- name: Run Ruff linter
33+
run: uv run ruff check solarfarmer/ tests/ --output-format=github
34+
35+
- name: Run Ruff formatter check
36+
run: uv run ruff format --check solarfarmer/ tests/

.github/workflows/publish.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch: # Manual trigger for testing builds
8+
inputs:
9+
dry_run:
10+
description: "Dry run (build only, skip publish)"
11+
type: boolean
12+
default: true
13+
14+
jobs:
15+
build:
16+
name: Build Package
17+
if: github.repository == 'dnv-opensource/solarfarmer-python-sdk'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v4
24+
with:
25+
enable-cache: true
26+
cache-dependency-glob: "pyproject.toml"
27+
28+
- name: Verify tag matches pyproject.toml version
29+
if: github.event_name == 'push'
30+
run: |
31+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
32+
PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
33+
echo "Tag version: $TAG_VERSION"
34+
echo "pyproject version: $PYPROJECT_VERSION"
35+
if [ "$TAG_VERSION" != "$PYPROJECT_VERSION" ]; then
36+
echo "ERROR: git tag v${TAG_VERSION} does not match pyproject.toml version ${PYPROJECT_VERSION}."
37+
echo "Bump the version in pyproject.toml and commit before tagging."
38+
exit 1
39+
fi
40+
41+
- name: Build package
42+
run: uv build --sdist --wheel --out-dir dist/
43+
44+
- name: List distribution file sizes
45+
run: du -h dist/*
46+
47+
- name: Check distribution metadata
48+
run: uv run --with twine twine check --strict dist/*
49+
50+
- name: Install wheel into isolated directory
51+
run: |
52+
mkdir ./tmp_install
53+
uv pip install --target=./tmp_install $(find dist -type f -name "*.whl" | head -1)
54+
55+
- name: Verify package imports and list installed sizes
56+
run: |
57+
PYTHONPATH=./tmp_install uv run python -c "import solarfarmer; print(solarfarmer.__version__)"
58+
du -h solarfarmer
59+
working-directory: ./tmp_install
60+
61+
- name: Upload artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: dist
65+
path: dist/
66+
if-no-files-found: error
67+
68+
publish-pypi:
69+
name: Publish to PyPI
70+
needs: build
71+
runs-on: ubuntu-latest
72+
if: github.event_name == 'push' && !inputs.dry_run
73+
environment:
74+
name: pypi
75+
url: https://pypi.org/p/dnv-solarfarmer
76+
permissions:
77+
id-token: write
78+
steps:
79+
- uses: actions/download-artifact@v4
80+
with:
81+
name: dist
82+
path: dist/
83+
84+
- name: Publish to PyPI
85+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: Test (Python ${{ matrix.python-version }}, ${{ matrix.os }})
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, macos-latest, windows-latest]
21+
python-version: ["3.10", "3.11", "3.12", "3.13"]
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python ${{ matrix.python-version }} with uv
28+
uses: astral-sh/setup-uv@v4
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Install dependencies
33+
run: uv sync --extra test
34+
35+
- name: Run tests
36+
run: uv run pytest tests/ -v

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
__pycache__/
2+
*.py[cod]
3+
*.pyo
4+
*.pyc
5+
6+
# Virtual environments
7+
.venv/
8+
venv/
9+
10+
# Distribution / packaging
11+
build/
12+
dist/
13+
*.egg-info/
14+
*.egg
15+
.eggs/
16+
17+
# uv
18+
uv.lock
19+
20+
# IDE/editor
21+
.vscode/
22+
.idea/
23+
24+
# Coverage / test
25+
.coverage
26+
htmlcov/
27+
.pytest_cache
28+
tests/__pycache__
29+
\tpytest -q
30+
31+
# MkDocs site output
32+
site/
33+
\tmkdocs build
34+
35+
# OS junk
36+
.DS_Store
37+
38+
public
39+
*.ipynb_checkpoints
40+
api_call_endpoints.py

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
args: ['--unsafe']
11+
- id: check-added-large-files
12+
- id: check-toml
13+
- id: check-json
14+
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
# Ruff version
17+
rev: v0.14.14
18+
hooks:
19+
# Run the linter.
20+
- id: ruff
21+
args: [ --fix ]
22+
# Run the formatter.
23+
- id: ruff-format

0 commit comments

Comments
 (0)