File tree Expand file tree Collapse file tree 8 files changed +98
-2
lines changed
test/java/com/redhat/labs/omp/resource Expand file tree Collapse file tree 8 files changed +98
-2
lines changed Original file line number Diff line number Diff line change 1
- name : Java CI
1
+ name : Container Build
2
2
3
3
on :
4
4
push :
18
18
java-version : 13.0.1
19
19
- name : Build with Maven & Quarkus
20
20
run : mvn test
21
+ - name : Find and Replace Commit
22
+ uses :
jacobtomlinson/[email protected]
23
+ with :
24
+ find : " ###GIT_COMMIT###"
25
+ replace : " ${{ github.sha }}"
26
+ include : " .s2i"
27
+ - name : Find and Replace Tag
28
+ uses :
jacobtomlinson/[email protected]
29
+ with :
30
+ find : " ###GIT_TAG###"
31
+ replace : " ${{ github.ref }}"
32
+ include : " .s2i"
21
33
- uses : redhat-cop/github-actions/s2i@v2
22
34
with :
23
35
base : registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift:1.8
Original file line number Diff line number Diff line change 1
- name : Java CI
1
+ name : PR check
2
2
3
3
on :
4
4
- pull_request
Original file line number Diff line number Diff line change
1
+ GIT_API_GIT_COMMIT=###GIT_COMMIT###
2
+ GIT_API_GIT_TAG=###GIT_TAG###
Original file line number Diff line number Diff line change
1
+ ![ Container Build] ( https://github.com/rht-labs/open-management-portal-git-api/workflows/Container%20Build/badge.svg )
2
+
1
3
# open-management-portal-git-api project
2
4
3
5
This project uses Quarkus, the Supersonic Subatomic Java Framework.
Original file line number Diff line number Diff line change
1
+ package com .redhat .labs .omp .models ;
2
+
3
+ import lombok .AllArgsConstructor ;
4
+ import lombok .Builder ;
5
+ import lombok .Data ;
6
+ import lombok .NoArgsConstructor ;
7
+
8
+ @ Data
9
+ @ Builder
10
+ @ NoArgsConstructor
11
+ @ AllArgsConstructor
12
+ public class Version {
13
+
14
+ private String gitCommit ;
15
+ private String gitTag ;
16
+
17
+ }
Original file line number Diff line number Diff line change
1
+ package com .redhat .labs .omp .resource ;
2
+
3
+ import javax .ws .rs .Consumes ;
4
+ import javax .ws .rs .GET ;
5
+ import javax .ws .rs .Path ;
6
+ import javax .ws .rs .Produces ;
7
+ import javax .ws .rs .core .MediaType ;
8
+
9
+ import org .eclipse .microprofile .config .inject .ConfigProperty ;
10
+ import org .eclipse .microprofile .metrics .annotation .Counted ;
11
+ import org .eclipse .microprofile .metrics .annotation .Timed ;
12
+
13
+ import com .redhat .labs .omp .models .Version ;
14
+
15
+ /**
16
+ * Provides version information via api. Expected to come from the container in a prod env
17
+ * @author mcanoy
18
+ *
19
+ */
20
+ @ Path ("/api/v1/version" )
21
+ @ Produces (MediaType .APPLICATION_JSON )
22
+ @ Consumes (MediaType .APPLICATION_JSON )
23
+ public class VersionResource {
24
+
25
+ @ ConfigProperty (name = "git.commit" )
26
+ String gitCommit ;
27
+
28
+ @ ConfigProperty (name = "git.tag" )
29
+ String gitTag ;
30
+
31
+ @ GET
32
+ @ Timed (name ="versionResourceTimer" )
33
+ @ Counted (name ="versionResourceCounter" )
34
+ public Version getVersion () {
35
+ return new Version (gitCommit , gitTag );
36
+ }
37
+ }
Original file line number Diff line number Diff line change @@ -37,3 +37,6 @@ residenciesParentRepositoryId=${RESIDENCIES_PARENT_REPOSITORIES_ID:2}
37
37
gitlab.api/mp-rest/url =${GITLAB_API_URL:https://acmegit.com}
38
38
deployKey =${DEPLOY_KEY:0}
39
39
40
+ git.commit =${GIT_API_GIT_COMMIT:not.set}
41
+ git.tag =${GIT_API_GIT_TAG:not.set}
42
+
Original file line number Diff line number Diff line change
1
+ package com .redhat .labs .omp .resource ;
2
+
3
+ import static io .restassured .RestAssured .given ;
4
+ import static org .hamcrest .CoreMatchers .is ;
5
+
6
+ import org .junit .jupiter .api .Test ;
7
+
8
+ import io .quarkus .test .junit .QuarkusTest ;
9
+
10
+ @ QuarkusTest
11
+ public class VersionResourceTest {
12
+
13
+ @ Test
14
+ public void testValidResourceVersion () {
15
+ given ()
16
+ .when ()
17
+ .get ("/api/v1/version" )
18
+ .then ()
19
+ .statusCode (200 )
20
+ .body (is ("{\" git_commit\" :\" not.set\" ,\" git_tag\" :\" not.set\" }" ));
21
+ }
22
+ }
23
+
You can’t perform that action at this time.
0 commit comments