|
| 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 | +# Apache Yetus test-patch: pre-commit patch testing (Ant, JDK 17). |
| 17 | +# Runs alongside master-build.yml; all CI is unified on Java 17. |
| 18 | +# See https://yetus.apache.org/documentation/0.15.1/precommit/ |
| 19 | +--- |
| 20 | +name: Apache Yetus |
| 21 | +on: |
| 22 | + push: |
| 23 | + branches: [master] |
| 24 | + pull_request: |
| 25 | + types: [opened, synchronize, reopened] |
| 26 | + branches: [master] |
| 27 | + |
| 28 | +concurrency: |
| 29 | + group: yetus-${{ github.ref }} |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +# GITHUB_TOKEN cannot comment on PRs from forks (403). Use a PAT secret |
| 33 | +# (e.g. YETUS_COMMENT_TOKEN) if you need comments on fork PRs. |
| 34 | +permissions: |
| 35 | + contents: read |
| 36 | + statuses: write |
| 37 | + pull-requests: write |
| 38 | + issues: write |
| 39 | + |
| 40 | +jobs: |
| 41 | + yetus: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + timeout-minutes: 45 |
| 44 | + env: |
| 45 | + PATCH_DIR: ${{ github.workspace }}/out |
| 46 | + JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64 |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v5 |
| 49 | + with: |
| 50 | + fetch-depth: 0 |
| 51 | + - name: Cache Ivy dependencies |
| 52 | + uses: actions/cache@v4 |
| 53 | + with: |
| 54 | + path: ~/.ivy2/cache |
| 55 | + key: ${{ runner.os }}-ivy-${{ hashFiles('ivy/ivy.xml', 'src/plugin/**/ivy.xml') }} |
| 56 | + restore-keys: | |
| 57 | + ${{ runner.os }}-ivy- |
| 58 | + - name: Apache Yetus test-patch |
| 59 | + uses: apache/yetus-test-patch-action@0.15.1 |
| 60 | + with: |
| 61 | + basedir: . |
| 62 | + buildtool: nobuild |
| 63 | + githubtoken: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + javahome: '/usr/lib/jvm/java-17-openjdk-amd64' |
| 65 | + patchdir: /github/workspace/out |
| 66 | + plugins: all,-jira,-gitlab,-unit,-compile |
| 67 | + project: nutch |
| 68 | + - name: Artifact output |
| 69 | + if: always() |
| 70 | + uses: actions/upload-artifact@v4 |
| 71 | + with: |
| 72 | + name: apacheyetuspatchdir |
| 73 | + path: ${{ env.PATCH_DIR }} |
| 74 | + - name: Install pandoc |
| 75 | + if: github.event_name == 'pull_request' |
| 76 | + run: sudo apt-get update && sudo apt-get install -y pandoc |
| 77 | + - name: Convert HTML report to Markdown |
| 78 | + if: github.event_name == 'pull_request' |
| 79 | + run: | |
| 80 | + OUT="${{ env.PATCH_DIR }}" |
| 81 | + echo "## Apache Yetus test-patch report" > yetus-report.md |
| 82 | + echo "" >> yetus-report.md |
| 83 | + if [ -f "$OUT/report.html" ]; then |
| 84 | + pandoc "$OUT/report.html" -f html -t gfm >> yetus-report.md 2>/dev/null || { |
| 85 | + echo "Pandoc conversion failed; using brief report." >> yetus-report.md |
| 86 | + echo '```' >> yetus-report.md |
| 87 | + cat "$OUT/brief.txt" >> yetus-report.md 2>/dev/null || true |
| 88 | + echo '```' >> yetus-report.md |
| 89 | + } |
| 90 | + elif [ -f "$OUT/brief.txt" ]; then |
| 91 | + echo '```' >> yetus-report.md |
| 92 | + cat "$OUT/brief.txt" >> yetus-report.md |
| 93 | + echo '```' >> yetus-report.md |
| 94 | + else |
| 95 | + echo "No Yetus report or brief found." >> yetus-report.md |
| 96 | + fi |
| 97 | + - name: Truncate if over comment limit |
| 98 | + if: github.event_name == 'pull_request' |
| 99 | + run: | |
| 100 | + MAX=60000 |
| 101 | + if [ $(wc -c < yetus-report.md) -gt $MAX ]; then |
| 102 | + head -c $MAX yetus-report.md > yetus-report-trimmed.md |
| 103 | + echo "" >> yetus-report-trimmed.md |
| 104 | + echo "" >> yetus-report-trimmed.md |
| 105 | + echo "_Report truncated (GitHub comment limit). Full HTML in apacheyetuspatchdir artifact as report.html._" >> yetus-report-trimmed.md |
| 106 | + mv yetus-report-trimmed.md yetus-report.md |
| 107 | + fi |
| 108 | + - name: Comment PR with Yetus report |
| 109 | + if: github.event_name == 'pull_request' |
| 110 | + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 |
| 111 | + continue-on-error: true |
| 112 | + with: |
| 113 | + token: ${{ secrets.YETUS_COMMENT_TOKEN || secrets.GITHUB_TOKEN }} |
| 114 | + repository: ${{ github.repository }} |
| 115 | + issue-number: ${{ github.event.pull_request.number }} |
| 116 | + body-path: yetus-report.md |
0 commit comments