Skip to content

Commit

Permalink
Intermediate sync commit (#12)
Browse files Browse the repository at this point in the history
* simple friendly bot

* change bot config with environment variables

* add git actions heroku deploy

* fix java config in deploy.yml

* change deploy.yml

* change ci/cd

* add dockerfile

* WIP Add deploy CI/CD config

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP Deploy test

* WIP Deploy test

* WIP Deploy test. Profile edited

* WIP. Deploy test. Change proccess type

* WIP. Deploy test. Added server port

* WIP. Deploy test. Remove server port

* WIP. Deploy test. Changed application version

* WIP

* WIP. Deploy test. Fixed workflow CI/CD

* WIP. Deploy test. Update wokflow enviroment

* Added checkstyle and satisfies its requiroments

* WIP

* Create repo branches scheme (#8)

* Added project_versioning_policy and related files

* docker composer with postgres

* postgres datasource for idea

* gitignore cleanup

* remove maven.yml

* Added branches

* Edit workflow: enable feature branch to jobs

---------

Co-authored-by: rain <[email protected]>
Co-authored-by: Artem Marchenko <[email protected]>

---------

Co-authored-by: rain <[email protected]>
Co-authored-by: Artem Marchenko <[email protected]>
  • Loading branch information
3 people authored Mar 7, 2023
1 parent 3afdcb6 commit c3a4bef
Show file tree
Hide file tree
Showing 22 changed files with 811 additions and 43 deletions.
51 changes: 51 additions & 0 deletions .github/busbot-code-style.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<code_scheme name="Busbot Code Style" version="173">
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="true" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
</value>
</option>
</JavaCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="120" />
<option name="BLANK_LINES_BEFORE_PACKAGE" value="1" />
<option name="BLANK_LINES_AROUND_FIELD" value="1" />
<option name="BLANK_LINES_AFTER_IMPORTS" value="2" />
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="RESOURCE_LIST_WRAP" value="1" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_LIST_WRAP" value="1" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_WRAP" value="1" />
<option name="FOR_STATEMENT_WRAP" value="1" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<option name="ASSERT_STATEMENT_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<option name="PARAMETER_ANNOTATION_WRAP" value="1" />
<option name="VARIABLE_ANNOTATION_WRAP" value="1" />
<option name="ENUM_CONSTANTS_WRAP" value="1" />
<option name="ENUM_CONSTANTS_WRAP" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
139 changes: 139 additions & 0 deletions .github/checkstyle-configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
<property name="charset" value="UTF-8"/>

<property name="severity" value="error"/>

<property name="fileExtensions" value=".java"/>

<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>

<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="NewlineAtEndOfFile"/>

<module name="TreeWalker">
<module name="AbbreviationAsWordInName">
<property name="allowedAbbreviationLength" value="4"/>
<property name="ignoreFinal" value="true"/>
<property name="ignoreStatic" value="false"/>
<property name="ignoreOverriddenMethods" value="false"/>
<property name="tokens"
value="CLASS_DEF, INTERFACE_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/>
</module>
<module name="AnnotationLocation">
<property name="allowSamelineSingleParameterlessAnnotation" value="false"/>
</module>
<module name="ArrayTrailingComma"/>
<module name="ArrayTypeStyle"/>
<module name="AtclauseOrder"/>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="AvoidNestedBlocks"/>
<module name="AvoidStarImport"/>
<module name="CommentsIndentation"/>
<module name="ConstantName"/>
<module name="CustomImportOrder">
<property name="customImportOrderRules"
value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE"/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
</module>
<module name="EmptyBlock">
<property name="option" value="TEXT"/>
</module>
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/>
</module>
<module name="EmptyLineSeparator"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="ExplicitInitialization"/>
<module name="FallThrough"/>
<module name="GenericWhitespace">
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
</module>
<module name="InterfaceTypeParameterName"/>
<module name="LambdaParameterName">
<message key="name.invalidPattern"
value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LeftCurly"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="MethodParamPad"/>
<module name="MethodTypeParameterName"/>
<module name="MissingSwitchDefault"/>
<module name="MultipleVariableDeclarations"/>
<module name="NeedBraces"/>
<module name="NoFinalizer"/>
<module name="NoWhitespaceBefore"/>
<module name="OneStatementPerLine"/>
<module name="OneTopLevelClass"/>
<module name="OperatorWrap"/>
<module name="OuterTypeFilename"/>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParenPad"/>
<module name="RightCurly"/>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapDot"/>
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapComma"/>
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapEllipsis"/>
<property name="tokens" value="ELLIPSIS"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapArrayDeclarator"/>
<property name="tokens" value="ARRAY_DECLARATOR"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapMethodRef"/>
<property name="tokens" value="METHOD_REF"/>
<property name="option" value="nl"/>
</module>
</module>
</module>
37 changes: 0 additions & 37 deletions .github/workflows/build.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/buildAndDeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and deploy workflow

on:
push:
branches:
- dev
- master
- 'release/**'
# - 'hotfix/**'
- 'feature/**'

jobs:
package:
runs-on: ubuntu-latest
env:
BOT_NAME: ${{ secrets.BOT_NAME }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME}}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN}}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: temurin

