Giter Site home page Giter Site logo

dilippurohit3 / semaphore-demo-java-spring Goto Github PK

View Code? Open in Web Editor NEW

This project forked from semaphoreci-demos/semaphore-demo-java-spring

0.0 0.0 0.0 1.16 MB

A Semaphore demo CI/CD pipeline using Java Spring.

Home Page: https://semaphoreci.com/blog/spring-boot-microservices-cicd

License: MIT License

Java 98.37% HTML 0.80% Dockerfile 0.83%

semaphore-demo-java-spring's Introduction

Semaphore demo CI/CD pipeline using Java Spring

Build Status

Example Spring Boot application and CI/CD pipeline showing how to run a Java project on Semaphore 2.0.

Application overview

Features

  • Simple login screen
  • User registration
  • An endpoint secured with Basic authentification layer
  • Persistence layer for storing users in database

Endpoints

  • "/admin/home" a secured endpoint that returns a webpage in a form of text/html, generated with thymeleaf. AdminController
  • "/login" standard spring login endpoint
  • "/logout" rest endpoint, ends user session, redirects to "/login"
  • "/users/signup" rest endpoint, adds a new user to the system. UserController

Persistence

Persistence for this project is set up using Spring Data JPA, and utilizes m2 database, which is a runtime database for the ease of testing and continuous integration, however is fully compatible with many standard database technologies like Postgres.

There is a single database entity User and a corresponding repository UserRepository

Tests

Tests are separated into two classpaths (in order to run them as separate tasks):

  • src/test holds the unit tests
  • src/it holds the integration tests, in this case repository and rest endpoint tests.

CI/CD pipeline on Semaphore

The Semaphore pipeline is configured to:

  1. Build the project
  2. Run tests
  3. Build Docker image
  4. Push image to hub.docker.com

Semaphore pipeline configuration is located at .semaphore/semaphore.yml

Setting up

To set up this pipeline on your Semaphore account:

  1. If you don't have sem command line tool installed, do so using curl https://storage.googleapis.com/sem-cli-releases/get.sh | bash and then connect to your account using sem connect <your organisation>.semaphoreci.com <your private key>. You can get the private key from your account dashboard at semaphoreci.com.
  2. Add the project to Semaphore using sem init.
  3. This pipeline relies on public Docker repository to push artifacts of successful builds. Create an account on https://hub.docker.com/ if you don't have one.
  4. Add your hub.docker.com credentials to ./docker-hub-secret.yml. The credentials should remain private, so don't publish them to your Git repository by mistake.
  5. Add your ./docker-hub-secret.yml credentials to Semaphore with sem create -f docker-hub-secret.yml

After pushing a new commit to master, Semaphore will initiate a workflow:

alt text

Build configuration

This project is set up using Maven. Build configuration can be found at pom.xml.

Running the project

mvn spring-boot:run

Running tests

Tests are separated into two classpaths: src/test for unit tests, and src/it for integration tests.

To run unit tests:

mvn clean test

To run integration tests

mvn clean test -Pintegration-testing

To run performance tests

mvn clean jmeter:jmeter

JMeter GUI

mvn jmeter:gui

License

Copyright (c) 2022 Rendered Text

Distributed under the MIT License. See the file LICENSE.

semaphore-demo-java-spring's People

Contributors

thepinkpanther avatar tomfern avatar markoa avatar commanderk5 avatar aleksandarcole avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.