Skip to content

Commit 5721e8c

Browse files
authored
Merge pull request #54 from tschm/master
Run your tests after every commit
2 parents ef9cc20 + f00727a commit 5721e8c

Some content is hidden

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

57 files changed

+5349
-248
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
*.py linguist-language=Python
22
*.ipynb linguist-language=Python
3-
*.html linguist-language=Python
3+
*.html linguist-language=Python
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build Environment
2+
description: "Build the environment using pyproject.toml and uv"
3+
4+
inputs:
5+
python-version:
6+
description: 'The Python we shall use'
7+
required: false
8+
default: '3.9'
9+
10+
runs:
11+
using: "composite"
12+
13+
steps:
14+
- name: Checkout [${{ github.repository }}]
15+
uses: actions/checkout@v4
16+
17+
# Install UV (Unix)
18+
- name: Install UV (Unix)
19+
if: runner.os == 'Linux' || runner.os == 'macOS'
20+
shell: bash
21+
run: |
22+
set -eo pipefail
23+
curl -LsSf https://astral.sh/uv/install.sh | sh
24+
echo "$HOME/.local/bin" >> $GITHUB_PATH
25+
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
26+
27+
# Ensure the venv/bin is first in the PATH
28+
unset PYTHONHOME # Unset the PYTHONHOME environment variable
29+
# if set to avoid any system Python fallback
30+
31+
32+
# Install UV (Windows)
33+
- name: Install UV (Windows)
34+
if: runner.os == 'Windows'
35+
shell: pwsh
36+
run: |
37+
irm https://astral.sh/uv/install.ps1 | iex
38+
$uvPath = "C:\Users\runneradmin\.local\bin"
39+
Add-Content $env:GITHUB_PATH $uvPath
40+
41+
# Modify PATH to only include the virtual environment's Scripts directory
42+
Add-Content $env:GITHUB_PATH ${{ github.workspace }}\.venv\Scripts
43+
44+
# Unset PYTHONHOME to avoid any system Python being used
45+
Remove-Item -Path Env:PYTHONHOME -ErrorAction SilentlyContinue
46+
47+
- name: Install pip and create venv
48+
shell: bash
49+
run: |
50+
# Create virtual environment with uv
51+
uv venv --python ${{ inputs.python-version }}
52+
53+
# Ensure pip is installed and up-to-date in the virtual environment
54+
python -m ensurepip --upgrade
55+
56+
# run if the file pyproject.toml exists
57+
- name: Install the dependencies
58+
shell: bash
59+
run : |
60+
# Sync environment (install dependencies)
61+
if [ -f "uv.lock" ]; then
62+
uv sync --all-extras --dev --frozen # Install all dependencies (including dev dependencies)
63+
else
64+
uv sync --all-extras --dev # Install all dependencies (including dev dependencies)
65+
fi

