From 97ad793d6874a7c767b7b9d4df7e7ed566442465 Mon Sep 17 00:00:00 2001 From: Adam Lerman Date: Mon, 21 Oct 2024 18:07:40 +0000 Subject: [PATCH 1/2] Updating workflows to use reusable --- .github/workflows/build-images.yml | 15 ++++++ .github/workflows/tests.yaml | 80 ++---------------------------- 2 files changed, 18 insertions(+), 77 deletions(-) create mode 100644 .github/workflows/build-images.yml diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml new file mode 100644 index 0000000..92175ea --- /dev/null +++ b/.github/workflows/build-images.yml @@ -0,0 +1,15 @@ +name: Build and Push Image + +on: + push: + paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE'] + tags: + - "**" + branches: + - 'integration' + - 'release/version*' + - 'docker-images' + workflow_dispatch: +jobs: + call-reusable-workflow: + uses: nationalsecurityagency/datawave/.github/workflows/microservice-build-image.yaml@integration diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 284ca14..5f30ec7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,4 +1,4 @@ -name: Tests +name: Run Maven Tests on: push: @@ -10,79 +10,5 @@ on: 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} - + call-reusable-workflow: + uses: nationalsecurityagency/datawave/.github/workflows/microservice-maven-tests.yaml@integration \ No newline at end of file From 6053f146335380e389de1573b2b5c1227b032cc3 Mon Sep 17 00:00:00 2001 From: Adam Lerman Date: Mon, 21 Oct 2024 18:17:21 +0000 Subject: [PATCH 2/2] Updating workflows to use reusable --- .github/workflows/build-images.yml | 5 ++++- .github/workflows/tests.yaml | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 92175ea..32ebdb4 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -6,10 +6,13 @@ on: tags: - "**" branches: - - 'integration' + - 'main' - 'release/version*' - 'docker-images' workflow_dispatch: jobs: call-reusable-workflow: uses: nationalsecurityagency/datawave/.github/workflows/microservice-build-image.yaml@integration + secrets: + USER_NAME: ${{ secrets.USER_NAME }} + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5f30ec7..d714b4d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,14 +1,17 @@ -name: Run Maven Tests +name: Tests on: push: paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE'] branches: - - 'main' - - 'release/*' + - 'main' + - 'release/*' pull_request: paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE'] jobs: call-reusable-workflow: - uses: nationalsecurityagency/datawave/.github/workflows/microservice-maven-tests.yaml@integration \ No newline at end of file + uses: nationalsecurityagency/datawave/.github/workflows/microservice-maven-tests.yaml@integration + secrets: + USER_NAME: ${{ secrets.USER_NAME }} + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} \ No newline at end of file