-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtasks
executable file
·109 lines (98 loc) · 2.66 KB
/
tasks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
set -Eeo pipefail
aws_region=eu-west-2
image_repo_name=registrations/mesh-inbox-s3-forwarder
function docker_login {
dojo -c Dojofile-infra "aws ecr get-login --no-include-email --region $aws_region"
}
function get_aws_account_id {
dojo -c Dojofile-infra "aws sts get-caller-identity --query Account --output text"
}
function validate_image_tag {
if [ -z $IMAGE_TAG ]; then
echo "Please set IMAGE_TAG environment variable"
exit 1
fi
}
function build_docker {
validate_image_tag
./tasks generate-requirements
FULL_LOCAL_IMAGE_TAG=${image_repo_name}:${IMAGE_TAG}
docker build -t $FULL_LOCAL_IMAGE_TAG .
}
for command in "$@"
do
echo "--- ${command} ---"
case "${command}" in
test)
pipenv run test
;;
format)
pipenv run format-import
pipenv run format
;;
check-format)
pipenv run check-format
;;
lint)
pipenv run lint-flake8
pipenv run lint-bandit
;;
typecheck)
pipenv run typecheck
;;
check-deps)
pipenv check \
--ignore 51457 # CVE-2022-42969 in unused code see https://github.com/pytest-dev/pytest/issues/10392
;;
validate)
./tasks check-format typecheck lint test
;;
dojo-validate)
dojo "./tasks devenv validate"
;;
clean)
find ./tests -type f -name "*.pyc" -delete
find ./tests -type d -name "__pycache__" -delete
find ./src -type f -name "*.pyc" -delete
find ./src -type d -name "__pycache__" -delete
find ./src -type f -path "*.egg-info*" -delete
find ./src -type d -path "*.egg-info" -delete
rm -rf build/ dist/ .pytest_cache/
;;
devenv)
echo "./tasks validate" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
pipenv install -d
;;
dep)
./tasks check-deps > audit-output.txt
;;
dojo-dep)
dojo "./tasks devenv dep"
;;
_generate-requirements)
pipenv lock -r > requirements.txt
;;
generate-requirements)
dojo "./tasks _generate-requirements"
;;
build-docker)
build_docker
;;
publish-docker)
build_docker
aws_account_id=$(get_aws_account_id)
repository_uri=${aws_account_id}.dkr.ecr.${aws_region}.amazonaws.com/${image_repo_name}
docker tag $FULL_LOCAL_IMAGE_TAG ${repository_uri}:${IMAGE_TAG}
docker tag $FULL_LOCAL_IMAGE_TAG ${repository_uri}:latest
eval $(docker_login)
docker push ${repository_uri}:${IMAGE_TAG}
;;
*)
echo "Invalid command: '${command}'"
exit 1
;;
esac
done
set +e