@@ -617,14 +617,11 @@ runs:
617617 MODEL : ${{ inputs.model }}
618618 AGENT_MODEL_INPUT : ${{ inputs.agent_model }}
619619 PARSING_MODEL_INPUT : ${{ inputs.parsing_model }}
620+ # A setup PR's run goes on to preview other pull requests; the credentials stay until
621+ # those finish and the step after them removes them.
622+ KEEP_AUTH : ${{ github.event_name == 'pull_request' && github.head_ref == 'codeboarding/setup-action' }}
620623 run : ' "$GITHUB_ACTION_PATH/scripts/action/with-auth.sh" "$GITHUB_ACTION_PATH/scripts/action/review-analyze-head.sh"'
621624
622- # The head step removes the credentials; this covers a run that failed before it.
623- - name : Remove analysis credentials
624- if : always() && steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
625- shell : bash
626- run : ' "$GITHUB_ACTION_PATH/scripts/action/clear-auth.sh"'
627-
628625 # Published before the review is rendered: the analysis is the expensive part,
629626 # so a later rendering or posting failure must not throw it away. Only the
630627 # next run reads this, hence the short retention.
@@ -730,6 +727,160 @@ runs:
730727 GITHUB_TOKEN : ${{ inputs.github_token }}
731728 path : ${{ steps.review_body.outputs.path }}
732729
730+ # Before a setup PR merges, its own run is the only one GitHub starts for us, so this is
731+ # where a new user's open pull requests get their first review: the ones the app listed
732+ # in the setup PR's description, each applied to the commit this run just analysed and
733+ # analysed incrementally from it (see review-preview-pr.sh). Nothing is posted on them.
734+ # The app finds each as codeboarding-preview-<run>-<attempt>-pr<number>-<head sha>.
735+ # Not codeboarding-review-<run>-...: the app takes the newest artifact with that prefix as
736+ # the setup PR's own review, so a preview named that way would replace the setup PR's map.
737+ # All best effort: the setup PR's map is already uploaded and must not fail because of them.
738+ - name : Resolve pull requests to preview
739+ id : preview_list
740+ if : steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.review_comment.outcome == 'success' && github.event_name == 'pull_request' && github.head_ref == 'codeboarding/setup-action'
741+ continue-on-error : true
742+ shell : bash
743+ env :
744+ GH_TOKEN : ${{ inputs.github_token }}
745+ GH_HOST : ${{ github.server_url }}
746+ REPOSITORY : ${{ github.repository }}
747+ PR_NUMBER : ${{ steps.guard.outputs.pr_number }}
748+ HEAD_REF : ${{ github.head_ref }}
749+ BASE_REF : ${{ steps.guard.outputs.base_ref }}
750+ MAX_PREVIEWS : ' 3'
751+ run : " $GITHUB_ACTION_PATH/scripts/action/resolve-preview-prs.sh"
752+
753+ - name : Preview pull request 1 for the setup PR
754+ id : preview_1
755+ if : steps.guard.outputs.mode == 'review' && steps.preview_list.outputs.count >= 1
756+ continue-on-error : true
757+ shell : bash
758+ env :
759+ ACTION_PATH : ${{ github.action_path }}
760+ CHECKOUT_DIR : ${{ github.workspace }}/.codeboarding-target
761+ GIT_TOKEN : ${{ inputs.github_token }}
762+ REPOSITORY : ${{ github.repository }}
763+ SETUP_PR : ${{ steps.guard.outputs.pr_number }}
764+ REVIEW_BASE_SHA : ${{ steps.guard.outputs.merge_base_sha }}
765+ BASE_ANALYSIS_PATH : ${{ steps.review_baseline.outputs.base_analysis_path }}
766+ # The setup PR's own review artifact already records where the base graph lives.
767+ REVIEW_ARTIFACT_DIR : ${{ steps.review_artifact.outputs.artifact_dir }}
768+ ENGINE_VERSION : ${{ steps.state.outputs.engine_version }}
769+ CFG_HASH : ${{ steps.state.outputs.cfg_hash }}
770+ DEPTH_CAP : ${{ inputs.depth_cap }}
771+ MODEL : ${{ inputs.model }}
772+ AGENT_MODEL_INPUT : ${{ inputs.agent_model }}
773+ PARSING_MODEL_INPUT : ${{ inputs.parsing_model }}
774+ KEEP_AUTH : ' true'
775+ run : ' "$GITHUB_ACTION_PATH/scripts/action/with-auth.sh" "$GITHUB_ACTION_PATH/scripts/action/review-preview-pr.sh" 1'
776+
777+ - name : Upload preview 1
778+ id : upload_preview_1
779+ if : steps.preview_1.outputs.artifact_dir != '' && github.server_url == 'https://github.com'
780+ continue-on-error : true
781+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
782+ with :
783+ name : codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_1.outputs.pr_number }}-${{ steps.preview_1.outputs.head_sha }}
784+ path : ${{ steps.preview_1.outputs.artifact_dir }}
785+ if-no-files-found : error
786+ retention-days : 14
787+
788+ # The sticky review comment is an edit by now, and edits send no notification. One new
789+ # comment on a setup PR emails its author: after the first preview when there is one,
790+ # so the email links a coloured pull request, otherwise as soon as the map is posted.
791+ - name : Tell the setup PR's author the map is ready
792+ if : steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.review_comment.outcome == 'success' && github.event_name == 'pull_request' && github.head_ref == 'codeboarding/setup-action'
793+ continue-on-error : true
794+ shell : bash
795+ env :
796+ GH_TOKEN : ${{ inputs.github_token }}
797+ GH_HOST : ${{ github.server_url }}
798+ REPOSITORY : ${{ github.repository }}
799+ PR_NUMBER : ${{ steps.guard.outputs.pr_number }}
800+ PR_AUTHOR : ${{ github.event.pull_request.user.login }}
801+ HEAD_REF : ${{ github.head_ref }}
802+ BASE_REF : ${{ steps.guard.outputs.base_ref }}
803+ FIRST_PR : ${{ steps.upload_preview_1.outcome == 'success' && steps.preview_1.outputs.pr_number || '' }}
804+ FIRST_TITLE : ${{ steps.preview_1.outputs.title }}
805+ PREVIEW_PRS : ${{ steps.preview_list.outputs.prs }}
806+ run : " $GITHUB_ACTION_PATH/scripts/action/notify-setup-ready.sh"
807+
808+ - name : Preview pull request 2 for the setup PR
809+ id : preview_2
810+ if : steps.guard.outputs.mode == 'review' && steps.preview_list.outputs.count >= 2
811+ continue-on-error : true
812+ shell : bash
813+ env :
814+ ACTION_PATH : ${{ github.action_path }}
815+ CHECKOUT_DIR : ${{ github.workspace }}/.codeboarding-target
816+ GIT_TOKEN : ${{ inputs.github_token }}
817+ REPOSITORY : ${{ github.repository }}
818+ SETUP_PR : ${{ steps.guard.outputs.pr_number }}
819+ REVIEW_BASE_SHA : ${{ steps.guard.outputs.merge_base_sha }}
820+ BASE_ANALYSIS_PATH : ${{ steps.review_baseline.outputs.base_analysis_path }}
821+ # The setup PR's own review artifact already records where the base graph lives.
822+ REVIEW_ARTIFACT_DIR : ${{ steps.review_artifact.outputs.artifact_dir }}
823+ ENGINE_VERSION : ${{ steps.state.outputs.engine_version }}
824+ CFG_HASH : ${{ steps.state.outputs.cfg_hash }}
825+ DEPTH_CAP : ${{ inputs.depth_cap }}
826+ MODEL : ${{ inputs.model }}
827+ AGENT_MODEL_INPUT : ${{ inputs.agent_model }}
828+ PARSING_MODEL_INPUT : ${{ inputs.parsing_model }}
829+ KEEP_AUTH : ' true'
830+ run : ' "$GITHUB_ACTION_PATH/scripts/action/with-auth.sh" "$GITHUB_ACTION_PATH/scripts/action/review-preview-pr.sh" 2'
831+
832+ - name : Upload preview 2
833+ id : upload_preview_2
834+ if : steps.preview_2.outputs.artifact_dir != '' && github.server_url == 'https://github.com'
835+ continue-on-error : true
836+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
837+ with :
838+ name : codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_2.outputs.pr_number }}-${{ steps.preview_2.outputs.head_sha }}
839+ path : ${{ steps.preview_2.outputs.artifact_dir }}
840+ if-no-files-found : error
841+ retention-days : 14
842+
843+ - name : Preview pull request 3 for the setup PR
844+ id : preview_3
845+ if : steps.guard.outputs.mode == 'review' && steps.preview_list.outputs.count >= 3
846+ continue-on-error : true
847+ shell : bash
848+ env :
849+ ACTION_PATH : ${{ github.action_path }}
850+ CHECKOUT_DIR : ${{ github.workspace }}/.codeboarding-target
851+ GIT_TOKEN : ${{ inputs.github_token }}
852+ REPOSITORY : ${{ github.repository }}
853+ SETUP_PR : ${{ steps.guard.outputs.pr_number }}
854+ REVIEW_BASE_SHA : ${{ steps.guard.outputs.merge_base_sha }}
855+ BASE_ANALYSIS_PATH : ${{ steps.review_baseline.outputs.base_analysis_path }}
856+ # The setup PR's own review artifact already records where the base graph lives.
857+ REVIEW_ARTIFACT_DIR : ${{ steps.review_artifact.outputs.artifact_dir }}
858+ ENGINE_VERSION : ${{ steps.state.outputs.engine_version }}
859+ CFG_HASH : ${{ steps.state.outputs.cfg_hash }}
860+ DEPTH_CAP : ${{ inputs.depth_cap }}
861+ MODEL : ${{ inputs.model }}
862+ AGENT_MODEL_INPUT : ${{ inputs.agent_model }}
863+ PARSING_MODEL_INPUT : ${{ inputs.parsing_model }}
864+ run : ' "$GITHUB_ACTION_PATH/scripts/action/with-auth.sh" "$GITHUB_ACTION_PATH/scripts/action/review-preview-pr.sh" 3'
865+
866+ - name : Upload preview 3
867+ id : upload_preview_3
868+ if : steps.preview_3.outputs.artifact_dir != '' && github.server_url == 'https://github.com'
869+ continue-on-error : true
870+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
871+ with :
872+ name : codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_3.outputs.pr_number }}-${{ steps.preview_3.outputs.head_sha }}
873+ path : ${{ steps.preview_3.outputs.artifact_dir }}
874+ if-no-files-found : error
875+ retention-days : 14
876+
877+ # The head and preview steps remove the credentials themselves; this covers a run that
878+ # failed before them, and a setup PR's run, which keeps them for its previews.
879+ - name : Remove analysis credentials
880+ if : always() && steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
881+ shell : bash
882+ run : ' "$GITHUB_ACTION_PATH/scripts/action/clear-auth.sh"'
883+
733884 # The same body, on the run page. Job summaries and logs are explicitly excluded from
734885 # the artifact storage allowance, and the cap is 1MiB per step against a diagram
735886 # measured in single-digit kilobytes, so this is free in both senses. It earns its
0 commit comments