Skip to content

Commit

Permalink
Resolve WIT-537 "Version docker images mwaa"
Browse files Browse the repository at this point in the history
# Breaking changes

From now on, docker images will be versioned, and will follow the same versioning mechanism of witboost core component.

# Definition of Done for Feature/Hotfixes

## All Developments

* [x] Feature was implemented as per the requirements
* [x] If some code parts are complex they must be commented with code documentation
* [x] CI/CD is successful
* [x] Code coverage is not reduced, any new code is covered
* [x] E2E/integration tests are successful (whether run locally or in CI/CD)
* [x] If dependencies were changed, be sure that they will not impact the project, that their license is compatible, and that they introduce no vulnerabilities
* [x] Documentation have been updated
  * Documentation has been updated with explanation of the new feature if it is user-facing (eg component now has additional setting) or it impacts him in some other way (eg optional field that becomes mandatory)
  * If it is a breaking change, we have documented it as such in the MR description in a "Breaking Changes" section
* [x] Check that you are not affecting any existing environments with these changes, especially the Sandbox/Playground. This means that merging it to master and deploying it to these environments will not break them and **no manual operations that are not reported in the documentation will be needed**
* [x] Check that nothing is out of order and nothing problematic is included in the changes (sensitive information, credentials, customer information or other intellectual property) as they could end up being public (we have Open Source SP already published and automatically mirrored)
* [x] Security, Authentication and Authorization have been considered. No SQL injection, tokens handling, RBAC integration. Common security vulnerabilities identified and resolved

## API Development

* [ ] Semantic of API has been checked, it is comprehensible, meaningful, with no redundant information and user oriented
* [ ] Meaningful unit and integration tests are present
* [ ] API Parameters are checked and errors are handled
* [ ] Returned errors are meaningful to the user
* [ ] API contract has been defined and documented. Documentation means explaining the meaning of all fields and including at least one example
* [ ] Exceptions and errors are handled, without letting the underlying framework to respond with a generic Internal Server Error
* [ ] API Performance has been assessed and is good for real world use cases. Database accesses have been optimized.
* [ ] API is logging in compliance with audit standards, presence of sensitive information for GDPR has been assessed and removed or managed in case is needed

## DB Development

* [ ] The database schema is designed to accurately represent the data model and meet the requirements
* [ ] Tables, relationships, and constraints (e.g. primary keys, foreign keys, unique constraints) are defined appropriately and following a common convention
* [ ] Normalization principles are applied to eliminate data redundancy and ensure data integrity
* [ ] Schema semantic is meaningful
* [ ] Fields naming are following naming convention ( Ex. camelCase or snake_case)
* [ ] No fields with mixed behaviors and meaning. If a field is representing an enum, enum values are strongly mutually exclusive
* [ ] Data Types have been reviewed and they are a good fit for each field
* [ ] Indexes are defined to optimize query performance for frequently accessed data, paying attention to do not affect too much write path and the overall complexity
* [ ] Sensitive data is stored securely, encrypted if required, and access is restricted to authorized users
* [ ] Backup and restore procedures have been updated to introduce new or changed tables
* [ ] Migration scripts to upgrade and downgrade the database have been implemented and tested

Closes WIT-537
  • Loading branch information
cventr-agilelab committed Oct 13, 2023
1 parent bad743a commit 4271ae8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ build:
apt-get install -yqq docker-ce-cli
apt-get install -yqq npm
npm install @openapitools/openapi-generator-cli -g
echo $VERSION
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
sbt clean generateCode compile k8tyGitlabCIPublish docker:publish
echo VERSION=$(sbt -Dsbt.log.noformat=true 'inspect actual version' | grep "Setting: java.lang.String" | cut -d '=' -f2 | tr -d ' ') >> vars.env
echo COMMIT=`git log -1 --pretty=%B | head -n 1 | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z` >> vars.env
cat vars.env
artifacts:
reports:
dotenv: vars.env
Expand Down
5 changes: 1 addition & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ lazy val root = (project in file(".")).settings(
dockerBaseImage := "adoptopenjdk:11-jdk-hotspot",
dockerUpdateLatest := true,
daemonUser := "daemon",
Docker / version := s"${
val buildVersion = (ThisBuild / version).value
if (buildVersion == "latest") buildVersion else s"v$buildVersion"
}".toLowerCase,
Docker / version := (ThisBuild / version).value,
Docker / packageName :=
s"registry.gitlab.com/agilefactory/witboost.mesh/provisioning/sandbox/witboost.mesh.provisioning.sandbox.mwaaspecificprovisioner",
Docker / dockerExposedPorts := Seq(8080),
Expand Down
27 changes: 1 addition & 26 deletions project/ComputeVersion.scala
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
import scala.sys.process._
import scala.util.matching.Regex

/** It computes the project version starting from git repository information
* A release branch should be in the form MAJOR.MINOR.x and the resulting version is computed in the following way:
* 1) if there are no tags associated to this branch in the form vMAJOR.MINOR.BUILD the resulting version is MAJOR.MINOR.1-SNAPSHOT
* 2) if there are tags then the BUILD number is computed as the max among all the tags build numbers incremented by one and
* the resulting version is MAJOR.MINOR.COMPUTEDBUILD-SNAPSHOT
* A tag is expected to be in the form vMAJOR.MINOR.BUILD and the resulting version is MAJOR.MINOR.BUILD
* Otherwise the resulting version is 0.0.0
*/
object ComputeVersion {

val gitOutput: String =
("git symbolic-ref -q --short HEAD" #|| "git describe --tags --exact-match" #|| "git rev-parse --short HEAD")
.lineStream_!.head
lazy val version: String = scala.util.Properties.envOrElse("VERSION", "0.0-local")

val releaseBranch: Regex = "([1-9]\\d*)\\.(\\d+)\\.([x])".r

val tag: Regex = "v([0-9]\\d*)\\.(\\d+)\\.(\\d+)".r

lazy val version: String = gitOutput match {
case tag(major, minor, build) => s"$major.$minor.$build"
case releaseBranch(major, minor, _*) =>
val out = s"""git tag --list v$major.$minor*""".lineStream_!.toList
if (out.isEmpty) s"$major.$minor.1-SNAPSHOT"
else {
val lastBuildVersion = out.map(_.split("\\.")(2)).map(_.toInt).foldLeft(0)(Math.max)
s"$major.$minor.${(lastBuildVersion + 1).toString}-SNAPSHOT"
}
case _ => "0.0.0"
}
}

0 comments on commit 4271ae8

Please sign in to comment.