.github/actions/tag/action.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "Bump version and create release"
2+
description: "Bumps version, creates a tag, and publishes a release."
3+
4+
inputs:
5+
github_token:
6+
description: "GitHub token for authentication"
7+
required: true
8+
9+
outputs:
10+
tag:
11+
description: 'A new tag'
12+
value: ${{ steps.tag_version.outputs.new_tag }}
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
# -----------------------------------------------------------------------------
18+
# Step 2: Bump version and tag
19+
# -----------------------------------------------------------------------------
20+
- name: Bump version and tag
21+
id: tag_version
22+
uses: mathieudutour/[email protected]
23+
with:
24+
github_token: ${{ inputs.github_token }}
25+
26+
# -----------------------------------------------------------------------------
27+
# Step 3: Install dependencies (hatch for packaging)
28+
# -----------------------------------------------------------------------------
29+
- name: Install dependencies
30+
shell: bash
31+
run: |
32+
python -m pip install --upgrade hatch
33+
34+
# -----------------------------------------------------------------------------
35+
# Step 4: Update version in pyproject.toml
36+
# -----------------------------------------------------------------------------
37+
- name: Update version in pyproject.toml
38+
shell: bash
39+
run: |
40+
echo "Updating version to ${{ steps.tag_version.outputs.new_tag }}"
41+
sed -i "s/0.0.0/${{ steps.tag_version.outputs.new_tag }}/" pyproject.toml
42+
43+
# -----------------------------------------------------------------------------
44+
# Step 5: Build the package
45+
# -----------------------------------------------------------------------------
46+
- name: Build package
47+
shell: bash
48+
run: |
49+
hatch build
50+
51+
# -----------------------------------------------------------------------------
52+
# Step 6: Upload build artifacts
53+
# -----------------------------------------------------------------------------
54+
- name: Upload distribution artifacts
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: dist
58+
path: dist/
59+
retention-days: 1
60+
61+
# -----------------------------------------------------------------------------
62+
# Step 7: Create GitHub release
63+
# -----------------------------------------------------------------------------
64+
- name: Create GitHub release with artifacts
65+
uses: softprops/action-gh-release@v2
66+
with:
67+
tag_name: ${{ steps.tag_version.outputs.new_tag }}
68+
generate_release_notes: true
69+
files: dist/*
70+
71+
- name: Debug Output Tag
72+
shell: bash
73+
run: |
74+
echo "DEBUG: ${{ steps.tag_version.outputs.new_tag }}"

.github/actions/test/action.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run Tests
2+
description: "Run pytest test suite"
3+
4+
inputs:
5+
tests-folder:
6+
description: 'Source folder with all tests'
7+
required: false
8+
default: 'tests'
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Update pip
14+
shell: bash
15+
run: |
16+
# Ensure pip is installed and up-to-date
17+
python -m ensurepip --upgrade
18+
19+
- name: Run tests
20+
shell: bash
21+
run: |
22+
python -m pip install --no-cache-dir pytest
23+
pytest ${{ inputs.tests-folder }}

.github/workflows/deptry.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: DEPTRY
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
deptry:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout [${{ github.repository }}]
11+
uses: actions/checkout@v4
12+
13+
- name: "Build the virtual environment for ${{ github.repository }}"
14+
uses: ./.github/actions/environment
15+
16+
- name: Run deptry
17+
run: |
18+
# Ensure pip is installed and up-to-date
19+
# python -m ensurepip --upgrade
20+
# python -m pip install --no-cache-dir deptry
21+
python -m deptry finmarketpy

.github/workflows/pre-commit.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: pre-commit
2+
3+
on:
4+
push:
5+
6+
permissions:
7+
checks: write
8+
contents: read
9+
10+
jobs:
11+
pre-commit:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v4
16+
17+
- uses: pre-commit/[email protected]
18+
with:
19+
extra_args: '--verbose --all-files'

.github/workflows/release.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bump version
2+
on:
3+
workflow_dispatch
4+
5+
permissions:
6+
contents: write
7+
jobs:
8+
tag:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout [${{ github.repository }}]
12+
uses: actions/checkout@v4
13+
14+
- name: Bump version and tag
15+
uses: ./.github/actions/tag
16+
with:
17+
github_token: ${{ secrets.GITHUB_TOKEN }}
18+
19+
publish:
20+
needs: tag
21+
runs-on: ubuntu-latest
22+
environment: release
23+
24+
permissions:
25+
contents: read
26+
# This permission is required for trusted publishing.
27+
id-token: write
28+
29+
steps:
30+
- name: Checkout [${{ github.repository }}]
31+
uses: actions/checkout@v4
32+
33+
- uses: actions/download-artifact@v4
34+
with:
35+
name: dist
36+
path: dist
37+
38+
- name: Publish to PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "CI"
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
test:
8+
# The type of runner that the job will run on
9+
runs-on: ${{ matrix.os }}
10+
11+
strategy:
12+
matrix:
13+
os: [ ubuntu-latest, windows-latest, macos-latest ]
14+
python-version: [ '3.9' ] # '3.10', '3.11', '3.12', '3.13' ]
15+
16+
# Steps represent a sequence of tasks that will be executed as part of the job
17+
steps:
18+
- name: Checkout [${{ github.repository }}]
19+
uses: actions/checkout@v4
20+
21+
- name: "Build the virtual environment for ${{ github.repository }}"
22+
uses: ./.github/actions/environment
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- uses: ./.github/actions/test
27+
with:
28+
tests-folder: tests

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
33
*.py[cod]
4+
.venv
45

56
# C extensions
67
*.so
@@ -66,4 +67,3 @@ docs/_build/
6667
target/
6768

6869
# Output Files
69-

.pre-commit-config.yaml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-toml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
9+
# - repo: https://github.com/charliermarsh/ruff-pre-commit
10+
# rev: 'v0.9.6'
11+
# hooks:
12+
# - id: ruff
13+
# args: [ --fix, --exit-non-zero-on-fix ]
14+
# # Run the formatter
15+
# - id: ruff-format
16+
# exclude: src/tests
17+
#
18+
# - repo: https://github.com/igorshubovych/markdownlint-cli
19+
# rev: v0.44.0
20+
# hooks:
21+
# - id: markdownlint
22+
# args: [ "--ignore", "book/**/*.md" ]
23+
#
24+
# - repo: https://github.com/asottile/pyupgrade
25+
# rev: v3.19.1
26+
# hooks:
27+
# - id: pyupgrade
28+
# args: [--py311-plus]
29+
#
30+
- repo: https://github.com/python-jsonschema/check-jsonschema
31+
rev: 0.31.2
32+
hooks:
33+
# - id: check-dependabot
34+
# args: ["--verbose"]
35+
# - id: check-renovate
36+
# args: ["--verbose"]
37+
- id: check-github-workflows
38+
args: ["--verbose"]
39+
40+
- repo: https://github.com/rhysd/actionlint
41+
rev: v1.7.7
42+
hooks:
43+
- id: actionlint
44+
args: [-ignore, SC]
45+
46+
- repo: https://github.com/abravalheri/validate-pyproject
47+
rev: v0.23
48+
hooks:
49+
- id: validate-pyproject
50+
#
51+
# - repo: https://github.com/crate-ci/typos
52+
# rev: v1.30.1
53+
# hooks:
54+
# - id: typos
55+
# exclude: ^\.gitignore|\.copier.answers$
56+
57+
#- repo: https://github.com/PyCQA/bandit
58+
# rev: 1.8.3
59+
# hooks:
60+
# - id: bandit
61+
# args: ["-c", "pyproject.toml"]
62+
# additional_dependencies: ["bandit[toml]"]

