Skip to content

Commit

Permalink
Merge pull request #6 from eea/develop
Browse files Browse the repository at this point in the history
Add SonarQube badges
  • Loading branch information
avoinea committed Dec 17, 2021
2 parents 461d6f0 + 2087e08 commit 21ce4d4
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 26 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Expand Up @@ -4,10 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [0.1.6](https://github.com/eea/volto-editing-progress/compare/0.1.5...0.1.6)

- Add SonarQube badges [`62c51d7`](https://github.com/eea/volto-editing-progress/commit/62c51d71b3586eaa4cfba7a9ead5e2970a536624)
- Refs #142010 - Optimize Volto-addons gitflow pipelines [`ecaea55`](https://github.com/eea/volto-editing-progress/commit/ecaea55e1987fdcf4228075fa05414f71922ba0c)

#### [0.1.5](https://github.com/eea/volto-editing-progress/compare/0.1.4...0.1.5)

> 24 June 2021
- Refs #124587 ensure we have document sidebar active on edit: [`#5`](https://github.com/eea/volto-editing-progress/pull/5)
- Refs #124587 lint fix: [`1fdaf0a`](https://github.com/eea/volto-editing-progress/commit/1fdaf0a2b7d003bc4c153b33f3d42dc02ed0359b)
- Refs #124587 ensure we have document sidebar active on edit: [`a070c42`](https://github.com/eea/volto-editing-progress/commit/a070c42c8fa495c9a094860c7c81e9f8b72890ff)

#### [0.1.4](https://github.com/eea/volto-editing-progress/compare/0.1.3...0.1.4)

Expand Down Expand Up @@ -35,7 +42,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
> 10 June 2021
- Cypress code coverage [`#1`](https://github.com/eea/volto-editing-progress/pull/1)
- [JENKINS] - Fix stylelint [`53ea81b`](https://github.com/eea/volto-editing-progress/commit/53ea81b9fd99913adbec69b25f2b456c40d4c5a7)
- Refs #124587 lint fixing [`2bc7ffa`](https://github.com/eea/volto-editing-progress/commit/2bc7ffa48535a1f032bfbfa242f0d0f9c09ad9b2)
- Refs #124587 wip setting bullets for soft required fields on edit [`5d0cd54`](https://github.com/eea/volto-editing-progress/commit/5d0cd54200117bda9b2fb9bb1ec56f270b6d3c33)
- Refs #124587 changed the following: [`5ac614f`](https://github.com/eea/volto-editing-progress/commit/5ac614f89fd9bef5775052f5ec1a171256235d1e)
Expand Down
73 changes: 52 additions & 21 deletions Jenkinsfile
Expand Up @@ -4,13 +4,37 @@ pipeline {
environment {
GIT_NAME = "volto-editing-progress"
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu"
SONARQUBE_TAGS = "volto.eea.europa.eu,www.eea.europa.eu-ims"
DEPENDENCIES = ""
}

stages {

stage('Release') {
when {
allOf {
environment name: 'CHANGE_ID', value: ''
branch 'master'
}
}
steps {
node(label: 'docker') {
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
sh '''docker pull eeacms/gitflow'''
sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
}
}
}
}

stage('Code') {
when {
allOf {
environment name: 'CHANGE_ID', value: ''
not { changelog '.*^Automated release [0-9\\.]+$' }
not { branch 'master' }
}
}
steps {
parallel(

Expand All @@ -36,6 +60,15 @@ pipeline {
}

stage('Tests') {
when {
allOf {
environment name: 'CHANGE_ID', value: ''
anyOf {
not { changelog '.*^Automated release [0-9\\.]+$' }
branch 'master'
}
}
}
steps {
parallel(

Expand Down Expand Up @@ -75,6 +108,15 @@ pipeline {
}

stage('Integration tests') {
when {
allOf {
environment name: 'CHANGE_ID', value: ''
anyOf {
not { changelog '.*^Automated release [0-9\\.]+$' }
branch 'master'
}
}
}
steps {
parallel(

Expand Down Expand Up @@ -122,10 +164,16 @@ pipeline {
}

stage('Report to SonarQube') {
// Exclude Pull-Requests
when {
allOf {
environment name: 'CHANGE_ID', value: ''
anyOf {
branch 'master'
allOf {
branch 'develop'
not { changelog '.*^Automated release [0-9\\.]+$' }
}
}
}
}
steps {
Expand Down Expand Up @@ -156,8 +204,8 @@ pipeline {
steps {
node(label: 'docker') {
script {
if ( env.CHANGE_BRANCH != "develop" && !( env.CHANGE_BRANCH.startsWith("hotfix")) ) {
error "Pipeline aborted due to PR not made from develop or hotfix branch"
if ( env.CHANGE_BRANCH != "develop" ) {
error "Pipeline aborted due to PR not made from develop branch"
}
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
sh '''docker pull eeacms/gitflow'''
Expand All @@ -168,23 +216,6 @@ pipeline {
}
}

stage('Release') {
when {
allOf {
environment name: 'CHANGE_ID', value: ''
branch 'master'
}
}
steps {
node(label: 'docker') {
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
sh '''docker pull eeacms/gitflow'''
sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
}
}
}
}

}

post {
Expand Down
91 changes: 89 additions & 2 deletions README.md
@@ -1,13 +1,25 @@
# volto-editing-progress

[![Releases](https://img.shields.io/github/v/release/eea/volto-editing-progress)](https://github.com/eea/volto-editing-progress/releases)

[![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2Fvolto-editing-progress%2Fmaster&subject=master)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-editing-progress/job/master/display/redirect)
[![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-editing-progress-master&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=volto-editing-progress-master)
[![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-editing-progress-master&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=volto-editing-progress-master)
[![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-editing-progress-master&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-editing-progress-master)
[![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-editing-progress-master&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-editing-progress-master)

[![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2Fvolto-editing-progress%2Fdevelop&subject=develop)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-editing-progress/job/develop/display/redirect)
[![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-editing-progress-develop&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=volto-editing-progress-develop)
[![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-editing-progress-develop&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=volto-editing-progress-develop)
[![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-editing-progress-develop&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-editing-progress-develop)
[![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-editing-progress-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-editing-progress-develop)

[Volto](https://github.com/plone/volto) add-on

[Volto](https://github.com/plone/volto) add-on: Editing progress

## Features

Demo GIF
Document Editing progress bar in Volto

## Getting started

Expand Down Expand Up @@ -70,6 +82,81 @@ Demo GIF

1. Happy editing!

## Release

### Automatic release using Jenkins

* The automatic release is started by creating a [Pull Request](../../compare/master...develop) from `develop` to `master`. The pull request status checks correlated to the branch and PR Jenkins jobs need to be processed successfully. 1 review from a github user with rights is mandatory.
* It runs on every commit on `master` branch, which is protected from direct commits, only allowing pull request merge commits.
* The automatic release is done by [Jenkins](https://ci.eionet.europa.eu). The status of the release job can be seen both in the Readme.md badges and the green check/red cross/yellow circle near the last commit information. If you click on the icon, you will have the list of checks that were run. The `continuous-integration/jenkins/branch` link goes to the Jenkins job execution webpage.
* Automated release scripts are located in the `eeacms/gitflow` docker image, specifically [js-release.sh](https://github.com/eea/eea.docker.gitflow/blob/master/src/js-release.sh) script. It uses the `release-it` tool.
* As long as a PR request is open from develop to master, the PR Jenkins job will automatically re-create the CHANGELOG.md and package.json files to be production-ready.
* The version format must be MAJOR.MINOR.PATCH. By default, next release is set to next minor version (with patch 0).
* You can manually change the version in `package.json`. The new version must not be already present in the tags/releases of the repository, otherwise it will be automatically increased by the script. Any changes to the version will trigger a `CHANGELOG.md` re-generation.
* Automated commits and commits with [JENKINS] or [YARN] in the commit log are excluded from `CHANGELOG.md` file.

### Manual release from the develop branch ( beta release )

#### Installation and configuration of release-it

You need to first install the [release-it](https://github.com/release-it/release-it) client.

```
npm install -g release-it
```

Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.

Release-it is a tool that automates 4 important steps in the release process:

1. Version increase in `package.json` ( increased from the current version in `package.json`)
2. `CHANGELOG.md` automatic generation from commit messages ( grouped by releases )
3. GitHub release on the commit with the changelog and package.json modification on the develop branch
4. NPM release ( by default it's disabled, but can be enabled in the configuration file )

To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)

```
export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
```

To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :

```
echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
```

#### Using release-it tool

There are 3 yarn scripts that can be run to do the release

##### yarn release-beta

Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).

```
? Select increment (next version):
❯ prepatch (0.1.1-beta.0)
preminor (0.2.0-beta.0)
premajor (1.0.0-beta.0)
Other, please specify...
```

##### yarn release-major-beta

Same as `yarn release-beta`, but with premajor version pre-selected.

##### yarn release

Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.

#### Important notes

> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
> Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version).

## How to contribute

See [DEVELOP.md](https://github.com/eea/volto-editing-progress/blob/master/DEVELOP.md).
Expand Down
4 changes: 3 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-editing-progress",
"version": "0.1.5",
"version": "0.1.6",
"description": "@eeacms/volto-editing-progress: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -23,6 +23,8 @@
},
"scripts": {
"release": "release-it",
"release-major-beta": "release-it major --preRelease=beta",
"release-beta": "release-it --preRelease=beta",
"bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
"stylelint": "../../../node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'",
"stylelint:overrides": "../../../node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'",
Expand Down

0 comments on commit 21ce4d4

Please sign in to comment.