Skip to content

Commit

Permalink
patch: work around pip's secure-install bug; bump version
Browse files Browse the repository at this point in the history
- upstream issue: pypa/pip#9644
- runs tests within a container, uses the same `dockerfile`
- ignores `pdm.lock`, removes `requirement.txt`
- update manual contribution steps
- bumps project version

**Related Items**

_Issues_

- Closes athul#137
  • Loading branch information
yozachar committed Jul 19, 2023
1 parent 78ac94e commit bd07cdc
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 1,095 deletions.
27 changes: 27 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Do NOT edit this file, make
# a copy and rename as `.env`

INPUT_GH_TOKEN=
INPUT_WAKATIME_API_KEY=
# meta
INPUT_API_BASE_URL=
INPUT_REPOSITORY=
# content
INPUT_SHOW_TITLE=
INPUT_SECTION_NAME=
INPUT_BLOCKS=
INPUT_CODE_LANG=
INPUT_TIME_RANGE=
INPUT_LANG_COUNT=
INPUT_SHOW_TIME=
INPUT_SHOW_TOTAL=
INPUT_SHOW_MASKED_TIME=
INPUT_STOP_AT_OTHER=
# commit
INPUT_COMMIT_MESSAGE=
INPUT_TARGET_BRANCH=
INPUT_TARGET_PATH=
INPUT_COMMITTER_NAME=
INPUT_COMMITTER_EMAIL=
INPUT_AUTHOR_NAME=
INPUT_AUTHOR_EMAIL=
22 changes: 11 additions & 11 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: UnitTests
name: WakaReadme CI

on:
push:
Expand All @@ -8,17 +8,17 @@ on:
workflow_dispatch:

jobs:
build:
UnitTests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
- name: Build docker image
run: |
python -m pip install --user --no-cache-dir -r requirements.txt
- name: Run unit tests
run: |
python -m unittest discover
# Clear existing cache
podman builder prune --force
# Build and run container (executes unit tests)
docker compose -p waka-readme -f ./compose.yml up --no-color --pull always --build --force-recreate
# Cleanup
docker compose -p waka-readme -f ./compose.yml down --rmi all
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,27 @@ 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
.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
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
poetry.lock

# pdm
# Similar to poetry.lock, it is generally recommended to include pdm.lock in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
# However, this project does not rely on pdm for production.
pdm.lock
.pdm-python

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
Expand Down
23 changes: 10 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

> First off, thank you! Please follow along.
**You need to _`fork`_ this repository and _`clone`_ it onto your system.** Inside the cloned folder, create a `.env` file with the following contents (without `# comments`):
**You need to _`fork`_ this repository & _`clone`_ it onto your system.** Inside the cloned folder, create a `.env` file with the following contents (without `# comments`):

```ini
INPUT_GH_TOKEN=EXAMPLE_GITHUB_PAT # required (for development)
Expand Down Expand Up @@ -44,26 +44,23 @@ $ podman-compose -p waka-readme -f ./docker-compose.yml down

## Using virtual environments

> Assumes you've already installed & configured latest version of [python](https://www.python.org/) and [pdm](https://pdm.fming.dev/latest/).
> Assumes you've already installed & configured latest version of [python](https://www.python.org/).
1. Inside the cloned folder run the following commands to install dependencies

```console
$ pdm install
$ eval $(pdm venv activate)
$ python -m venv .venv
$ . ./.venv/bin/activate
$ python -m pip install .
```

in a virtual environnement and activate it. In windows use the following

```ps1
> Invoke-Expression (pdm venv activate)
```

to activate virtual environment.
to activate virtual environment & install dependencies.

2. To test or execute the program in development, run:

```console
(waka-readme-py3_11)$ python -m unittest discover # run tests
(waka-readme-py3_11)$ python -m main --dev # execute program in dev mode
(.venv)$ python -m unittest discover # run tests
(.venv)$ python -m main --dev # execute program in dev mode
```

> You can use any other virtual environment & dependency manager as well.
11 changes: 11 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# for CI testing
services:
waka-readme:
env_file:
- .env.template
build:
context: .
dockerfile: dockerfile
image: waka-readme:testing
container_name: WakaReadmeTesting
command: python -m unittest discover
4 changes: 2 additions & 2 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ ENV PATH="${PATH}:/root/.local/bin" \
PIP_DEFAULT_TIMEOUT=100

# copy project files
COPY --chown=root:root requirements.txt main.py /app/
COPY --chown=root:root pyproject.toml main.py /app/

# install dependencies
RUN python -m pip install -r /app/requirements.txt
RUN python -m pip install /app/

# execute program
CMD python /app/main.py
Loading

0 comments on commit bd07cdc

Please sign in to comment.