INSTALL.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ various Python libraries. The Cuemacro libraries will install most Python depend
7070
* Install finmarketpy, findatapy and chartpy the easy way...
7171
* You can install some Python data science conda environments that I use for teaching
7272
which include finmarketpy, findatapy and chartpy
73-
* Instructions on how to install Anaconda and the py37class conda environment at
73+
* Instructions on how to install Anaconda and the py37class conda environment at
7474
[https://github.com/cuemacro/teaching/blob/master/pythoncourse/installation/installing_anaconda_and_pycharm.ipynb](https://github.com/cuemacro/teaching/blob/master/pythoncourse/installation/installing_anaconda_and_pycharm.ipynb)
7575

7676
* Python libraries (open source)
@@ -80,7 +80,7 @@ various Python libraries. The Cuemacro libraries will install most Python depend
8080
* Also compresses data contents
8181
* blpapi - https://www.bloomberglabs.com/api/libraries/ (both C++ and Python libraries)
8282
* Interact with Bloomberg programmatically via Python to download historical and live data
83-
* Note that may need requires a C++ compiler to build the Python library
83+
* Note that may need requires a C++ compiler to build the Python library
8484
* Follow instructions at [https://github.com/cuemacro/findatapy/blob/master/BLOOMBERG.md](https://github.com/cuemacro/findatapy/blob/master/BLOOMBERG.md) for all the steps necessary to install blpapi
8585
* Whilst Anaconda has most of the dependencies below and pip will install all additional ones needed by the Cuemacro Python
8686
libraries it is possible to install them manually via pip, below is a list of the dependencies
@@ -97,7 +97,7 @@ various Python libraries. The Cuemacro libraries will install most Python depend
9797
* redis - Python wrapper to access Redis, in-memory database, like a hashtable (Anaconda Linux/Mac)
9898
* `brew reinstall redis` (Unix)
9999
* openpyxl - writing Excel spreadsheets to disk (Anaconda)
100-
* pyarrow - for caching
100+
* pyarrow - for caching
101101
* keyring - for storing passwords
102102
* arctic - wrapper on MongoDB (see below for installation)
103103
* blpapi - Python API for Bloomberg (see below for installation)
@@ -257,4 +257,4 @@ This will keep code you are working on separate from the site-packages directory
257257

258258
```
259259
conda create -n devcuemacro python=3.6 anaconda
260-
```
260+
```

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
recursive-include finmarketpy/ *.*
22
recursive-include finmarketpy_examples/ *.*
33

4-
global-exclude *.py[cod] __pycache__ *.so *.pdf
4+
global-exclude *.py[cod] __pycache__ *.so *.pdf

0 commit comments

Comments
 (0)