From f9d2f9fbbe742c478f5e2dc03db9061705ac57de Mon Sep 17 00:00:00 2001 From: Mateusz Bysiek Date: Thu, 24 Oct 2024 13:15:49 +0900 Subject: [PATCH] feat: add example anonymization script --- Dockerfile | 1 + Jenkinsfile | 9 ++++++++- cleanup_examples.sh | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 cleanup_examples.sh diff --git a/Dockerfile b/Dockerfile index 2c7ec4f..10b05fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,6 +41,7 @@ RUN set -Eeuxo pipefail && \ python3-numpy \ python3-pip \ python3-venv \ + shellcheck \ sudo && \ apt-get -qy autoremove && \ apt-get clean && \ diff --git a/Jenkinsfile b/Jenkinsfile index 565868d..7aedb17 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,7 @@ pipeline { stage('Lint') { environment { PYTHON_MODULES = "${env.PYTHON_PACKAGE} test *.py" + SHELL_SCRIPTS = '*.sh' } steps { sh """#!/usr/bin/env bash @@ -37,6 +38,8 @@ pipeline { echo "\${PIPESTATUS[0]}" | tee flake518_status.log python3 -m pydocstyle ${PYTHON_MODULES} |& tee pydocstyle.log echo "\${PIPESTATUS[0]}" | tee pydocstyle_status.log + shellcheck ${SHELL_SCRIPTS} |& tee shellcheck.log + echo "\${PIPESTATUS[0]}" | tee shellcheck_status.log """ } } @@ -61,7 +64,11 @@ pipeline { echo "${PIPESTATUS[0]}" | tee coverage_status.log ''' script { - defaultHandlers.afterPythonBuild() + if (env.CHANGE_ID) { + HashMap toolResults = pythonUtils.prepareLintingReport() + toolResults['shellcheck'] = languageUtils.prepareToolReport('shellcheck') + repoUtils.postToolsReportOnPR(toolResults) + } } } } diff --git a/cleanup_examples.sh b/cleanup_examples.sh new file mode 100755 index 0000000..7a9e9b8 --- /dev/null +++ b/cleanup_examples.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -Eeuxo pipefail + +HOSTNAME=$(hostname) +USER=$(whoami) + +FILES=('README.rst' 'examples.ipynb') + +for file in "${FILES[@]}" ; do + sed -i "s|${USER}|user|" "${file}" + sed -i "s|${HOSTNAME}|hostname|" "${file}" +done