- name: Publish to Docker Hub
# if: "startsWith(env.TAG_NAME, 'dev') || startsWith(env.TAG_NAME, 'release')"
run: >-
mvn
clean install
-PpushToDockerHub
deploy:
needs: package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Heroku Container registry
env:
HEROKU_API_KEY: ${{secrets.HEROKU_API_KEY}}
run: heroku container:login
- name: Push image to Heroku
env:
HEROKU_API_KEY: ${{secrets.HEROKU_API_KEY}}
run:
docker pull atmtrans/busbot &&
docker tag atmtrans/busbot registry.heroku.com/busbot-atmtrans/worker &&
docker push registry.heroku.com/busbot-atmtrans/worker
- name: Deploy application to Heroku
env:
HEROKU_API_KEY: ${{secrets.HEROKU_API_KEY}}
run:
heroku container:release -a busbot-atmtrans worker
Binary file added docs/media/git_flow_scheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions docs/project_versioning_policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
## Project versioning policy

This document describes guide of GitFlow process established on this project.
Whenever you want to participate to develop some functionality or contribute
some changes to the current project, please follow rules described in this
file.

___

### Git Flow

The GitFlow schema approved for this project is illustrated by the following
sketch.

![Git Flow Scheme](media/git_flow_scheme.png)

* ```master``` branch: Contains stable, released code. Any direct pushes from
working (feature, dev) branches to this branch are NOT ALLOWED. All pull
requests will be rejected.

* ```release``` branch: Temporary branch. Contains all workable,
requirement-matched code for future deploy. Support for preparing a new product
release. Allows you to fix small bugs and prepare different metadata for the
release.

* ```dev``` branch: Develop branch should be inherited from latest master
version. Developers should to create a separate ```feature``` branches for
implement new functionality and open a pull request to push back a workable
code into this branch. Also, this branch allow strict merge of minor
corrections (e.g. typos, renaming, etc.)

* ```feature``` branch: Should be created for implementation a new
functionality. The development of new features starts from the "dev" branch.
Once, when all work is done and matches all requirements this branch should
be merged into ```dev``` branch. This branch is temporary. Thus, after the pull
request is closed, this branch will be deleted. Naming of this branch are
numbered by tracking system (e.g. ZenHub) and should implement all
functionality described in the ticket.

* ```hotfix``` branch: Branch created for immediate fix functionality of
released code if it goes wrong. The only branch which can be merged
directly to the master branch.

* ```bugfix``` branch: Branch for fixes of non-critical errors in the app
behaviour. This branch should be inherited from dev, opened after
```bug report``` ticket were opened and should be numbered by ticket's number.
The correction which presented in this code should be covered by a test case
that catches the bug described in the ZenHub ticket. After all work is done
all commits should be merged in the ```dev``` branch. Naming in this branch
is equivalent to ```hotfix``` branch naming.

* ```refactor``` branch: This branch should be created for the correction
of the implementation which is working correctly but the way of its
implementation has some flaws which are conflict with best practices,
have some security vulnerabilities, or violates
[Java Code Convention](https://www.oracle.com/technetwork/java/codeconventions-150003.pdf).
This branch should be opened in according to Zenhub ticket. Result committed in
this branch should be merged into dev by opening a pull request.

### Examples of naming:

```
GOOD:
feature/#2-Creating_new_functionality
hotfix/#245-Unexeptable_response_during_pay_process
bugfix/#252-Incorrect_route_building
refactor/#632-Ticket_booking_service_logic_refactor
BAD:
Feature/230-WrongBranchName
Hotfix/#134-Fix-branch-naming
```
8 changes: 8 additions & 0 deletions launch/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.8"

services:
busbot:
image: atmtrans/busbot
environment:
BOT_TOKEN: ${BOT_TOKEN}
BOT_NAME: ${BOT_NAME}
Loading

0 comments on commit c3a4bef

Please sign in to comment.