Skip to content

Commit

Permalink
added environment file for credentials in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioteula committed Oct 8, 2024
1 parent a97c17e commit f1468d4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
KEY=
SECRET=
TAG=
COUNTRY=
4 changes: 3 additions & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ docker build \
--build-arg GID="$(id -g)" \
-t python-amazon-paapi .

docker run -t --rm -u "$(id -u):$(id -g)" -v "${PWD}:/code" \
touch .env

docker run -t --rm -u "$(id -u):$(id -g)" -v "${PWD}:/code" --env-file .env \
python-amazon-paapi -c "python -m pre_commit"
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ repos:
- id: test
name: Running tests
language: system
entry: "python -m coverage run -m unittest"
entry: "python -m coverage run -m pytest"
pass_filenames: false

- id: test
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ setup:
build:
@docker build --build-arg TAG="3.12" --build-arg UID="${UID}" --build-arg GID="${GID}" -t python-amazon-paapi .

coverage: build
@touch .env
@docker run -t --rm -u "${UID}:${GID}" -v "${PWD}:/code" --env-file .env python-amazon-paapi -c \
"python -m coverage run -m pytest && python -m coverage xml && python -m coverage report"

test: build
@docker run -t --rm -u "${UID}:${GID}" -v "${PWD}:/code" python-amazon-paapi -c "python -m pytest"
@touch .env
@docker run -t --rm -u "${UID}:${GID}" -v "${PWD}:/code" --env-file .env python-amazon-paapi -c "python -m pytest"

test-all-python-tags:
@touch .env
@for tag in $$PYTHON_TAGS; do \
docker build --build-arg TAG="$$tag" --build-arg UID="${UID}" --build-arg GID="${GID}" -t python-amazon-paapi .; \
docker run -t --rm -u "${UID}:${GID}" -v "${PWD}:/code" python-amazon-paapi -c "python -m unittest"; \
docker run -t --rm -u "${UID}:${GID}" -v "${PWD}:/code" python-amazon-paapi -c "python -m pytest"; \
done

lint: build
@docker run --rm -t -u "${UID}:${GID}" -v "${PWD}:/code" python-amazon-paapi -c "python -m pre_commit run -a"
@touch .env
@docker run --rm -t -u "${UID}:${GID}" -v "${PWD}:/code" --env-file .env python-amazon-paapi -c "python -m pre_commit run -a"

pre-commit:
@./.githooks/pre-commit

0 comments on commit f1468d4

Please sign in to comment.