Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ Global Options
-c FILE, --config FILE Read configuration from the given file [default
value: ``config.yml``]

-E FILE, --env FILE Load environment variables from the given
``.env`` file. By default, environment
variables are loaded from the first file named
"``.env``" found by searching from the current
directory upwards.
Copy link
Copy Markdown
Member

@yarikoptic yarikoptic May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just setup a $PWD.env file with secrets and which I source before running...

We need a big fat warning here though -- in datalad mode or just with pure git users might commit and leak it. Conscientious of the problem user can configure .gitignore or add it to git-annex while annotating with metadata to not distribute with default datalad push or publish commands, but it should be for user to decide...

Suggested change
directory upwards.
directory upwards. WARNING: Placing in the same directory
as output whenever output is to be committed to git must be done
with care: either specify the file to be excluded in ``.gitignore`` or
place it under git-annex control and set it up with all necessary
provisions to avoid public sharing.

tune to your liking

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning added.


**Warning**: Care must be taken when this file
is located in a Git repository so as not to
publicly expose it: either list the file in
``.gitignore`` or, if using Datalad or
git-annex, configure git-annex to prohibit
public sharing of the file.

-l LEVEL, --log-level LEVEL Set the log level to the given value. Possible
values are "``CRITICAL``", "``ERROR``",
"``WARNING``", "``INFO``", "``DEBUG``" (all
Expand Down Expand Up @@ -326,6 +339,9 @@ Path templates may also contain custom placeholders defined in the top-level
Authentication
--------------

Note that environment variables can be loaded from a ``.env`` file as an
alternative to setting them directly in the environment.

GitHub
~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ package_dir =
=src
python_requires = ~=3.8
install_requires =
click ~= 7.0
click >= 7.0
click-loglevel ~= 0.2
datalad ~= 0.14
in_place ~= 0.4
pydantic ~= 1.7
PyGithub ~= 1.55
python-dateutil ~= 2.7
python-dotenv ~= 0.11
PyYAML ~= 5.0
requests ~= 2.20

Expand Down
10 changes: 9 additions & 1 deletion src/tinuous/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from click_loglevel import LogLevel
from datalad.api import Dataset
from dateutil.parser import isoparse
from dotenv import load_dotenv
from github import Github
from github.Repository import Repository
from github.Workflow import Workflow
Expand Down Expand Up @@ -949,6 +950,12 @@ def _validate_since(cls, v: datetime) -> datetime: # noqa: B902, U100
help="Read configuration from the given file",
show_default=True,
)
@click.option(
"-E",
"--env",
type=click.Path(exists=True, dir_okay=False),
help="Load environment variables from given .env file",
)
@click.option(
"-l",
"--log-level",
Expand All @@ -958,8 +965,9 @@ def _validate_since(cls, v: datetime) -> datetime: # noqa: B902, U100
show_default=True,
)
@click.pass_context
def main(ctx: click.Context, config: str, log_level: int) -> None:
def main(ctx: click.Context, config: str, log_level: int, env: Optional[str]) -> None:
""" Download build logs from GitHub Actions, Travis, and Appveyor """
load_dotenv(env)
logging.basicConfig(
format="%(asctime)s [%(levelname)-8s] %(name)s %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S%z",
Expand Down