Add build system (#8)

This commit is contained in:
Alexey S 2022-01-28 13:34:24 +03:00 committed by GitHub
parent 4d54c8aaa6
commit ffc1b1b5df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 21375 additions and 500 deletions

38
.github/workflows/build-v2.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: OpenAPI Spec CI
on:
pull_request:
branches:
- v2
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache Node Modules and NPM Cache
id: cache
uses: actions/cache@v2
with:
path: |
node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
- name: Install deps
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
- name: Run tests
run: npm test
- name: Bundle spec and build docsite
run: npm run build

48
.github/workflows/release-v2.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Release
on:
push:
branches:
- v2
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Cache Node Modules and NPM Cache
id: cache
uses: actions/cache@v2
with:
path: |
node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
- name: Install deps
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
- name: Run tests
run: npm test
- name: Bundle spec and build docsite
run: npm run build -- web_deploy
- name: Prepare release artifacts
run: mkdir -p out && cp web_deploy/swagger.{yaml,json} out/
- name: Deploy artifacts to release branch
uses: JamesIves/github-pages-deploy-action@v4.2.2
with:
branch: release/v2
folder: out
commit-message: Release ${{ github.repository }}@${{ github.sha }} by ${{ github.actor }}

1
.gitignore vendored
View File

@ -38,7 +38,6 @@ node_modules
# Generated
web_deploy/
package-lock.json
# User-specific stuff:
.idea/

4
.gitmodules vendored
View File

@ -1,4 +0,0 @@
[submodule "build_utils"]
path = build_utils
url = git@github.com:rbkmoney/build_utils.git
branch = master

View File

@ -1,45 +0,0 @@
# swag-v2
## Version 2.0.0 to 2.0.1
---
### What's New
---
### What's Deprecated
---
### What's Changed
---
`GET` /analytics/shops/{shopID}/invoices
Parameters
Modify bankCardTokenProvider
- yandexpay
Modify paymentTerminalProvider
- uzcard
`GET` /analytics/shops/{shopID}/payments
Parameters
Modify bankCardTokenProvider
- yandexpay
Modify paymentTerminalProvider
- uzcard
`GET` /processing/invoices/{invoiceID}/payments
Return Type
Insert transactionInfo
`GET` /processing/invoices/{invoiceID}/payments/{paymentID}
Return Type
Insert transactionInfo
`GET` /processing/payments
Return Type
Insert transactionInfo

View File

@ -1 +0,0 @@
* @rbkmoney/appsec

38
Jenkinsfile vendored
View File

@ -1,38 +0,0 @@
#!groovy
build('common-api', 'docker-host') {
checkoutRepo()
loadBuildUtils()
def pipeDefault
def gitUtils
runStage('load pipeline') {
env.JENKINS_LIB = "build_utils/jenkins_lib"
pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy")
gitUtils = load("${env.JENKINS_LIB}/gitUtils.groovy")
}
pipeDefault() {
runStage('init') {
withGithubSshCredentials {
sh 'make wc_init'
}
}
runStage('build') {
sh 'make wc_build'
}
// Java
runStage('Build client & server') {
withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) {
if (env.BRANCH_NAME == 'v2' || env.BRANCH_NAME.startsWith('epic/')) {
sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.deploy_client'
sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.deploy_server'
} else {
sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.compile_client'
sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.compile_server'
}
}
}
}
}

129
Makefile
View File

