Skip to content

Commit e12b0a4

Browse files
authored
Cleanu repo root dir (#1382)
* Move all config in conf * Move api-doc in doc * Set conf config file for linters * Make all runs relative to repo root * Make scan relative to repo root * Specify properties file location in conf * Run everything all relative to repo root * Build everything from repo root * Delete only what is needed before rebuilding * Fix problem with tests * Move scanner properties file back in repo root * Fix API docs path in exclusions * Don't install bandit, not used anymore * Run linters in conf
1 parent 838ac11 commit e12b0a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+52
-82
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Install dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install flake8 pylint bandit pytest coverage
31+
pip install flake8 pylint pytest coverage
3232
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3333
#- name: Lint with flake8
3434
# run: |
@@ -49,8 +49,8 @@ jobs:
4949
- name: Run linters
5050
working-directory: .
5151
run: |
52-
chmod +x ./run_linters.sh
53-
./run_linters.sh
52+
chmod +x conf/run_linters.sh
53+
conf/run_linters.sh
5454
#- name: Cache SonarQube packages
5555
# uses: actions/cache@v4
5656
# with:

.sonarcloud.properties

Lines changed: 0 additions & 9 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

deploy.sh renamed to conf/deploy.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2020
#
2121

22+
ME="$( basename "${BASH_SOURCE[0]}" )"
23+
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
24+
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25+
2226
build_docs=1
2327
build_image=1
2428
release=0
@@ -44,30 +48,30 @@ while [ $# -ne 0 ]; do
4448
done
4549

4650
black --line-length=150 .
47-
rm -rf build dist
48-
python3 setup.py bdist_wheel
51+
rm -rf $ROOTDIR/build/lib/sonar $ROOTDIR/build/lib/cli $ROOTDIR/build/scripts*/sonar-tools $ROOTDIR/dist/sonar_tools*
52+
python3 $ROOTDIR/setup.py bdist_wheel
4953

5054
# Deploy locally for tests
51-
pip install --upgrade --force-reinstall dist/sonar_tools-*-py3-*.whl
55+
pip install --upgrade --force-reinstall $ROOTDIR/dist/sonar_tools-*-py3-*.whl
5256

5357
if [ "$build_image" == "1" ]; then
54-
docker build -t olivierkorach/sonar-tools:3.5 -t olivierkorach/sonar-tools:latest -f snapshot.Dockerfile . --load
58+
docker build -t olivierkorach/sonar-tools:3.5 -t olivierkorach/sonar-tools:latest -f $CONFDIR/snapshot.Dockerfile $ROOTDIR --load
5559
fi
5660

5761
if [ "$build_docs" == "1" ]; then
58-
rm -rf api-doc/build
59-
sphinx-build -b html api-doc/source api-doc/build
62+
rm -rf doc/api/build
63+
sphinx-build -b html doc/api/source doc/api/build
6064
fi
6165

6266
# Deploy on pypi.org once released
6367
if [ "$release" = "1" ]; then
6468
echo "Confirm release [y/n] ?"
6569
read -r confirm
6670
if [ "$confirm" = "y" ]; then
67-
python3 -m twine upload dist/sonar_tools-*-py3-*.whl
71+
python3 -m twine upload $ROOTDIR/dist/sonar_tools-*-py3-*.whl
6872
fi
6973
fi
7074

7175
if [ "$release_docker" = "1" ]; then
72-
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-tools:3.5 -t olivierkorach/sonar-tools:latest -f release.Dockerfile .
76+
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-tools:3.5 -t olivierkorach/sonar-tools:latest -f $ROOTDIR/release.Dockerfile .
7377
fi
File renamed without changes.
File renamed without changes.

run_linters.sh renamed to conf/run_linters.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2020
#
2121

22-
buildDir="build"
22+
ME="$( basename "${BASH_SOURCE[0]}" )"
23+
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
24+
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25+
26+
buildDir="$ROOTDIR/build"
2327
pylintReport="$buildDir/pylint-report.out"
2428
# banditReport="$buildDir/bandit-report.json"
2529
flake8Report="$buildDir/flake8-report.out"
@@ -29,7 +33,7 @@ externalIssueReport="$buildDir/external-issue-report.json"
2933

3034
echo "Running pylint"
3135
rm -f $pylintReport
32-
pylint ./*.py ./*/*.py -r n --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" | tee $pylintReport
36+
pylint --rcfile $CONFDIR/pylintrc $ROOTDIR/*.py $ROOTDIR/*/*.py -r n --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" | tee $pylintReport
3337
re=$?
3438
if [ "$re" == "32" ]; then
3539
>&2 echo "ERROR: pylint execution failed, errcode $re, aborting..."
@@ -39,11 +43,11 @@ fi
3943
echo "Running flake8"
4044
rm -f $flake8Report
4145
# See .flake8 file for settings
42-
flake8 . >$flake8Report
46+
flake8 --config "$CONFIG/.flake8" "$ROOTDIR" >$flake8Report
4347

4448
# echo "Running bandit"
4549
# rm -f $banditReport
4650
# bandit --exit-zero -f json --skip B311,B303,B101 -r . -x .vscode,./tests >$banditReport
4751

4852
echo "Running shellcheck"
49-
shellcheck ./*.sh ./*/*.sh -s bash -f json | ./shellcheck2sonar.py >$externalIssueReport
53+
shellcheck $ROOTDIR/*.sh $ROOTDIR/*/*.sh -s bash -f json | $CONFDIR/shellcheck2sonar.py >$externalIssueReport

run_tests.sh renamed to conf/run_tests.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@
1919
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2020
#
2121

22-
buildDir="build"
22+
ME="$( basename "${BASH_SOURCE[0]}" )"
23+
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
24+
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25+
buildDir="$ROOTDIR/build"
2326
coverageReport="$buildDir/coverage.xml"
2427

2528
[ ! -d $buildDir ] && mkdir $buildDir
2629

2730
echo "Running tests"
28-
chmod u-rw test/sif_not_readable.json
31+
unreadableSif=$ROOTDIR/test/sif_not_readable.json
32+
chmod u-rw $unreadableSif
2933
export SONAR_HOST_URL=${1:-${SONAR_HOST_URL_TEST}}
30-
coverage run --source=. -m pytest test/
34+
coverage run --source=$ROOTDIR -m pytest $ROOTDIR/test/
3135
coverage xml -o $coverageReport
32-
chmod u+rw test/sif_not_readable.json
36+
chmod u+rw $unreadableSif

scan.sh renamed to conf/scan.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2020
#
2121

22+
ME="$( basename "${BASH_SOURCE[0]}" )"
23+
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
24+
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25+
2226
dolint=true
2327
dotest=false
2428

@@ -40,7 +44,7 @@ do
4044
shift
4145
done
4246

43-
buildDir="build"
47+
buildDir="$ROOTDIR/build"
4448
pylintReport="$buildDir/pylint-report.out"
4549
banditReport="$buildDir/bandit-report.json"
4650
flake8Report="$buildDir/flake8-report.out"
@@ -51,14 +55,14 @@ externalIssuesReport="$buildDir/external-issue-report.json"
5155
rm -rf -- ${buildDir:?"."}/* .coverage */__pycache__ */*.pyc # mediatools/__pycache__ testpytest/__pycache__ testunittest/__pycache__
5256

5357
if [ "$dotest" == "true" ]; then
54-
./run_tests.sh
58+
$CONFDIR/run_tests.sh
5559
fi
5660

5761
if [ "$dolint" != "false" ]; then
58-
./run_linters.sh
62+
$CONFDIR/run_linters.sh
5963
fi
6064

61-
version=$(grep PACKAGE_VERSION sonar/version.py | cut -d "=" -f 2 | sed -e "s/[\'\" ]//g" -e "s/^ +//" -e "s/ +$//")
65+
version=$(grep PACKAGE_VERSION $ROOTDIR/sonar/version.py | cut -d "=" -f 2 | sed -e "s/[\'\" ]//g" -e "s/^ +//" -e "s/ +$//")
6266

6367
cmd="sonar-scanner -Dsonar.projectVersion=$version \
6468
-Dsonar.python.flake8.reportPaths=$flake8Report \

0 commit comments

Comments
 (0)