Skip to content

Commit 22b412b

Browse files
author
Derek Tang
committed
initial ci
1 parent ebe70a1 commit 22b412b

File tree

5 files changed

+175
-2
lines changed

5 files changed

+175
-2
lines changed

.dockerignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
.github
3+
4+
.dockerignore
5+
.gitignore
6+
Dockerfile
7+
Jenkinsfile
8+
OrthoinferenceOverview.png
9+
README.md

.github/workflows/ci.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: release-orthoinference ci
2+
3+
4+
on:
5+
workflow_dispatch:
6+
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
12+
push:
13+
branches:
14+
- main
15+
16+
17+
permissions:
18+
id-token: write
19+
contents: read
20+
21+
22+
jobs:
23+
lint:
24+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
25+
runs-on: ubuntu-latest
26+
env:
27+
REPO_DIR : /opt/release-orthoinference
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Run lint
32+
run: |
33+
docker build --build-arg REPO_DIR="$REPO_DIR" --target setup-env -t lint-image .
34+
docker run --name lint-container lint-image
35+
36+
- name: Display lint errors
37+
if: failure()
38+
run: |
39+
docker cp lint-container:"$REPO_DIR"/lint.log .
40+
while IFS= read -r LINT_MSG; do echo "::warning::${LINT_MSG}"; done < lint.log
41+
exit 1
42+
43+
docker-build:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- uses: docker/setup-buildx-action@v3
49+
50+
- uses: docker/build-push-action@v5
51+
with:
52+
context: .
53+
file: Dockerfile
54+
tags: tmp-tag
55+
outputs: type=docker,dest=/tmp/image.tar
56+
57+
- uses: actions/upload-artifact@v4
58+
with:
59+
name: image-artifact
60+
path: /tmp/image.tar
61+
62+
docker-push:
63+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
64+
needs: docker-build
65+
runs-on: ubuntu-latest
66+
steps:
67+
- env:
68+
AWS_REGION : us-east-1
69+
uses: aws-actions/configure-aws-credentials@v4
70+
with:
71+
role-to-assume: ${{ vars.AWS_ROLE }}
72+
aws-region: ${{ env.AWS_REGION }}
73+
74+
- id: login-ecr
75+
uses: aws-actions/amazon-ecr-login@v2
76+
77+
- uses: actions/download-artifact@v4
78+
with:
79+
name: image-artifact
80+
path: /tmp
81+
82+
- env:
83+
AWS_REGISTRY : ${{ steps.login-ecr.outputs.registry }}
84+
AWS_REPO : release-orthoinference
85+
IMG_TAG : latest
86+
run: |
87+
docker load --input /tmp/image.tar
88+
docker image tag tmp-tag $AWS_REGISTRY/$AWS_REPO:$IMG_TAG
89+
docker push $AWS_REGISTRY/$AWS_REPO:$IMG_TAG

Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ARG REPO_DIR=/opt/release-orthoinference
2+
3+
4+
# ===== stage 1 =====
5+
FROM maven:3.9.6-eclipse-temurin-11-focal AS setup-env
6+
7+
ARG REPO_DIR
8+
9+
WORKDIR ${REPO_DIR}
10+
11+
COPY . .
12+
13+
SHELL ["/bin/bash", "-c"]
14+
15+
# run lint if container started
16+
ENTRYPOINT []
17+
18+
CMD mvn -B -q checkstyle:check | \
19+
grep -i --color=never '\.java\|failed to execute goal' > lint.log && \
20+
exit 1 || \
21+
exit 0
22+
23+
24+
# ===== stage 2 =====
25+
FROM setup-env AS build-jar
26+
27+
RUN mvn clean compile assembly:single
28+
29+
30+
# ===== stage 3 =====
31+
FROM eclipse-temurin:11-jre-focal
32+
33+
ARG REPO_DIR
34+
35+
ARG JAR_FILE=target/orthoinference-*-jar-with-dependencies.jar
36+
37+
WORKDIR ${REPO_DIR}
38+
39+
COPY --from=build-jar ${REPO_DIR}/${JAR_FILE} ./target/

checkstyle.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE module PUBLIC
2+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
3+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
4+
<module name="Checker">
5+
<module name="LineLength">
6+
<property name="max" value="150"/>
7+
</module>
8+
<!-- Add more modules as needed -->
9+
</module>

pom.xml

+29-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@
103103
<artifactId>maven-compiler-plugin</artifactId>
104104
<version>3.8.1</version>
105105
<configuration>
106-
<source>1.8</source>
107-
<target>1.8</target>
106+
<source>11</source>
107+
<target>11</target>
108108
</configuration>
109109
</plugin>
110110

@@ -173,6 +173,33 @@
173173
</execution>
174174
</executions>
175175
</plugin>
176+
177+
<plugin>
178+
<groupId>org.apache.maven.plugins</groupId>
179+
<artifactId>maven-checkstyle-plugin</artifactId>
180+
<version>3.1.1</version>
181+
<dependencies>
182+
<!-- This dependency allows Checkstyle to understand Java 11 syntax -->
183+
<dependency>
184+
<groupId>com.puppycrawl.tools</groupId>
185+
<artifactId>checkstyle</artifactId>
186+
<version>8.44</version>
187+
</dependency>
188+
</dependencies>
189+
<executions>
190+
<execution>
191+
<id>checkstyle-check</id>
192+
<goals>
193+
<goal>check</goal>
194+
</goals>
195+
</execution>
196+
</executions>
197+
<configuration>
198+
<configLocation>checkstyle.xml</configLocation>
199+
<!-- Optional: Set encoding -->
200+
<encoding>UTF-8</encoding>
201+
</configuration>
202+
</plugin>
176203
</plugins>
177204
</build>
178205
</project>

0 commit comments

Comments
 (0)