@ -1,129 +0,0 @@
SUBMODULES = build_utils
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
UTILS_PATH := build_utils
TEMPLATES_PATH := .
# Name of the service
SERVICE_NAME := common-api
# Service image default tag
SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD)
# The tag for service image to be pushed with
SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG)
BUILD_IMAGE_TAG := f3732d29a5e622aabf80542b5138b3631a726adb
CALL_ANYWHERE := \
all submodules init build java.compile java.deploy
CALL_W_CONTAINER := $(CALL_ANYWHERE)
all: build
-include $(UTILS_PATH)/make_lib/utils_image.mk
-include $(UTILS_PATH)/make_lib/utils_container.mk
.PHONY: $(CALL_W_CONTAINER)
$(SUBTARGETS): %/.git: %
git submodule update --init $<
touch $@
submodules: $(SUBTARGETS)
# NPM
build:
npm install
npm run build
start:
npm start
test:
npm run test
# wercker
dev:
wercker dev --publish 3000 --direct-mount
# swagger
ifdef SWAGGER_PORTS
DOCKER_RUN_OPTS += -p 127.0.0.1:3000:3000
DOCKER_RUN_OPTS += -p 127.0.0.1:5000:5000
endif
# Java
ifdef SETTINGS_XML
DOCKER_RUN_OPTS += -v $(SETTINGS_XML):$(SETTINGS_XML)
DOCKER_RUN_OPTS += -e SETTINGS_XML=$(SETTINGS_XML)
endif
ifdef LOCAL_BUILD
DOCKER_RUN_OPTS += -v $$HOME/.m2:/home/$(UNAME)/.m2:rw
endif
COMMIT_HASH := $(shell git --no-pager log -1 --pretty=format:"%h")
NUMBER_COMMITS := $(shell git rev-list --count HEAD)
JAVA_PKG_VERSION := 1.$(NUMBER_COMMITS)-$(COMMIT_HASH)
ifdef BRANCH_NAME
ifeq "$(findstring epic,$(BRANCH_NAME))" "epic"
JAVA_PKG_VERSION := $(JAVA_PKG_VERSION)-epic
endif
endif
MVN = mvn -s $(SETTINGS_XML) -Dcommit.number="$(NUMBER_COMMITS)"
java.swag.compile_client:
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
$(MVN) clean && \
$(MVN) compile -P="client"
java.swag.deploy_client:
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
$(MVN) clean && \
$(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-client" && \
$(MVN) deploy -P="client"
java.swag.install_client:
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
$(MVN) clean && \
$(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-client" && \
$(MVN) install -P="client"
java.swag.compile_server:
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
$(MVN) clean && \
$(MVN) compile -P="server"
java.swag.deploy_server:
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
$(MVN) clean && \
$(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-server" && \
$(MVN) deploy -P="server"
java.swag.install_server:
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
$(MVN) clean && \
$(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-server" && \
$(MVN) install -P="server"
java.compile: java.settings
$(MVN) compile
java.deploy: java.settings
$(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)" && \
$(MVN) deploy
java.install: java.settings
$(MVN) clean && \
$(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)" && \
$(MVN) install
java.settings:
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)

@ -1 +0,0 @@
Subproject commit ccf618949b95590d572157b248289428abeaa2e5

21287
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
{
"name": "RBKmoney-openapi-spec",
"name": "vality-openapi-spec",
"version": "0.0.1",
"dependencies": {
"bower": "^1.7.7",

207
pom.xml
View File

@ -1,207 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.rbkmoney</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>common-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Common API swag</name>
<description>Generates jar artifact containing compiled swagger classes based on generated swagger yaml files
</description>
<properties>
<default.package>com.rbkmoney.swag.common_api</default.package>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations-version>1.5.21</swagger-annotations-version>
<jodatime-version>2.7</jodatime-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<jetty-version>9.2.15.v20160210</jetty-version>
<slf4j-version>1.7.21</slf4j-version>
<junit-version>4.12</junit-version>
<servlet-api-version>2.5</servlet-api-version>
<springfox-version>2.7.0</springfox-version>
<jackson-version>2.8.9</jackson-version>
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
<spring-version>5.1.3.RELEASE</spring-version>
<javax-annotation-api-version>1.3.2</javax-annotation-api-version>
<javax-validation-api-version>1.1.0.Final</javax-validation-api-version>
<jaxb-version>2.3.1</jaxb-version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version>
<scope>provided</scope>
</dependency>
<!--Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<!--SpringFox dependencies-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>${javax-annotation-api-version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-version}</version>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax-validation-api-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>server</id>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>generate-server</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>web_deploy/swagger.yaml</inputSpec>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<language>spring</language>
<library>spring-mvc</library>
<apiPackage>${default.package}.api</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>client</id>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>generate-client</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>web_deploy/swagger.yaml</inputSpec>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<language>java</language>
<library>resttemplate</library>
<apiPackage>${default.package}.api</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>RBKmoney Payments API</title>
<title>Vality Payments API</title>
<!-- needed for adaptive design -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -1,72 +0,0 @@
box:
id: node:7
username: ${DOCKER_ID}
password: ${DOCKER_PWD}
build:
steps:
- npm-install
- npm-test
- script:
name: build docsite
code: npm run build -- ${WERCKER_OUTPUT_DIR}
after-steps:
- slack-notifier:
url: ${SLACK_WEBHOOK_URL}
username: "wercker"
dev:
steps:
- npm-install
- npm-test
- internal/shell
release-epic:
steps:
- script:
name: prepare release artifacts for epic/* branch
code: mkdir -p out && cp ./swagger.{yaml,json} out/
- lordlothar99/git-push:
gh_oauth: ${GITHUB_API_TOKEN}
branch: release/${WERCKER_GIT_BRANCH}
basedir: out
message: Epic release ${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}@${WERCKER_GIT_COMMIT}
after-steps:
- slack-notifier:
url: ${SLACK_WEBHOOK_URL}
username: "wercker"
release-v:
steps:
- script:
name: prepare release artifacts for branch v1, v2, etc.
code: mkdir -p out && cp ./swagger.{yaml,json} out/
- lordlothar99/git-push:
gh_oauth: ${GITHUB_API_TOKEN}
branch: release/${WERCKER_GIT_BRANCH}
basedir: out
message: Release ${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}@${WERCKER_GIT_COMMIT}
after-steps:
- slack-notifier:
url: ${SLACK_WEBHOOK_URL}
username: "wercker"
deploy:
steps:
- lukevivier/gh-pages:
repo: rbkmoney/api
token: ${GITHUB_API_TOKEN}
after-steps:
- slack-notifier:
url: ${SLACK_WEBHOOK_URL}
username: "wercker"
deploy-next:
steps:
- lukevivier/gh-pages:
repo: rbkmoney/api-v2
token: ${GITHUB_API_TOKEN}
after-steps:
- slack-notifier:
url: ${SLACK_WEBHOOK_URL}
username: "wercker"