From 0d511f7a771c24acc2400a0b83c225eb16afe47d Mon Sep 17 00:00:00 2001 From: Yih-Dar <2521628+ydshieh@users.noreply.github.com> Date: Mon, 4 Aug 2025 10:24:45 +0200 Subject: [PATCH] Use comment to build doc on PRs (#39846) * try * try * try * try * try --------- Co-authored-by: ydshieh --- .../workflows/pr_build_doc_with_comment.yml | 58 +++++++++++++++++++ .github/workflows/pr_run_slow_ci.yml | 22 ------- 2 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/pr_build_doc_with_comment.yml diff --git a/.github/workflows/pr_build_doc_with_comment.yml b/.github/workflows/pr_build_doc_with_comment.yml new file mode 100644 index 0000000000..e3baca7c45 --- /dev/null +++ b/.github/workflows/pr_build_doc_with_comment.yml @@ -0,0 +1,58 @@ +name: PR - build doc via comment +on: + issue_comment: + types: + - created + branches-ignore: + - main +concurrency: + group: ${{ github.workflow }}-${{ github.event.issue.number }}-${{ startsWith(github.event.comment.body, 'build-doc') }} + cancel-in-progress: true +permissions: {} + + +jobs: + get-pr-number: + name: Get PR number + if: ${{ github.event.issue.state == 'open' && contains(fromJSON('["ydshieh", "ArthurZucker", "zucchini-nlp", "qubvel", "molbap", "gante", "LysandreJik", "Cyrilvallez", "Rocketknight1", "SunMarc", "muellerzr", "eustlb", "MekkCyber", "manueldeprada", "vasqu", "ivarflakstad", "stevhliu", "ebezzam"]'), github.actor) && (startsWith(github.event.comment.body, 'build-doc')) }} + uses: ./.github/workflows/get-pr-number.yml + + get-pr-info: + name: Get PR commit SHA + needs: get-pr-number + if: ${{ needs.get-pr-number.outputs.PR_NUMBER != ''}} + uses: ./.github/workflows/get-pr-info.yml + with: + pr_number: ${{ needs.get-pr-number.outputs.PR_NUMBER }} + + verity_pr_commit: + name: Verity PR commit corresponds to a specific event by comparing timestamps + if: ${{ needs.get-pr-number.outputs.PR_NUMBER != ''}} + runs-on: ubuntu-22.04 + needs: get-pr-info + env: + COMMENT_DATE: ${{ github.event.comment.created_at }} + PR_MERGE_COMMIT_DATE: ${{ needs.get-pr-info.outputs.PR_MERGE_COMMIT_DATE }} + PR_MERGE_COMMIT_TIMESTAMP: ${{ needs.get-pr-info.outputs.PR_MERGE_COMMIT_TIMESTAMP }} + steps: + - run: | + COMMENT_TIMESTAMP=$(date -d "${COMMENT_DATE}" +"%s") + echo "COMMENT_DATE: $COMMENT_DATE" + echo "PR_MERGE_COMMIT_DATE: $PR_MERGE_COMMIT_DATE" + echo "COMMENT_TIMESTAMP: $COMMENT_TIMESTAMP" + echo "PR_MERGE_COMMIT_TIMESTAMP: $PR_MERGE_COMMIT_TIMESTAMP" + if [ $COMMENT_TIMESTAMP -le $PR_MERGE_COMMIT_TIMESTAMP ]; then + echo "Last commit on the pull request is newer than the issue comment triggering this run! Abort!"; + exit -1; + fi + + build-doc: + name: Build doc + needs: [get-pr-number, get-pr-info] + if: ${{ needs.get-pr-number.outputs.PR_NUMBER != '' }} + uses: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml@main + with: + commit_sha: ${{ needs.get-pr-info.outputs.PR_HEAD_SHA }} + pr_number: ${{ needs.get-pr-number.outputs.PR_NUMBER }} + package: transformers + languages: ar de en es fr hi it ko pt tr zh ja te diff --git a/.github/workflows/pr_run_slow_ci.yml b/.github/workflows/pr_run_slow_ci.yml index 4b93dcd829..9b57c91e82 100644 --- a/.github/workflows/pr_run_slow_ci.yml +++ b/.github/workflows/pr_run_slow_ci.yml @@ -16,28 +16,6 @@ jobs: with: pr_number: ${{ needs.get-pr-number.outputs.PR_NUMBER }} - # We only need to verify the timestamp if the workflow is triggered by `issue_comment`. - verity_pr_commit: - name: Verity PR commit corresponds to a specific event by comparing timestamps - if: ${{ github.event.comment.created_at != '' }} - runs-on: ubuntu-22.04 - needs: get-pr-info - env: - COMMENT_DATE: ${{ github.event.comment.created_at }} - PR_MERGE_COMMIT_DATE: ${{ needs.get-pr-info.outputs.PR_MERGE_COMMIT_DATE }} - PR_MERGE_COMMIT_TIMESTAMP: ${{ needs.get-pr-info.outputs.PR_MERGE_COMMIT_TIMESTAMP }} - steps: - - run: | - COMMENT_TIMESTAMP=$(date -d "${COMMENT_DATE}" +"%s") - echo "COMMENT_DATE: $COMMENT_DATE" - echo "PR_MERGE_COMMIT_DATE: $PR_MERGE_COMMIT_DATE" - echo "COMMENT_TIMESTAMP: $COMMENT_TIMESTAMP" - echo "PR_MERGE_COMMIT_TIMESTAMP: $PR_MERGE_COMMIT_TIMESTAMP" - if [ $COMMENT_TIMESTAMP -le $PR_MERGE_COMMIT_TIMESTAMP ]; then - echo "Last commit on the pull request is newer than the issue comment triggering this run! Abort!"; - exit -1; - fi - get-jobs: name: Get test files to run runs-on: ubuntu-22.04