engine: Create openstack release jobs
[infra/cicd.git] / jjb / cloud-infra / scripts / cloud-infra-lint.sh
1 #!/bin/bash
2
3 # ============LICENSE_START=======================================================
4 #  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
20
21 set -o nounset
22 set -o errexit
23 set -o pipefail
24
25 # ensure we are in job build WORKSPACE
26 cd "$WORKSPACE"
27
28 export DEBIAN_FRONTEND=noninteractive
29
30 # install dependencies
31 echo "Info: Install python3.6-minimal python3-distutils virtualenv using apt"
32 sudo apt update -q=3 > /dev/null 2>&1
33 sudo apt install -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew -q=3 -y python3.6-minimal python3-distutils virtualenv > /dev/null 2>&1
34
35 # create and activate virtualenv
36 echo "Info: Create and activate python virtualenv"
37 virtualenv -p python3.6 .venv > /dev/null 2>&1
38 set +u
39 source .venv/bin/activate > /dev/null 2>&1
40 set -u
41
42 # install test-requirements
43 echo "Info: Install python packages listed in test-requirements.txt using pip"
44 pip install --force-reinstall --quiet -r test-requirements.txt > /dev/null 2>&1
45
46 # set default lint type
47 export LINT_TYPE="${LINT_TYPE:-ansible-lint}"
48
49 # run tox
50 echo "Info: Run $LINT_TYPE using tox"
51 echo "----------------------------------------------------"
52 tox -e "$LINT_TYPE"
53 echo "----------------------------------------------------"
54 echo "Info: Done!"
55
56 # vim: set ts=2 sw=2 expandtab: