Skip to content

Commit

Permalink
Setup CI pipeline for the repository (#2)
Browse files Browse the repository at this point in the history
* Formatting Dockerfile and pom.xml file

Signed-off-by: S m, Aruna <[email protected]>

* Add GH Actions

1. Test, build for all the PRs
2. Test, build after every merge to the main branch
3. Test, build and generate a new docker image for release.

This can be improved further by adding a auto-version increment
option for the pom.xml. Until then the version has to be
manually incremented for every new release.

Signed-off-by: S m, Aruna <[email protected]>

* Add CODEOWNERS file

Signed-off-by: S m, Aruna <[email protected]>

* Add CODE_OF_CONDUCT.md file

Signed-off-by: S m, Aruna <[email protected]>
  • Loading branch information
arsulegai authored Feb 13, 2022
1 parent ff1332c commit 13df741
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 23 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Pull Request CI

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Clone the repository
uses: "actions/checkout@v2"
- name: Setup JDK 8
uses: "actions/setup-java@v2"
with:
java-version: '8'
distribution: 'adopt-openj9'
- name: Run tests
run: mvn -B clean verify
- name: Run build
run: mvn -B package -DskipTests=true
24 changes: 24 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Merge Build and Sanity

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Clone the repository
uses: "actions/checkout@v2"
- name: Setup JDK 8
uses: "actions/setup-java@v2"
with:
java-version: '8'
distribution: 'adopt-openj9'
- name: Run tests and lints
run: mvn -B clean verify
- name: Run build
run: mvn -B clean package -DskipTests=true
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Clone the repository
uses: "actions/checkout@v2"
- name: Setup JDK 8
uses: "actions/setup-java@v2"
with:
java-version: '8'
distribution: 'adopt-openj9'
- name: Run tests and lints
run: mvn -B clean verify
- name: Run build
run: mvn -B clean package -DskipTests=true
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: "${{ secrets.PAT_USERNAME }}"
password: "${{ secrets.PAT }}"
- name: Generate a container image
run: |
version=$(mvn -q \
-Dexec.executable=echo \
-Dexec.args='${project.version}' \
--non-recursive \
exec:exec)
docker build . -t ghcr.io/${USERNAME_OR_ORG}/hlf-connector:${version}
docker push ghcr.io/${USERNAME_OR_ORG}/hlf-connector:${version}
shell: bash
env:
USERNAME_OR_ORG: "${{ github.repository_owner }}"
3 changes: 3 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
# Fabric Connector Maintainers
* @hyperledger-labs/hlf-connector-maintainers
8 changes: 8 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Code of Conduct Guidelines
==========================

Please review the Hyperledger [Code of
Conduct](https://wiki.hyperledger.org/community/hyperledger-project-code-of-conduct)
before participating. It is important that we keep things civil.

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ RUN rm -rf /usr/local/tomcat/webapps/examples/
RUN rm -rf /usr/local/tomcat/webapps/ROOT/*
RUN mkdir -p /usr/local/config



RUN addgroup -S -g 10001 appGrp \
&& adduser -S -D -u 10000 -s /sbin/nologin -h /opt/app/ -G appGrp app\
&& chown -R 10000:10001 /usr/local/tomcat && chown -R 10000:10001 /usr/local/config


USER 10000

COPY ./config/index.html /usr/local/tomcat/webapps/ROOT/

COPY ./config/setenv.sh /usr/local/tomcat/bin/

COPY ./target/hlf-connector.war /usr/local/tomcat/webapps/hlf-connector.war
COPY ./target/hlf-connector.war /usr/local/tomcat/webapps/hlf-connector.war
42 changes: 23 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.3.9</version>
</dependency>

<!-- Apache Kafka Spring Integration -->
<dependency>
<groupId>org.springframework.kafka</groupId>
Expand All @@ -93,28 +92,18 @@
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</dependency>

<!-- Testing related dependencies -->
<!-- Hyperledger Fabric -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<groupId>org.hyperledger.fabric</groupId>
<artifactId>fabric-gateway-java</artifactId>
<version>2.2.0</version>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.hyperledger.fabric-sdk-java</groupId>
<artifactId>fabric-sdk-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.hyperledger.fabric</groupId>
<artifactId>fabric-gateway-java</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.hyperledger.fabric-sdk-java</groupId>
<artifactId>fabric-sdk-java</artifactId>
Expand All @@ -126,11 +115,28 @@
</exclusion>
</exclusions>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.16.0</version>
</dependency>
<!-- Testing related dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
Expand All @@ -144,8 +150,6 @@
<version>3.6.0</version>
<scope>test</scope>
</dependency>


</dependencies>

<build>
Expand Down

0 comments on commit 13df741

Please sign in to comment.