Skip to content

Commit

Permalink
DRY out the workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnybot0 committed Dec 5, 2024
1 parent 1a1b892 commit 09db827
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 325 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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
#
# http://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.

name: Common Workflow

on:
workflow_call:
inputs:
gradle_task:
description: 'Gradle task to run'
required: true
type: string
container_image:
description: 'Docker container image'
required: true
type: string

jobs:
common:
runs-on: ubuntu-latest
container:
image: ${{ inputs.container_image }}
env:
GRADLE_OPTS: -Xmx1024m -XX:MaxMetaspaceSize=256m
GRADLE_USER_HOME: .gradle-home
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Restore Gradle cache
uses: actions/cache@v4
with:
path: .gradle-home
key: gradle-home-${{ inputs.gradle_task }}-${{ github.ref }}
restore-keys: |
gradle-home-${{ inputs.gradle_task }}-${{ github.ref }}
gradle-home-${{ inputs.gradle_task }}-master
gradle-home-${{ inputs.gradle_task }}
- name: Run Gradle tasks
run: ./gradlew --no-daemon --max-workers 4 --parallel -Pci ${{ inputs.gradle_task }}

- name: Copy all test results to a directory
run: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \;
- name: Store test results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: ~/test-results/

- name: Store build reports
uses: actions/upload-artifact@v4
with:
name: build-reports
path: build/reports

- name: Save Gradle cache
uses: actions/cache@v4
with:
path: .gradle-home
key: gradle-home-${{ inputs.gradle_task }}-${{ github.ref }}-${{ github.run_id }}
Loading

0 comments on commit 09db827

Please sign in to comment.