Skip to content
Snippets Groups Projects
Commit 287ee13f authored by Stefano Di Frischia's avatar Stefano Di Frischia Committed by Corné Lukken
Browse files

L2SS-629: install pre-push hooks

parent d89ca190
Branches
No related tags found
1 merge request!875L2SS-629: install pre-push hooks
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
**/pending_log_messages.db **/pending_log_messages.db
**/vscode-server.tar **/vscode-server.tar
**/*.orig **/*.orig
**/venv
tangostationcontrol/build tangostationcontrol/build
tangostationcontrol/cover tangostationcontrol/cover
......
default_stages: [push]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- repo: local
hooks:
- id: tox-black
name: tox-black (local)
entry: tox
language: system
args: ["-c", "tangostationcontrol/tox.ini", "-e", "black", "--"]
- repo: local
hooks:
- id: tox-pep8
name: tox-pep8 (local)
entry: tox
language: system
args: ["-c", "tangostationcontrol/tox.ini", "-e", "pep8", "--"]
...@@ -166,6 +166,7 @@ Next change the version in the following places: ...@@ -166,6 +166,7 @@ Next change the version in the following places:
# Release Notes # Release Notes
* 0.31.1 Add pre-push git hooks for basic CI checks
* 0.31.0 Poll attributes independently from Tango * 0.31.0 Poll attributes independently from Tango
* 0.30.5 Log and count event subscription errors * 0.30.5 Log and count event subscription errors
* 0.30.4 Fix Tango attribute parameter types * 0.30.4 Fix Tango attribute parameter types
......
#!/bin/bash
pip install pre-commit
pre-commit install --hook-type pre-push --allow-missing-config
# --allow-missing-config: Allows the installation to proceed
# even if the configuration file is missing, and hooks won't be executed
# without a configuration file.
#
# e.g. switching between branches who might have or not have pre-push config
# files result in no annoying messages
# To uninstall pre-commit:
#
# pre-commit uninstall
# pip uninstall pre-commit
#
# You might want to remove also '.git/hooks/pre-push'
...@@ -13,12 +13,27 @@ fi ...@@ -13,12 +13,27 @@ fi
ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE})) ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE}))
export LOFAR20_DIR=${1:-${ABSOLUTE_PATH}} export LOFAR20_DIR=${1:-${ABSOLUTE_PATH}}
# Create a virtual environment directory if it doesn't exist
VENV_DIR="${LOFAR20_DIR}/venv"
if [ ! -d "$VENV_DIR" ]; then
echo "Creating virtual environment..."
python3 -m venv "$VENV_DIR"
fi
# Activate the virtual environment
source "$VENV_DIR/bin/activate"
# Install git post-checkout hook upon next execution of git command # Install git post-checkout hook upon next execution of git command
# git alias eventually automatically uninstalled # git alias eventually automatically uninstalled
if [ ! -f "${LOFAR20_DIR}/.git/hooks/post-checkout" ]; then if [ ! -f "${LOFAR20_DIR}/.git/hooks/post-checkout" ]; then
alias git="cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-checkout; cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-merge; unalias git; git" alias git="cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-checkout; cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-merge; unalias git; git"
fi fi
# Install git pre-push hook
if [ ! -f "${LOFAR20_DIR}/.git/hooks/pre-push" ]; then
source "${LOFAR20_DIR}/sbin/install-pre-commit.sh"
fi
# It checks if Tango is running within nomad, by trying to query the service from consul. # It checks if Tango is running within nomad, by trying to query the service from consul.
# If consul is not available it is assumed that the Tango host, the computer that runs the TangoDB, # If consul is not available it is assumed that the Tango host, the computer that runs the TangoDB,
# is this host. If this is not true, then modify to the Tango host's FQDN and # is this host. If this is not true, then modify to the Tango host's FQDN and
......
0.31.0 0.31.1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment