Skip to content
Snippets Groups Projects
Commit 7049cbf1 authored by sandcha's avatar sandcha
Browse files

Ajoute la vérification de la version en CI

parent 86ea289b
No related branches found
No related tags found
1 merge request!6CI - Ajoute le build, le tag git et la publication sur PyPi
......@@ -45,3 +45,12 @@ test:
needs: ["install-repository"]
script:
- poetry run pytest --log-cli-level=DEBUG
check_version:
stage: test
needs: ["install-repository"]
script:
# check for functional changes and version number
- .gitlab/ci/is-version-number-acceptable.sh
except:
- main
#! /usr/bin/env bash
IGNORE_DIFF_ON="README.md CONTRIBUTING.md .gitignore .gitlab-ci.yml .gitlab/*"
remote_tags_exist=`git ls-remote --tags origin`
if [[ $remote_tags_exist ]];
then
# get last tagged commit
commit_to_compare_to=`git describe --tags --abbrev=0 --first-parent` # --first-parent ensures we don't follow tags not published in main through an unlikely intermediary merge commit
else
# get remote main branch last commit
commit_to_compare_to=`git rev-parse origin/main`
fi
if git diff-index --name-only --exit-code $commit_to_compare_to -- . `echo " $IGNORE_DIFF_ON" | sed 's/ / :(exclude)/g'` # check if any file that has not be listed in IGNORE_DIFF_ON has changed since the last tag was published.
then
echo "No functional changes detected."
exit 1
else
echo "The functional files above were changed."
fi
#! /usr/bin/env bash
if [[ $CI_COMMIT_BRANCH == main ]]
then
echo "No need for a version check on main."
exit 0
fi
if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh
then
echo "No need for a version update."
exit 0
fi
current_version=`poetry version --short`
if git rev-parse --verify --quiet $current_version
then
echo "Version $current_version already exists in commit:"
git --no-pager log -1 $current_version
echo
echo "Update the version number in pyproject.toml before merging this branch into main."
echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated."
exit 1
fi
if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh | grep --quiet CHANGELOG.md
then
echo "CHANGELOG.md has not been modified, while functional changes were made."
echo "Explain what you changed before merging this branch into main."
echo "Look at the CONTRIBUTING.md file to learn how to write the changelog."
exit 2
fi
#! /usr/bin/env bash
git tag `poetry version --short`
# push tag to GitLab thanks to our GITLAB_API_ACCESS_TOKEN
# and predefined variables (see https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)
# TODO move from .gitlab-ci.yml into here:
# git push --tags -o ci.skip "https://${CI_REGISTRY_USER}:${GITLAB_API_ACCESS_TOKEN}@${CI_REPOSITORY_URL#*@}"
# or like leximpact-prepare-data, create the token by going to {PROJECT} / Settings / Access Tokens. Then create one with read/write repository.
# git push -o ci.skip "https://${CI_REGISTRY_USER}:${API_TOKEN}@${CI_REPOSITORY_URL#*@}"
# Contribuer à leximpact-dotations-back
Avant tout, merci de votre volonté de contribuer au dépôt `leximpact-dotations-back` !
Afin de faciliter son utilisation et d'améliorer la qualité du code, les contributions suivent certaines règles décrites dans ce fichier.
## Format des versions et du CHANGELOG
Les évolutions de `leximpact-dotations-back` doivent pouvoir être comprises par des utilisateurs ne disposant pas du contexte complet de l'application. C'est pourquoi nous faisons le choix :
* D'un [versionnement sémantique](https://semver.org/lang/fr/) de l'application où l'évaluation des changements majeurs se fait au regard des évolutions de l'API web.
* De l'existence d'un [CHANGELOG.md](./CHANGELOG.md), rédigé en français, pour la description des évolutions. Celui-ci se doit être le plus explicite possible.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment