From 1e1122e3be132e4faadadec6a1870efdf28df32c Mon Sep 17 00:00:00 2001 From: jmkerloch <53606373+jmkerloch@users.noreply.github.com> Date: Mon, 1 Mar 2021 13:54:02 +0100 Subject: [PATCH] add check for branch name in CI and with git hooks (#150) * add pre-commit hooks in .githooks folder * test branch name validation github action * correction of github action because of no on action and no jobs * add mandatory runs-on * Update CONTRIBUTING.md for description of supported branch names * Make pre-commit executable * correction of installer because of CONTRIBUTING.txt rename to CONTRIBUTING.md Co-authored-by: Florian Omnes --- .githooks/pre-commit | 16 ++++++++++ .github/workflows/branchNameValidation.yml | 16 ++++++++++ CONTRIBUTING.md | 35 ++++++++++++++++++++++ CONTRIBUTING.txt | 30 ------------------- src/distrib/win32/sourcefiles.inc.nsh | 2 +- 5 files changed, 68 insertions(+), 31 deletions(-) create mode 100755 .githooks/pre-commit create mode 100644 .github/workflows/branchNameValidation.yml create mode 100644 CONTRIBUTING.md delete mode 100644 CONTRIBUTING.txt diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000000..36a1a4b063 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +LC_ALL=C + +local_branch="$(git rev-parse --abbrev-ref HEAD)" + +valid_branch_regex="^(feature|features|fix|release)\/[a-z0-9._-]+$" + +message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again." + +if [[ ! $local_branch =~ $valid_branch_regex ]] +then + echo "$message" + exit 1 +fi + +exit 0 diff --git a/.github/workflows/branchNameValidation.yml b/.github/workflows/branchNameValidation.yml new file mode 100644 index 0000000000..ff0d8fc669 --- /dev/null +++ b/.github/workflows/branchNameValidation.yml @@ -0,0 +1,16 @@ +name: Branch name validation + +on: + push: + +jobs: + + valid-branch-name: + runs-on: ubuntu-latest + + steps: + - uses: deepakputhraya/action-branch-name@master + with: + regex: '([a-z])+\/([a-z])+' # Regex the branch should match. This example enforces grouping + allowed_prefixes: 'feature,features,fix,release' # All branches should start with the given prefix + ignore: master,develop # Ignore exactly matching branch names from convention diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..63485bf851 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,35 @@ +# How to contribute to Antares Simulator + +## Reporting bug +- Make sure that the bug was not already reported by searching on GitHub under [Issues](https://github.com/AntaresSimulatorTeam/Antares_Simulator/issues). + +- If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/AntaresSimulatorTeam/Antares_Simulator/issues/new). You must provide : + - description of bug and unexpected behavior + - expected behavior + - small antares study to reproduce unexpected behavior + - Antares Simulator version and OS used + + +## Developpement +Antares Simulator team will be pleased to have some developpers join our project. + +You can find all steps needed for compilation and installation of Antares Simulator in [INSTALL.md](INSTALL.md). + +### Branch names +Currently CI is runned only for specific branch names : +- `feature/*` +- `features/*` +- `fix/*` +- `release/*` + +If you create a branch with a different name no CI will be runned but you should receive an email indicating that your branch name is incorrect. + +In order to avoid pushing with invalid branch name, a git hooks is provided for pre-commit check. This hooks is available in `.githooks` directory. + +By default git use hooks in `.git/hooks` directory which is not under version control. You can define a new hooks directory with this command in Antares Simulator root directory : +``` +git config core.hooksPath .githooks +``` + +### Code formatting +We're using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to format code. Rules are defined in [.clang-format](src/.clang-format) file. diff --git a/CONTRIBUTING.txt b/CONTRIBUTING.txt deleted file mode 100644 index c0bb8bed10..0000000000 --- a/CONTRIBUTING.txt +++ /dev/null @@ -1,30 +0,0 @@ -Antares_Simulator is a project which, twelve years after its beginning, is still subject -to significant evolutions. - -To have an general idea of the progress that has been made so far, please read the NEWS file -at the root of this directory. - -To get of a wiew of the main directions in which further developments are currently oriented, -please read the ROADMAP file at the root of this directory. - -If you think about contributing to the Antares_Simulator project, your first move should be to get the source code. -There are two ways to achieve that: - -1) Clone the Antares_Simulator git repository available on GitHub : https://github.com/AntaresSimulatorTeam/Antares_Simulator -2) Get an Antares_Simulator installer package available at https://antares-simulator.org -and tick the box "copy source code" when installing the software. - -In the process followed to release the code of Antares_Simulator under Open Source, there are two important milestones: - -* In Summer 2018 , release of Antares_Simulator 6.0.0 : this first (ex-post) publication is meant to -provide a general access to the code, giving to everybody the ability to review as well as to (re)build the application. -At this stage, however, all will not be set yet regarding how to contribute (this file), conduct code, coding conventions, etc. - -* In Winter 2018/2019, release of Antares_Simulator 7.0.0 source. With this version will start the actual open -developement process, no more code being written in proprietary mode. This publication is meant to give the actual kick-off -for external contributions. - -* During the interim period (second half of 2018), developers who wish to join are welcome to examine -the code already published and to share their thoughts with the Antares_Simulator Team through one of -the email addresses that can be found at https://antares-simulator.org - diff --git a/src/distrib/win32/sourcefiles.inc.nsh b/src/distrib/win32/sourcefiles.inc.nsh index 01c37b37cb..80813988e9 100644 --- a/src/distrib/win32/sourcefiles.inc.nsh +++ b/src/distrib/win32/sourcefiles.inc.nsh @@ -4,7 +4,7 @@ File /nonfatal /r /x build_deps ${ANTARES_SRC_DIR}\..\src\*.* ${SetOutPath} "$INSTDIR\Sources" File ${ANTARES_SRC_DIR}\..\AUTHORS.txt File ${ANTARES_SRC_DIR}\..\CERTIFICATE.txt -File ${ANTARES_SRC_DIR}\..\CONTRIBUTING.txt +File ${ANTARES_SRC_DIR}\..\CONTRIBUTING.md File ${ANTARES_SRC_DIR}\..\COPYING.txt File ${ANTARES_SRC_DIR}\..\NEWS.txt File ${ANTARES_SRC_DIR}\..\ROADMAP.txt