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

Add microservice workflows #2607

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
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
38 changes: 38 additions & 0 deletions .github/workflows/microservice-build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
name: Create and publish a Docker image

on:
workflow_call:

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository.lowercase }}
JAVA_VERSION: '11'
JAVA_DISTRIBUTION: 'zulu' #This is the default on v1 of the action for 1.8
USER_NAME: ${{ github.actor }}
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-and-push-datawave-images:
runs-on: ubuntu-latest
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USER_NAME }}
password: ${{ env.ACCESS_TOKEN }}
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK ${{env.JAVA_VERSION}}
uses: actions/setup-java@v4
with:
distribution: ${{env.JAVA_DISTRIBUTION}}
java-version: ${{env.JAVA_VERSION}}
cache: 'maven'
- name: Build And Push Docker Image (Maven)
run: |
mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e clean install -Pdocker,exec -Ddocker.image.prefix=ghcr.io/nationalsecurityagency/ -DpushImage


60 changes: 60 additions & 0 deletions .github/workflows/microservice-maven-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Tests

on:
workflow_call:

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@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
- uses: actions/cache@v4
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@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
- uses: actions/cache@v4
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 }}

Loading