Skip to content

Commit

Permalink
Feature/57 ajouter shellcheck et yamllint sur equipe info template maven
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Maury authored and Marthym committed Mar 4, 2020
1 parent e271b47 commit 0ded1df
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 42 deletions.
99 changes: 65 additions & 34 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
---
image: d.i-run.fr/irun-compiler:20190917.f02b5df2

variables:
#CHAT_WEBHOOK_URL: Must exists in group variables or projet variables
#GIT_SUBMODULE_STRATEGY: normal
# CHAT_WEBHOOK_URL: Must exists in group variables or projet variables
# GIT_SUBMODULE_STRATEGY: normal
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode -Dmaven.repo.local=${CI_PROJECT_DIR}/.m2/repository --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
MAVEN_CLI_OPTS:
"--batch-mode -Dmaven.repo.local=${CI_PROJECT_DIR}/.m2/repository
--errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"

cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- ${CI_PROJECT_DIR}/.m2/repository/
- ${CI_PROJECT_DIR}/.m2/repository/

stages:
- build
- test
- release
- deploy
- notify
- build
- test
- release
- deploy
- notify

workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- when: always

maven:build:
stage: build
before_script:
before_script:
- find "${CI_PROJECT_DIR}/.m2/repository" -type f -name "*SNAPSHOT*" -delete || true
- .gitlab/install-deps.sh
- .gitlab/install-deps.sh
script:
- mvn ${MAVEN_CLI_OPTS} clean install -DskipTests
artifacts:
Expand All @@ -35,11 +44,11 @@ maven:build:
maven:checkstyle:
stage: test
dependencies:
- maven:build
- maven:build
cache:
policy: pull
script:
- mvn ${MAVEN_CLI_OPTS} install checkstyle:check -DskipTests
- mvn ${MAVEN_CLI_OPTS} install checkstyle:check -DskipTests

maven:javadoc:
stage: test
Expand All @@ -49,26 +58,41 @@ maven:javadoc:
policy: pull
script:
- mvn ${MAVEN_CLI_OPTS} javadoc:javadoc

maven:test:
stage: test
dependencies:
- maven:build
- maven:build
script: mvn ${MAVEN_CLI_OPTS} test -Pintegration
artifacts:
reports:
junit: [
]

🖍yaml:lint:
stage: test
image: python:3-slim
before_script:
- export PATH="$PATH:~/.local/bin"
- pip install --user yamllint
script:
- yamllint .

