|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +name: "Worker" |
| 17 | + |
| 18 | +on: |
| 19 | + workflow_call: |
| 20 | + inputs: |
| 21 | + jdk: |
| 22 | + required: false |
| 23 | + type: string |
| 24 | + default: '17' |
| 25 | + script: |
| 26 | + required: true |
| 27 | + type: string |
| 28 | + description: "Script to execute" |
| 29 | + key: |
| 30 | + required: false |
| 31 | + type: string |
| 32 | + description: "Identifier for job" |
| 33 | + artifact_prefix: |
| 34 | + required: false |
| 35 | + type: string |
| 36 | + description: "Prefix for the artifact name" |
| 37 | + artifacts_to_download: |
| 38 | + required: false |
| 39 | + type: string |
| 40 | + description: "Artifacts to download. For example: 'unit-test-reports-*'" |
| 41 | + |
| 42 | +env: |
| 43 | + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5 |
| 44 | + |
| 45 | +jobs: |
| 46 | + execute: |
| 47 | + name: "${{ inputs.key }}" |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - name: Checkout repository |
| 51 | + uses: actions/checkout@v4 |
| 52 | + with: |
| 53 | + fetch-depth: 500 |
| 54 | + |
| 55 | + - uses: actions/setup-java@v4 |
| 56 | + with: |
| 57 | + distribution: 'zulu' |
| 58 | + java-version: ${{ inputs.jdk }} |
| 59 | + cache: 'maven' |
| 60 | + |
| 61 | + - name: Download required artifacts |
| 62 | + if: ${{ inputs.artifacts_to_download != '' }} |
| 63 | + uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + pattern: ${{ inputs.artifacts_to_download }} |
| 66 | + merge-multiple: true |
| 67 | + |
| 68 | + - name: Calculate hash for artifact name |
| 69 | + run: echo "HASH=$(echo -n "${{ inputs.key }}" | sha256sum | cut -c-8)" >> $GITHUB_ENV |
| 70 | + |
| 71 | + - name: 'Execute: ${{ inputs.script }}' |
| 72 | + run: ${{ inputs.script }} |
| 73 | + |
| 74 | + - name: Upload artifact |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + if: ${{ failure() || inputs.artifact_prefix != '' }} |
| 77 | + with: |
| 78 | + name: "${{ inputs.artifact_prefix }}-${{ env.HASH }}" |
| 79 | + path: | |
| 80 | + **/*.hprof |
| 81 | + **/hs_err_pid* |
| 82 | + **/replay_pid* |
| 83 | + **/core.[0-9]* |
| 84 | + **/TEST-*.xml |
| 85 | + **/target/jacoco*.exec |
0 commit comments