Skip to content

Commit

Permalink
ci: cleanup (#140)
Browse files Browse the repository at this point in the history
- **update 13 files and delete 9 files**
- **update 8 files, copy 1 file and create 2 files**
- **test: update test_markdown.py**
- **update Dockerfile and main.py**
- **update 11 files and delete 3 files**
- **update docker_smoketest.yml, .gitignore, Makefile and __main__.py**
- **update 5 files**
- **chore: update 1 file and delete 1 file**
  • Loading branch information
MartinBernstorff authored Jun 21, 2024
1 parent 78ba12a commit fc59a10
Show file tree
Hide file tree
Showing 39 changed files with 435 additions and 572 deletions.
4 changes: 2 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: ae075e2
_commit: ac0611c
_src_path: https://github.com/MartinBernstorff/nimble-python-template
email: [email protected]
full_name: Martin Bernstorff
github_username: MartinBernstorff
package_name: memorymarker
project_name: memorymarker
project_slug: memorymarker
python_version: '3.12'
python_version: '3.11'
release_docker_image: true
release_package: true
162 changes: 162 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# macOS
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
*.whl

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

.ruff_cache

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# Tests
.testmondata*
8 changes: 4 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OMNIVORE_API_KEY=""
OPENAI_API_KEY=""
ANTHROPIC_API_KEY=""
AIRTABLE_PAT=""
OMNIVORE_API_KEY=
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
MAX_N=
7 changes: 3 additions & 4 deletions .github/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12
FROM python:3.11

# Set the working directory to /app
WORKDIR /app
Expand All @@ -7,16 +7,15 @@ ENV RYE_HOME="/opt/rye"
ENV PATH="$RYE_HOME/shims:$PATH"
ENV RYE_INSTALL_OPTION="--yes"
ENV RYE_TOOLCHAIN="/usr/local/bin/python"
ENV RYE_VERSION=0.26.0
ENV RYE_VERSION=0.33.0

RUN curl -sSf https://rye-up.com/get > /tmp/get-rye.sh
RUN curl -sSf https://rye.astral.sh/get > /tmp/get-rye.sh
RUN bash /tmp/get-rye.sh
RUN rm /tmp/get-rye.sh
RUN echo 'source "$HOME/.rye/env"' >> ~/.bashrc

RUN rye config --set-bool behavior.use-uv=true
RUN rye config --set-bool behavior.global-python=true
RUN rye config --set default.dependency-operator="~="

COPY Makefile ./
COPY pyproject.toml ./
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{steps.meta.outputs.tags }}
tags: ${{ steps.meta.outputs.tags }}
8 changes: 7 additions & 1 deletion .github/workflows/docker_smoketest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ jobs:
- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Get environment variables
run: |
echo "OMNIVORE_API_KEY=${{ secrets.OMNIVORE_API_KEY }}" >> .env
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }}" >> .env
- name: Run integration test
shell: bash
run: |
docker build -t memorymarker -f Dockerfile .
make docker-smoketest
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# macOS
.DS_Store

# IDEs
.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -164,3 +167,7 @@ cython_debug/
# Cache
omnivore_cache/
profile.html

*.smoketest*
compose.yml
smoketest_output
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12
FROM python:3.11

# Set the working directory to /app
WORKDIR /app
Expand All @@ -7,16 +7,19 @@ ENV RYE_HOME="/opt/rye"
ENV PATH="$RYE_HOME/shims:$PATH"
ENV RYE_INSTALL_OPTION="--yes"
ENV RYE_TOOLCHAIN="/usr/local/bin/python"
ENV RYE_VERSION=0.26.0
ENV RYE_VERSION=0.33.0

RUN curl -sSf https://rye-up.com/get > /tmp/get-rye.sh
RUN curl -sSf https://rye.astral.sh/get > /tmp/get-rye.sh
RUN bash /tmp/get-rye.sh
RUN rm /tmp/get-rye.sh
RUN echo 'source "$HOME/.rye/env"' >> ~/.bashrc

RUN rye config --set-bool behavior.use-uv=true
RUN rye config --set-bool behavior.global-python=true
RUN rye config --set default.dependency-operator="~="

COPY . /app
RUN make quicksync
COPY pyproject.toml requirements.lock requirements-dev.lock ./
RUN rye sync --no-lock

COPY . /app/
RUN rye sync --no-lock
ENTRYPOINT ["python", "-m", "memorymarker"]
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ quicksync:
rye sync --no-lock

test:
@rye run pytest --cov=$(SRC_PATH) $(SRC_PATH) --cov-report xml:.coverage.xml --cov-report lcov:.coverage.lcov --testmon
rye test

test-with-coverage:
@echo "––– Testing –––"
Expand All @@ -24,9 +24,7 @@ test-with-coverage:
lint: ## Format code
@echo "––– Linting –––"
@rye run ruff format .
@rye run ruff . --fix --unsafe-fixes \
--extend-select F401 \
--extend-select F841
@rye run ruff . --fix --unsafe-fixes
@echo "✅✅✅ Lint ✅✅✅"

types: ## Type-check code
Expand All @@ -46,12 +44,19 @@ docker_ci: ## Run all checks in docker
docker build -t memorymarker_ci -f .github/Dockerfile.dev .
docker run --env-file .env memorymarker_ci make validate_ci

pr: ## Submit a PR
@lumberman sync --squash --automerge

#########################
# End template makefile #
#########################

docker-smoketest:
cp compose.sample.yml compose.smoketest.yml
perl -pi -e 's#YOUR_OUTPUT_DIR#./smoketest_output#' compose.smoketest.yml

cp .env .env.smoketest
echo "MAX_N=1" >> .env.smoketest

docker build . -t ghcr.io/martinbernstorff/memorymarker:latest
docker compose -f compose.smoketest.yml --env-file .env.smoketest up

update-snapshots:
@rye run pytest --snapshot-update
Loading

0 comments on commit fc59a10

Please sign in to comment.