Skip to content

Commit c187b61

Browse files
author
Joel Weiser
committed
2 parents 24fffb4 + cea6282 commit c187b61

File tree

5 files changed

+185
-3
lines changed

5 files changed

+185
-3
lines changed

.dockerignore

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

.github/workflows/ci.yml

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

Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ARG REPO_DIR=/opt/release-update-dois
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/update-dois-*-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

+37-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<dependency>
5353
<groupId>org.reactome.release</groupId>
5454
<artifactId>release-common-lib</artifactId>
55-
<version>1.2.0</version>
55+
<version>2.0.0-SNAPSHOT</version>
5656
</dependency>
5757

5858
<!-- Test dependencies -->
@@ -76,6 +76,13 @@
7676
</dependency>
7777
</dependencies>
7878

79+
<repositories>
80+
<repository>
81+
<id>ossrh</id>
82+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
83+
</repository>
84+
</repositories>
85+
7986
<build>
8087
<plugins>
8188
<!-- sets the Java compiler version targeted by Maven -->
@@ -84,8 +91,8 @@
8491
<artifactId>maven-compiler-plugin</artifactId>
8592
<version>3.8.1</version>
8693
<configuration>
87-
<source>1.8</source>
88-
<target>1.8</target>
94+
<source>11</source>
95+
<target>11</target>
8996
</configuration>
9097
</plugin>
9198

@@ -176,6 +183,33 @@
176183
</execution>
177184
</executions>
178185
</plugin>
186+
187+
<plugin>
188+
<groupId>org.apache.maven.plugins</groupId>
189+
<artifactId>maven-checkstyle-plugin</artifactId>
190+
<version>3.1.1</version>
191+
<dependencies>
192+
<!-- This dependency allows Checkstyle to understand Java 11 syntax -->
193+
<dependency>
194+
<groupId>com.puppycrawl.tools</groupId>
195+
<artifactId>checkstyle</artifactId>
196+
<version>8.44</version>
197+
</dependency>
198+
</dependencies>
199+
<executions>
200+
<execution>
201+
<id>checkstyle-check</id>
202+
<goals>
203+
<goal>check</goal>
204+
</goals>
205+
</execution>
206+
</executions>
207+
<configuration>
208+
<configLocation>checkstyle.xml</configLocation>
209+
<!-- Optional: Set encoding -->
210+
<encoding>UTF-8</encoding>
211+
</configuration>
212+
</plugin>
179213
</plugins>
180214
</build>
181215
</project>

0 commit comments

Comments
 (0)