Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update action #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 30 additions & 62 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,47 @@ on:
push:
paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE']
branches:
- 'main'
- 'release/*'
- 'main'
- 'release/*'
pull_request:
paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE']

env:
JAVA_VERSION: '11'
JAVA_DISTRIBUTION: 'zulu' #This is the default on v1 of the action
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Djava.awt.headless=true"

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 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- 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 -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"

- name: Checkout Code
uses: actions/checkout@v3
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: 'maven'
- name: Format code
run: |
mvn -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)
# 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 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- 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 -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"

# 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"
# run: |
# # Set up env vars
# IMAGE_NAME=$(mvn -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${project.version}' exec:exec)
# IMAGE_PREFIX=$(mvn -q -N -Pdocker -f service/pom.xml -Dexec.executable='echo' -Dexec.args='${docker.image.prefix}' exec:exec)
# IMAGE_TAG=$(mvn -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}

- name: Checkout Code
uses: actions/checkout@v3
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: 'maven'
- name: Build and Run Unit Tests
run: mvn -V -B -e -Ddist clean verify