Skip to content

Commit

Permalink
Java PR workflow improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Kinard <jeff@thekinards.com>
  • Loading branch information
Polber committed May 6, 2024
1 parent 81d83cb commit 4abf76c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 100 deletions.
37 changes: 37 additions & 0 deletions .github/actions/upload-test-report/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Cleans up the Java environment. This is mostly intended to help keep the
# Java cache a bit smaller by removing unnecessary dependencies or stuff that
# we will always rebuild anyways.

name: 'Publish Test Report'
description: 'Publish test report'

inputs:
output-zip-file:
description: 'Output zip file name'
type: string
required: true

runs:
using: 'composite'
steps:
- name: Upload Test Report
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v3.1.2
with:
name: ${{ inputs.output-zip-file }}
path: '**/surefire-reports/TEST-*.xml'
retention-days: 1
if-no-files-found: ignore
15 changes: 8 additions & 7 deletions .github/workflows/java-pr-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ on:
workflow_run:
workflows:
- Java PR
- Release
types: [ completed ]

permissions:
Expand All @@ -29,15 +28,17 @@ jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Download Test Report
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
- name: Checkout Code
uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
with:
fetch-depth: 2 # setup-env action assumes fetch depth of at least 2 for https://github.com/tj-actions/changed-files?tab=readme-ov-file#on-push-%EF%B8%8F
- name: Download Test Reports
uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d # v3.0.0
with:
name: surefire-test-results
workflow: ${{ github.event.workflow.id }}
run_id: ${{ github.event.workflow_run.id }}
if_no_artifact_found: warn
if_no_artifact_found: ignore
- name: Publish Test Report
uses: mikepenz/action-junit-report@150e2f992e4fad1379da2056d1d1c279f520e058 # v3.8.0
uses: mikepenz/action-junit-report@9379f0ccddcab154835d4e2487555ee79614fe95 # v4.2.1
with:
commit: ${{github.event.workflow_run.head_sha}}
report_paths: '**/surefire-reports/TEST-*.xml'
135 changes: 42 additions & 93 deletions .github/workflows/java-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ on:
- '**.xml'
# Include relevant GitHub Action files for running these checks.
# This will make it easier to verify action changes don't break anything.
- '.github/actions/setup-env/*'
- '.github/actions/*'
- '.github/workflows/java-pr.yml'
schedule:
- cron: "0 */12 * * *"
- '.github/codecov.yml'
- 'cicd'
workflow_dispatch:

env:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.shade=error

permissions: read-all
permissions:
contents: read
checks: write
id-token: write

