-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (83 loc) · 3.87 KB
/
tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Tests
on:
push:
paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE']
branches:
- 'main'
- 'release/*'
pull_request:
paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE']
jobs:
# Runs the pom sorter and code formatter to ensure that the code
# is formatted and poms are sorted according to project rules. This
# will fail if the formatter makes any changes.
check-code-formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-format-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-format-
${{ runner.os }}-maven-
- name: Format code
run: |
mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e clean formatter:format sortpom:sort -Pautoformat
git status
git diff-index --quiet HEAD || (echo "Error! There are modified files after formatting." && false)
env:
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Djava.awt.headless=true"
USER_NAME: ${{ secrets.USER_NAME }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# Build the code and run the unit/integration tests.
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-build-
${{ runner.os }}-maven-format-
${{ runner.os }}-maven-
- name: Build and Run Unit Tests
run: mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -Ddist clean verify
env:
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Djava.awt.headless=true"
USER_NAME: ${{ secrets.USER_NAME }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# Here's an example of how you'd deploy the image to the github package registry.
# We don't want to do this by default since packages on github cannot be deleted
# or overwritten. So this could only be done for tags, however it seems the quickstart
# image may also exceed the maximum size allowed by github.
# - name: Image
# env:
# IMAGE_REGISTRY: "docker.pkg.github.com"
# IMAGE_USERNAME: "NationalSecurityAgency"
# USER_NAME: ${{ secrets.USER_NAME }}
# ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# run: |
# # Set up env vars
# IMAGE_NAME=$(mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${project.version}' exec:exec)
# IMAGE_PREFIX=$(mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${docker.image.prefix}' exec:exec)
# IMAGE_TAG=$(mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec)
# REMOTE_IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_USERNAME}/${IMAGE_PREFIX}${IMAGE_NAME}"
# # Log in to the package registry
# echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com --username ${GITHUB_ACTOR} --password-stdin
# # Tag and push the image
# docker tag ${IMAGE_PREFIX}${IMAGE_NAME}:${IMAGE_TAG} ${REMOTE_IMAGE_NAME}:${IMAGE_TAG}
# docker push ${REMOTE_IMAGE_NAME}:${IMAGE_TAG}