From ba27835acb1afb079f3727072278e0911975e7a0 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 15 Oct 2026 12:25:49 +0200 Subject: [PATCH] Delete .github/workflows/commands.yml --- .github/workflows/commands.yml | 236 --------------------------------- 1 file changed, 236 deletions(-) delete mode 100644 .github/workflows/commands.yml diff --git a/.github/workflows/commands.yml b/.github/workflows/commands.yml deleted file mode 100644 index 87edd6211f0..00000000000 --- a/.github/workflows/commands.yml +++ /dev/null @@ -1,236 +0,0 @@ -name: Run CLI Commands via PR Comment - -on: - issue_comment: - types: [created] - -jobs: - authorize_commenter: - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - outputs: - allowed: ${{ steps.check.outputs.allowed }} - steps: - - name: Check commenter write access - id: check - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const actor = context.payload.comment.user.login; - const repo_owner = context.payload.repository.owner.login; - const repo_name = context.payload.repository.name; - try { - const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({ - owner: repo_owner, - repo: repo_name, - username: actor - }); - const allowed = ['admin', 'write'].includes(permission.permission); - core.setOutput('allowed', allowed ? 'true' : 'false'); - } catch (e) { - core.setOutput('allowed', 'false'); - } - - parsing_job: - needs: authorize_commenter - runs-on: ubuntu-latest - permissions: - issues: write # Allow adding a reaction via the comment-pipeline - pull-requests: write - outputs: - command: ${{ steps.parse.outputs.command }} - arg: ${{ steps.parse.outputs.arguments }} - if: needs.authorize_commenter.outputs.allowed == 'true' && github.event.issue.pull_request - steps: - - name: Parse comment - id: parse - uses: dotnet/comment-pipeline@e08a11834acf1e825ac727b732ac9d4cb8120c51 - with: - comment: ${{ toJSON(github.event.comment) }} - commands: | - /run fantomas - /run ilverify - /run xlf - /run test-baseline - github-token: ${{ secrets.GITHUB_TOKEN }} - - # This second job by definition runs user-supplied code - you must NOT elevate its permissions to `write` - run-parsed-command: - needs: parsing_job - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - if: needs.parsing_job.outputs.command != '' - steps: - - - name: Checkout the repository - uses: actions/checkout@v4 - - - name: Checkout PR branch - run: gh auth setup-git && gh pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install dotnet - uses: actions/setup-dotnet@v3 - with: - global-json-file: global.json - - - name: Install dotnet tools - run: dotnet tool restore - - - name: Setup .NET 9.0.0 Runtime for test execution - if: ${{ needs.parsing_job.outputs.command == '/run test-baseline' }} - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '9.0.x' - - - name: Run command - id: run-cmd - env: - TEST_UPDATE_BSL: 1 - continue-on-error: true - run: | - case "${{ needs.parsing_job.outputs.command }}" in - "/run fantomas") dotnet fantomas . ;; - "/run xlf") dotnet build src/Compiler /t:UpdateXlf ;; - "/run ilverify") pwsh tests/ILVerify/ilverify.ps1 || true ;; - "/run test-baseline") dotnet test ./FSharp.Compiler.Service.slnx -- --filter-query "${{ needs.parsing_job.outputs.arg }}" -c Release || true ;; - *) echo "Unknown command" && exit 1 ;; - esac - - - name: Create patch & metadata - id: meta - if: needs.parsing_job.outputs.command - run: | - echo "run_step_outcome=${{ steps.run-cmd.outcome }}" > result - if [[ "${{ steps.run-cmd.outcome }}" == "success" ]]; then - git diff > repo.patch || true - if [ -s repo.patch ]; then echo "hasPatch=true" >> result; else echo "hasPatch=false" >> result; fi - else - echo "hasPatch=false" >> result - fi - cat result - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: cli-results - path: | - repo.patch - result - - apply-and-report: - needs: [parsing_job, run-parsed-command] - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - if: needs.parsing_job.outputs.command != '' && needs.run-parsed-command.result == 'success' - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - - name: Checkout PR branch - run: gh auth setup-git && gh pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: cli-results - - - name: Read metadata - id: read-meta - run: | - run_step_outcome="" - hasPatch="" - while IFS='=' read -r key value; do - case "$key" in - run_step_outcome) run_step_outcome="$value" ;; - hasPatch) hasPatch="$value" ;; - *) echo "Unexpected key: $key" >&2; exit 1 ;; - esac - done < result - echo "run_step_outcome=$run_step_outcome" >> $GITHUB_OUTPUT - echo "hasPatch=$hasPatch" >> $GITHUB_OUTPUT - - - name: Validate patch paths - if: ${{ steps.read-meta.outputs.run_step_outcome == 'success' && steps.read-meta.outputs.hasPatch == 'true' }} - run: | - # Forbid any .git* paths anywhere - if grep -E '^(\+\+\+|---) ' repo.patch | grep -E '(^|/)\.git(/|$)|(^|/)\.git'; then - echo "Patch touches .git paths; aborting"; exit 1 - fi - - # Allow only top-level src/, tests/, vsintegration/ changes - if grep -E '^(\+\+\+|---) ' repo.patch | grep -Ev '^(---|\+\+\+) (a|b)/(src|tests|vsintegration)/' | grep -E '^(---|\+\+\+) '; then - echo "Patch touches files outside allowed directories (src/tests/vsintegration); aborting"; exit 1 - fi - - - name: Apply and push patch - if: ${{ steps.read-meta.outputs.run_step_outcome == 'success' && steps.read-meta.outputs.hasPatch == 'true' }} - run: | - patch -p1 -s --force < repo.patch || true - git config user.name "GH Actions" - git config user.email "actions@github.com" - git add -u - git commit -m "Apply patch from ${{ needs.parsing_job.outputs.command }}" - branch=$(git rev-parse --abbrev-ref HEAD) - echo "Pushing to origin $branch" - git push origin HEAD:"$branch" - - - name: Count stats - id: stats - if: ${{ steps.read-meta.outputs.run_step_outcome == 'success' && steps.read-meta.outputs.hasPatch == 'true' }} - run: | - files=$(git diff --name-only HEAD~1 HEAD | wc -l) - lines=$(git diff HEAD~1 HEAD | wc -l) - echo "files=$files" >> $GITHUB_OUTPUT - echo "lines=$lines" >> $GITHUB_OUTPUT - - name: Generate and publish report - if: always() - env: - COMMAND: ${{ needs.parsing_job.outputs.command }} - OUTCOME: ${{ steps.read-meta.outputs.run_step_outcome }} - PATCH: ${{ steps.read-meta.outputs.hasPatch }} - run: | - # Build the markdown report - report=" - # 🔧 CLI Command Report - - - **Command:** \`${COMMAND}\` - - **Outcome:** ${OUTCOME} - - " - - if [[ "$OUTCOME" == "success" ]]; then - if [[ "$PATCH" == "true" ]]; then - report+="✅ Patch applied: - - Files changed: ${{ steps.stats.outputs.files }} - - Lines changed: ${{ steps.stats.outputs.lines }}" - else - report+="✅ Command succeeded, no changes needed." - fi - else - report+="❌ Command **failed** — no patch applied." - fi - - # Output to GitHub Actions UI - echo "$report" >> "$GITHUB_STEP_SUMMARY" - - # Store for use in next step - echo "$report" > pr_report.md - - - name: Comment on PR - if: always() - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh pr comment ${{ github.event.issue.number }} \ - --body-file pr_report.md