jobs:
spotless_check:
Expand All @@ -43,7 +46,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
with:
fetch-depth: 2 # setup-env action assumes fetch depth of at least 2 for https://github.com/tj-actions/changed-files?tab=readme-ov-file#on-push-%EF%B8%8F
- name: Setup Environment
Expand All @@ -57,7 +60,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
with:
fetch-depth: 2 # setup-env action assumes fetch depth of at least 2 for https://github.com/tj-actions/changed-files?tab=readme-ov-file#on-push-%EF%B8%8F
- name: Setup Environment
Expand All @@ -67,134 +70,80 @@ jobs:
run: ./cicd/run-checkstyle --changed-files="${{ steps.setup-env.outputs.changed-files }}"
java_build:
name: Build
needs: [spotless_check, checkstyle_check]
timeout-minutes: 60
runs-on: [self-hosted, it]
steps:
- name: Checkout Code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
with:
fetch-depth: 2 # setup-env action assumes fetch depth of at least 2 for https://github.com/tj-actions/changed-files?tab=readme-ov-file#on-push-%EF%B8%8F
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Build
run: ./cicd/run-build --changed-files="${{ steps.setup-env.outputs.changed-files }}"
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
- name: Run Java Build
uses: ./.github/actions/run-build
with:
changed-files: ${{ steps.setup-env.outputs.changed-files }}
java_unit_tests:
name: Unit Tests
needs: [java_build]
timeout-minutes: 60
runs-on: [self-hosted, it]
steps:
- name: Checkout Code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
with:
fetch-depth: 2 # setup-env action assumes fetch depth of at least 2 for https://github.com/tj-actions/changed-files?tab=readme-ov-file#on-push-%EF%B8%8F
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Unit Tests
run: ./cicd/run-unit-tests --changed-files="${{ steps.setup-env.outputs.changed-files }}"
- name: Upload Unit Tests Report
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: always() # always run even if the previous step fails
uses: ./.github/actions/run-unit-tests
with:
changed-files: ${{ steps.setup-env.outputs.changed-files }}
- name: Upload Unit Tests Surefire Report
uses: ./.github/actions/upload-test-report
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
retention-days: 1
output-zip-file: unit-test-results
if: always()
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: GoogleCloudPlatform/DataflowTemplates
files: 'target/site/jacoco-aggregate/jacoco.xml'
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
java_integration_smoke_tests_templates:
name: Dataflow Templates Integration Smoke Tests
needs: [spotless_check, checkstyle_check, java_build, java_unit_tests]
needs: [java_build]
timeout-minutes: 60
# Run on any runner that matches all the specified runs-on values.
runs-on: [self-hosted, it]
steps:
- name: Checkout Code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
with:
fetch-depth: 2 # setup-env action assumes fetch depth of at least 2 for https://github.com/tj-actions/changed-files?tab=readme-ov-file#on-push-%EF%B8%8F
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Integration Smoke Tests
run: |
./cicd/run-it-smoke-tests \
--changed-files="${{ steps.setup-env.outputs.changed-files }}" \
--it-region="us-central1" \
--it-project="cloud-teleport-testing" \
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
--it-private-connectivity="datastream-private-connect-us-central1"
- name: Upload Smoke Tests Report
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: always() # always run even if the previous step fails
- name: Run Smoke Tests
uses: ./.github/actions/run-smoke-tests
with:
changed-files: ${{ steps.setup-env.outputs.changed-files }}
- name: Upload Smoke Tests Surefire Report
uses: ./.github/actions/upload-test-report
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
retention-days: 1
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
output-zip-file: smoke-test-results
if: always()
java_integration_tests_templates:
name: Dataflow Templates Integration Tests
needs: [java_integration_smoke_tests_templates]
needs: [java_build]
timeout-minutes: 180
# Run on any runner that matches all the specified runs-on values.
runs-on: [self-hosted, it]
steps:
- name: Checkout Code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
with:
fetch-depth: 2 # setup-env action assumes fetch depth of at least 2 for https://github.com/tj-actions/changed-files?tab=readme-ov-file#on-push-%EF%B8%8F
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Integration Tests
run: |
./cicd/run-it-tests \
--changed-files="${{ steps.setup-env.outputs.changed-files }}" \
--it-region="us-central1" \
--it-project="cloud-teleport-testing" \
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
--it-private-connectivity="datastream-private-connect-us-central1"
- name: Upload Integration Tests Report
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: always() # always run even if the previous step fails
uses: ./.github/actions/run-integration-tests
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
retention-days: 1
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
java_load_tests_templates:
if: contains(github.event.pull_request.labels.*.name, 'run-load-tests')
name: Dataflow Templates Load Tests
needs: [spotless_check, checkstyle_check, java_build, java_unit_tests, java_integration_tests_templates]
timeout-minutes: 600
# Run on any runner that matches all the specified runs-on values.
runs-on: [self-hosted, perf]
steps:
- name: Checkout Code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
with:
fetch-depth: 2 # setup-env action assumes fetch depth of at least 2 for https://github.com/tj-actions/changed-files?tab=readme-ov-file#on-push-%EF%B8%8F
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Load Tests
run: |
./cicd/run-load-tests \
--changed-files="${{ steps.setup-env.outputs.changed-files }}" \
--it-region="us-central1" \
--it-project="cloud-teleport-testing" \
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
--it-private-connectivity="datastream-private-connect-us-central1"
- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
changed-files: ${{ steps.setup-env.outputs.changed-files }}
- name: Upload Integration Tests Surefire Report
uses: ./.github/actions/upload-test-report
with:
output-zip-file: integration-test-results
if: always()

0 comments on commit 4abf76c

Please sign in to comment.