shell-check:
image: d.i-run.fr/irun-compiler:jdk8-20200224.d83136a5
stage: test
script:
- shellcheck .gitlab/*.sh

maven:release:
stage: release
dependencies:
- maven:build
- maven:build
before_script:
- git checkout -B "$CI_BUILD_REF_NAME"
- mvn ${MAVEN_CLI_OPTS} -DdryRun=true release:prepare
- git clean -f
script:
script:
- |
mvn ${MAVEN_CLI_OPTS} \
release:prepare \
Expand All @@ -83,10 +107,11 @@ maven:release:
- git checkout master
- git merge --no-ff -m "[maven-release][skip CI] Merge release in master" origin/develop~1
- git push origin master
when: manual
only:
- develop
- /^support/.*$/
rules:
- if: >
$CI_COMMIT_REF_NAME == "develop"
|| $CI_COMMIT_REF_NAME =~ /^support/
when: manual
maven:sonar:
stage: deploy
Expand All @@ -97,17 +122,20 @@ maven:sonar:
policy: pull
script:
- mvn ${MAVEN_CLI_OPTS} test sonar:sonar -Psonar
only:
- develop
rules:
- if: '$CI_COMMIT_REF_NAME == "develop"'
when: always

maven:deploy:
stage: deploy
dependencies:
- maven:build
script: mvn ${MAVEN_CLI_OPTS} deploy -DskipTests
only:
- develop
- master
rules:
- if: >
$CI_COMMIT_REF_NAME == "develop"
|| $CI_COMMIT_REF_NAME == "master"
when: always
trigger:itg:
stage: notify
Expand All @@ -116,18 +144,21 @@ trigger:itg:
trigger:
project: nora/tooling/itg-deploy
branch: master
only:
- develop
when: on_success
rules:
- if: '$CI_COMMIT_REF_NAME == "develop"'
when: on_success

documentation:deploy:
stage: notify
allow_failure: true
cache: {}
script:
- curl --request POST --form "token=${CI_JOB_TOKEN}" --form ref=develop "${CI_API_V4_URL}/projects/149/trigger/pipeline"
only:
- develop
script:
- >
curl --request POST --form "token=${CI_JOB_TOKEN}"
--form ref=develop "${CI_API_V4_URL}/projects/149/trigger/pipeline"
rules:
- if: '$CI_COMMIT_REF_NAME == "develop"'
when: always

mattermost:failure:
stage: notify
Expand All @@ -140,4 +171,4 @@ mattermost:failure:
- source "./user-mapping.sh" && chmod +x ./feature-fail.sh
- CHANNEL="info-gitlab" ./feature-fail.sh
- CHANNEL="@${USERS[$GITLAB_USER_LOGIN]:-$GITLAB_USER_LOGIN}" ./feature-fail.sh
when: on_failure
when: on_failure
17 changes: 9 additions & 8 deletions .gitlab/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ readonly NORMAL="\\e[0m"
readonly RED="\\e[1;31m"
readonly YELLOW="\\e[1;33m"
readonly DIM="\\e[2m"
# shellcheck disable=SC2034
readonly BOLD="\\e[1m"
readonly LOG_FILE="/tmp/$(basename "$0").log"
readonly BLUE="\\e[34m"
Expand Down Expand Up @@ -52,7 +53,7 @@ function cleanup() {
rm -rf "/tmp/git"
return
}

# shellcheck disable=SC2034
readonly VERSION_SEPARATOR="\\u02DF"
readonly IRUN_GROUP_ID="fr.irun"
readonly IRUN_PATTERN="(fr.irun:.*)"
Expand All @@ -77,7 +78,7 @@ function downloadDependenciesParentPom() {

debug "mvn ${MVN_ARGS[*]} clean dependency:copy-dependencies \
-Dmdep.addParentPoms=true \
-DincludeGroupIds="${IRUN_GROUP_ID}" \
-DincludeGroupIds=${IRUN_GROUP_ID} \
-DincludeTypes=pom \
-f ${prefix}"

Expand Down Expand Up @@ -129,10 +130,10 @@ function installDependency() {
if [[ "$version" = *"SNAPSHOT" ]]; then
info "repository: ${repository}, projetName: ${projetName}, version: ${version}"
if git clone "$repository" "$gitDir"; then
local pattern; pattern="$(echo "${CI_COMMIT_REF_NAME}"|sed 's:^.*/[0-9]*.::')" # i remove string/number/string
local pattern; pattern="${CI_COMMIT_REF_NAME/*?(\/)+([0-9])?([[:punct:]])/}" # i remove string/number/string
local allBranch; allBranch="$(git -C "${gitDir}" branch -a )" # view all branch
local selectBranch; selectBranch="$(cat <<< "$allBranch"| grep "$pattern" || true)" # select branch we have the same name of project
local localBranch; localBranch="$(echo "${selectBranch}"|sed 's:^.*origin/::' || true)" # remove "remotes/origin/"
local localBranch; localBranch="${selectBranch/*origin\//}" # remove "remotes/origin/"
debug "see all branch: \n ${allBranch}"
debug " pattern : ${pattern}"
debug "selected branch: $selectBranch"
Expand Down Expand Up @@ -187,7 +188,7 @@ function installDependencies() {

if [[ "${BASH_SOURCE[0]}" = "$0" ]]; then
trap cleanup EXIT
prog "START OF PROGRAM"
prog "START OF PROGRAM"
# Parse command line arguments
POSITIONAL=()
verbose=false
Expand All @@ -208,7 +209,7 @@ if [[ "${BASH_SOURCE[0]}" = "$0" ]]; then
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

# shellcheck disable=SC2016,SC2155
declare -ra CURRENT_ARTIFACT_ID="$(mvn exec:exec -q -Dexec.executable=echo -Dexec.args='${project.artifactId}')"
debug "${CURRENT_ARTIFACT_ID[*]}"

Expand All @@ -218,5 +219,5 @@ if [[ "${BASH_SOURCE[0]}" = "$0" ]]; then

installed=()
installDependencies "."
prog "END OF PROGRAM"
fi
prog "END OF PROGRAM"
fi
8 changes: 8 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
extends: default

rules:
line-length:
max: 120
empty-lines:
max: 1

0 comments on commit 0ded1df

Please sign in to comment.