Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pylint bandit pytest coverage
pip install flake8 pylint pytest coverage
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
#- name: Lint with flake8
# run: |
Expand All @@ -49,8 +49,8 @@ jobs:
- name: Run linters
working-directory: .
run: |
chmod +x ./run_linters.sh
./run_linters.sh
chmod +x conf/run_linters.sh
conf/run_linters.sh
#- name: Cache SonarQube packages
# uses: actions/cache@v4
# with:
Expand Down
9 changes: 0 additions & 9 deletions .sonarcloud.properties

This file was deleted.

File renamed without changes.
File renamed without changes.
20 changes: 12 additions & 8 deletions deploy.sh → conf/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

ME="$( basename "${BASH_SOURCE[0]}" )"
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

build_docs=1
build_image=1
release=0
Expand All @@ -44,30 +48,30 @@ while [ $# -ne 0 ]; do
done

black --line-length=150 .
rm -rf build dist
python3 setup.py bdist_wheel
rm -rf $ROOTDIR/build/lib/sonar $ROOTDIR/build/lib/cli $ROOTDIR/build/scripts*/sonar-tools $ROOTDIR/dist/sonar_tools*
python3 $ROOTDIR/setup.py bdist_wheel

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

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

if [ "$build_docs" == "1" ]; then
rm -rf api-doc/build
sphinx-build -b html api-doc/source api-doc/build
rm -rf doc/api/build
sphinx-build -b html doc/api/source doc/api/build
fi

# Deploy on pypi.org once released
if [ "$release" = "1" ]; then
echo "Confirm release [y/n] ?"
read -r confirm
if [ "$confirm" = "y" ]; then
python3 -m twine upload dist/sonar_tools-*-py3-*.whl
python3 -m twine upload $ROOTDIR/dist/sonar_tools-*-py3-*.whl
fi
fi

if [ "$release_docker" = "1" ]; then
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-tools:3.5 -t olivierkorach/sonar-tools:latest -f release.Dockerfile .
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-tools:3.5 -t olivierkorach/sonar-tools:latest -f $ROOTDIR/release.Dockerfile .
fi
File renamed without changes.
File renamed without changes.
12 changes: 8 additions & 4 deletions run_linters.sh → conf/run_linters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

buildDir="build"
ME="$( basename "${BASH_SOURCE[0]}" )"
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

buildDir="$ROOTDIR/build"
pylintReport="$buildDir/pylint-report.out"
# banditReport="$buildDir/bandit-report.json"
flake8Report="$buildDir/flake8-report.out"
Expand All @@ -29,7 +33,7 @@ externalIssueReport="$buildDir/external-issue-report.json"

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

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

echo "Running shellcheck"
shellcheck ./*.sh ./*/*.sh -s bash -f json | ./shellcheck2sonar.py >$externalIssueReport
shellcheck $ROOTDIR/*.sh $ROOTDIR/*/*.sh -s bash -f json | $CONFDIR/shellcheck2sonar.py >$externalIssueReport
12 changes: 8 additions & 4 deletions run_tests.sh → conf/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

buildDir="build"
ME="$( basename "${BASH_SOURCE[0]}" )"
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
buildDir="$ROOTDIR/build"
coverageReport="$buildDir/coverage.xml"

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

echo "Running tests"
chmod u-rw test/sif_not_readable.json
unreadableSif=$ROOTDIR/test/sif_not_readable.json
chmod u-rw $unreadableSif
export SONAR_HOST_URL=${1:-${SONAR_HOST_URL_TEST}}
coverage run --source=. -m pytest test/
coverage run --source=$ROOTDIR -m pytest $ROOTDIR/test/
coverage xml -o $coverageReport
chmod u+rw test/sif_not_readable.json
chmod u+rw $unreadableSif
12 changes: 8 additions & 4 deletions scan.sh → conf/scan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

ME="$( basename "${BASH_SOURCE[0]}" )"
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

dolint=true
dotest=false

Expand All @@ -40,7 +44,7 @@ do
shift
done

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

if [ "$dotest" == "true" ]; then
./run_tests.sh
$CONFDIR/run_tests.sh
fi

if [ "$dolint" != "false" ]; then
./run_linters.sh
$CONFDIR/run_linters.sh
fi

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

cmd="sonar-scanner -Dsonar.projectVersion=$version \
-Dsonar.python.flake8.reportPaths=$flake8Report \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 0 additions & 42 deletions migration.Dockerfile

This file was deleted.

16 changes: 10 additions & 6 deletions migration/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

ME="$( basename "${BASH_SOURCE[0]}" )"
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
CONFDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

build_image=1
release=0

Expand All @@ -40,25 +44,25 @@ while [ $# -ne 0 ]; do
done

black --line-length=150 .
rm -rf build dist
python3 setup_migration.py bdist_wheel
rm -rf $ROOTDIR/build/lib/migration $ROOTDIR/build/lib/cli $ROOTDIR/build/lib/sonar $ROOTDIR/build/scripts*/sonar_migration $ROOTDIR/dist/sonar_migration*
python3 $ROOTDIR/setup_migration.py bdist_wheel

# Deploy locally for tests
pip install --upgrade --force-reinstall dist/sonar_migration-*-py3-*.whl
pip install --upgrade --force-reinstall $ROOTDIR/dist/sonar_migration-*-py3-*.whl

if [ "$build_image" == "1" ]; then
docker build -t olivierkorach/sonar-migration:latest -f migration/snapshot.Dockerfile . --load
docker build -t olivierkorach/sonar-migration:latest -f migration/snapshot.Dockerfile $ROOTDIR --load
fi

# Deploy on pypi.org once released
if [ "$release" = "1" ]; then
echo "Confirm release [y/n] ?"
read -r confirm
if [ "$confirm" = "y" ]; then
python3 -m twine upload dist/sonar_migration-*-py3-*.whl
python3 -m twine upload $ROOTDIR/dist/sonar_migration-*-py3-*.whl
fi
fi

if [ "$release_docker" = "1" ]; then
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-migration:0.3 -t olivierkorach/sonar-migration:latest -f migration/release.Dockerfile .
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-migration:0.3 -t olivierkorach/sonar-migration:latest -f migration/release.Dockerfile $ROOTDIR
fi
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sonar.python.flake8.reportPaths=build/flake8-report.out
sonar.python.pylint.reportPaths=build/pylint-report.out
# sonar.python.bandit.reportPaths=build/bandit-report.json

sonar.exclusions=api-doc/**/*, build/**/*, test/**/*
sonar.coverage.exclusions=setup*.py, migration/migration.py, test/**/*, shellcheck2sonar.py, cli/cust_measures.py, sonar/custom_measures.py, cli/support.py, cli/projects_export.py, , cli/projects_import.py
sonar.exclusions=doc/api/**/*, build/**/*, test/**/*
sonar.coverage.exclusions=setup*.py, migration/migration.py, test/**/*, conf/shellcheck2sonar.py, cli/cust_measures.py, sonar/custom_measures.py, cli/support.py, cli/projects_export.py, cli/projects_import.py
sonar.cpd.exclusions=setup*.py, migration/migration.py
sonar.tests=test
1 change: 1 addition & 0 deletions sonar/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def __run_request(
headers["Authorization"] = f"Bearer {self.__token}"
if kwargs.get("with_organization", True):
params["organization"] = self.organization
req_type, url = "", ""
if log.get_level() >= logging.DEBUG:
req_type = getattr(request, "__name__", repr(request)).upper()
url = self.__urlstring(api, params)
Expand Down