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
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Changelog

## 1.0.8
- Support providing GitHub Token via `APR_API_KEY` env var instead of `config.yaml`

## 1.0.7
- Add `--exclude-missing` when running `auto-pr status`
- Allows you to remove the `Missing PRs` section from the output
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ update_command:
- my-file
```

If you wish to keep your API Key outside of `config.yaml`, set the env var `APR_API_KEY` with your GitHub Token

### Repositories

You can define the list of repositories to pull and build into the database to update using a list of rules.
Expand Down
3 changes: 1 addition & 2 deletions autopr/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from dataclasses import dataclass, field
from os import environ
from typing import List, Optional

import marshmallow_dataclass
Expand All @@ -18,8 +17,8 @@

@dataclass
class Credentials:
api_key: str
ssh_key_file: str
api_key: str = field(default_factory=(lambda: environ.get("APR_API_KEY", "")))


CREDENTIALS_SCHEMA = marshmallow_dataclass.class_schema(Credentials)()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "auto-pr"
version = "1.0.8"
version = "1.0.7"
description = "Perform bulk updates across repositories"
license = "Apache-2.0"

Expand Down
20 changes: 0 additions & 20 deletions test/test_run.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import subprocess
from pathlib import Path
from test.test_utils import (
env_var_token_test_config,
init_git_repos,
run_cli,
simple_test_config,
Expand Down Expand Up @@ -44,22 +43,3 @@ def test_create_files(_create_github_client: Mock, tmp_path):
db=db,
)
print(result.output)


@patch("autopr.repo.run_cmd", new=_test_cmd)
@patch("autopr.github.create_github_client")
def test_api_key_env_var(_create_github_client: Mock, monkeypatch, tmp_path):
monkeypatch.setenv("APR_API_KEY", "env_var_test")
wd = workdir.WorkDir(Path(tmp_path))
db = simple_test_database()
init_git_repos(wd, db)
result = run_cli(
wd,
["run"],
cfg=env_var_token_test_config(),
db=db,
)

assert (
_create_github_client.call_args_list[0][0][0] == "env_var_test"
), f"wrong api_key used for create_github_client: {_create_github_client.call_args_list}"
7 changes: 0 additions & 7 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ def simple_test_config() -> config.Config:
return config.Config(credentials=credentials, pr=pr, update_command=cmd)


def env_var_token_test_config() -> config.Config:
credentials = config.Credentials(ssh_key_file="test")
pr = config.PrTemplate()
cmd = ["bash", "-c", "echo 'test' > testfile.txt"]
return config.Config(credentials=credentials, pr=pr, update_command=cmd)


def simple_test_database() -> database.Database:
repo = database.Repository(
owner="test", name="test", ssh_url="test@testytest.com", default_branch="master"
Expand Down