blob: 58ba23c583a492c3554f9c2d02b72d1af0925e0d [file]
# 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.
#
# Apache Yetus test-patch: pre-commit patch testing (apache/yetus-test-patch-action).
# The action runs inside ghcr.io/apache/yetus:0.15.1 — javahome must be a JDK path
# inside that image (OpenJDK 11 on amd64), not actions/setup-java on the runner.
# See https://yetus.apache.org/documentation/0.15.1/precommit/
---
name: Apache Yetus
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, reopened]
branches: [master]
concurrency:
group: yetus-${{ github.ref }}
cancel-in-progress: true
# GITHUB_TOKEN cannot comment on PRs from forks (403). Use a PAT secret
# (e.g. YETUS_COMMENT_TOKEN) if you need comments on fork PRs.
permissions:
contents: read
statuses: write
pull-requests: write
issues: write
jobs:
yetus:
runs-on: ubuntu-latest
timeout-minutes: 45
env:
PATCH_DIR: ${{ github.workspace }}/out
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Cache Ivy dependencies
uses: actions/cache@v4
with:
path: ~/.ivy2/cache
key: ${{ runner.os }}-ivy-${{ hashFiles('ivy/ivy.xml', 'src/plugin/**/ivy.xml') }}
restore-keys: |
${{ runner.os }}-ivy-
- name: Apache Yetus test-patch
uses: apache/yetus-test-patch-action@0.15.1
with:
basedir: .
buildtool: nobuild
githubtoken: ${{ secrets.GITHUB_TOKEN }}
javahome: /usr/lib/jvm/java-11-openjdk-amd64
patchdir: /github/workspace/out
plugins: all,-jira,-gitlab,-unit,-compile
project: nutch
- name: Artifact output
if: always()
uses: actions/upload-artifact@v4
with:
name: apacheyetuspatchdir
path: ${{ env.PATCH_DIR }}
- name: Install pandoc
if: github.event_name == 'pull_request'
run: sudo apt-get update && sudo apt-get install -y pandoc
- name: Convert HTML report to Markdown
if: github.event_name == 'pull_request'
run: |
OUT="${{ env.PATCH_DIR }}"
echo "## Apache Yetus test-patch report" > yetus-report.md
echo "" >> yetus-report.md
if [ -f "$OUT/report.html" ]; then
pandoc "$OUT/report.html" -f html -t gfm >> yetus-report.md 2>/dev/null || {
echo "Pandoc conversion failed; using brief report." >> yetus-report.md
echo '```' >> yetus-report.md
cat "$OUT/brief.txt" >> yetus-report.md 2>/dev/null || true
echo '```' >> yetus-report.md
}
elif [ -f "$OUT/brief.txt" ]; then
echo '```' >> yetus-report.md
cat "$OUT/brief.txt" >> yetus-report.md
echo '```' >> yetus-report.md
else
echo "No Yetus report or brief found." >> yetus-report.md
fi
- name: Truncate if over comment limit
if: github.event_name == 'pull_request'
run: |
MAX=60000
if [ $(wc -c < yetus-report.md) -gt $MAX ]; then
head -c $MAX yetus-report.md > yetus-report-trimmed.md
echo "" >> yetus-report-trimmed.md
echo "" >> yetus-report-trimmed.md
echo "_Report truncated (GitHub comment limit). Full HTML in apacheyetuspatchdir artifact as report.html._" >> yetus-report-trimmed.md
mv yetus-report-trimmed.md yetus-report.md
fi
- name: Comment PR with Yetus report
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9
continue-on-error: true
with:
token: ${{ secrets.YETUS_COMMENT_TOKEN || secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
issue-number: ${{ github.event.pull_request.number }}
body-path: yetus-report.md