Skip to content
This repository was archived by the owner on Jan 7, 2024. It is now read-only.

Commit 89af60b

Browse files
authored
Merge pull request #112 from freedomofpress/filename-key-regres
test: regression coverage for #111 (KeyError due to filename), also fix ci on master
2 parents 748adb6 + 1140d40 commit 89af60b

File tree

8 files changed

+427
-34
lines changed

8 files changed

+427
-34
lines changed

.circleci/config.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,47 @@ jobs:
33
test-run:
44
working_directory: ~/sdclientapi
55
docker:
6-
- image: circleci/python:3.5.3
7-
environment:
8-
PIPENV_VENV_IN_PROJECT: true
6+
- image: circleci/python:3.7
97
steps:
108
- checkout
119
- run: sudo chown -R circleci:circleci /usr/local/bin
12-
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.5/site-packages
10+
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.7/site-packages
1311
- restore_cache:
14-
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
12+
key: deps9-{{ .Branch }}-{{ checksum "dev-requirements.txt" }}
1513
- run:
1614
name: Install dependencies
1715
command: |
18-
set -e
19-
sudo pip install pipenv
20-
pipenv install --dev --skip-lock
21-
pipenv run pip freeze
16+
virtualenv --python=python3 .venv
17+
source .venv/bin/activate
18+
pip install --require-hashes -r dev-requirements.txt
2219
- save_cache:
23-
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
20+
key: deps9-{{ .Branch }}-{{ checksum "dev-requirements.txt" }}
2421
paths:
2522
- ".venv"
2623
- "/usr/local/bin"
27-
- "/usr/local/lib/python3.5/site-packages"
24+
- "/usr/local/lib/python3.7/site-packages"
2825
- run:
29-
name: Run linters
30-
command: pipenv run make lint mypy
31-
- run:
32-
name: Run tests
33-
command: pipenv run make test
34-
- run:
35-
name: Check for known CVEs
36-
command: pipenv check
26+
name: Run linter, tests, check for known CVEs
27+
command: |
28+
source .venv/bin/activate
29+
make check
30+
3731
test-against-latest-api:
3832
working_directory: ~/project
3933
machine:
4034
enabled: true
35+
image: ubuntu-1604:201903-01
4136
environment:
4237
DOCKER_API_VERSION: 1.23
4338
steps:
4439
- checkout
4540
- run:
4641
name: Install dependencies
4742
command: |
48-
sudo pip install pipenv
49-
pipenv install --dev --skip-lock
50-
pipenv run pip freeze
43+
pyenv global 3.7.0
44+
virtualenv --python=python3 .venv
45+
source .venv/bin/activate
46+
pip install --require-hashes -r dev-requirements.txt
5147
- run:
5248
name: Download SecureDrop server code
5349
command: git clone https://github.com/freedomofpress/securedrop.git
@@ -56,7 +52,7 @@ jobs:
5652
command: |
5753
cd securedrop
5854
NUM_SOURCES=5 make -C securedrop dev
59-
background: true
55+
background: true
6056
- run: # As suggested in https://discuss.circleci.com/t/prevent-race-conditions-by-waiting-for-services-with-dockerize/11215
6157
name: Install dockerize
6258
command: |
@@ -74,7 +70,9 @@ jobs:
7470
name: Remove VCR cassettes and run tests against latest API
7571
command: |
7672
rm data/*.yml # Removing VCR cassettes
77-
pipenv run make test
73+
source .venv/bin/activate
74+
make test
75+
7876
workflows:
7977
version: 2
8078
securedrop_ci:

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,22 @@ mypy: ## Run the mypy typechecker
2020
@mypy sdclientapi
2121

2222
.PHONY: check
23-
check: lint mypy test ## Run all checks and tests
23+
check: lint mypy test safety ## Run all checks and tests
24+
25+
.PHONY: safety
26+
safety: ## Runs `safety check` to check python dependencies for vulnerabilities
27+
pip install --upgrade safety && \
28+
for req_file in `find . -type f -name '*requirements.txt'`; do \
29+
echo "Checking file $$req_file" \
30+
&& safety check --full-report -r $$req_file \
31+
&& echo -e '\n' \
32+
|| exit 1; \
33+
done
34+
35+
.PHONY: update-pip-requirements
36+
update-pip-requirements: ## Updates all Python requirements files via pip-compile.
37+
pip-compile --generate-hashes --output-file dev-requirements.txt requirements.in dev-requirements.in
38+
pip-compile --generate-hashes --output-file requirements.txt requirements.in
2439

2540
.PHONY: open-coverage-report
2641
open-coverage-report: ## Open the coverage report in your browser

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,19 @@ The SDK is currently used by the [SecureDrop Client](https://github.com/freedomo
1313
## Quick Start
1414

1515
```bash
16-
pip install -U pipenv
17-
pipenv sync --dev
18-
pipenv shell
16+
virtualenv --python=python3 .venv
17+
source .venv/bin/activate
18+
pip install --require-hashes -r dev-requirements.txt
1919
make test
2020
```
2121

22-
This project uses [pipenv](https://docs.pipenv.org) to manage all dependencies.
23-
This is a Python 3 project. When using ``pipenv`` locally, ensure you used the ``--keep-outdated``
24-
flag to prevent dependencies from being unnecessarily upgraded during normal development.
25-
2622
We cover all the API calls supported by the SecureDrop Journalist Interface API.
2723

2824
## Testing
2925

3026
The tests are located in the `tests` directory. This project uses [vcrpy](http://vcrpy.readthedocs.io/en/latest/) to record and then reply the API calls so that
3127
developers will have repeatable results so that they may work offline. `vcrpy` stores YAML
32-
recordings of the API calls in the `data` directory.
28+
recordings of the API calls in the `data` directory.
3329

3430
To run all the test cases, use the following command.
3531

@@ -118,7 +114,7 @@ Please read [CONTRIBUTING.md](https://github.com/freedomofpress/securedrop-sdk/b
118114

119115
# Versioning
120116

121-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/freedomofpress/securedrop-sdk/tags).
117+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/freedomofpress/securedrop-sdk/tags).
122118

123119
# License
124120

dev-requirements.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
coverage
2+
flake8
3+
mypy
4+
pyotp
5+
pytest
6+
pytest-cov
7+
sphinx
8+
vcrpy
9+
pyyaml>=5.1,<6
10+
pytest-mock
11+
pip-tools

0 commit comments

Comments
 (0)