diff --git a/.github/workflows/comment-pr.yaml b/.github/workflows/comment-pr.yaml new file mode 100644 index 000000000..24bf1fbc3 --- /dev/null +++ b/.github/workflows/comment-pr.yaml @@ -0,0 +1,28 @@ +name: Comment on pull request + +on: + workflow_run: + workflows: ["Performance"] + types: [completed] + +jobs: + post-comment: + name: Post PR comment + runs-on: ubuntu-latest + permissions: + pull-requests: write + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'}} + steps: + - name: Download comment + uses: actions/download-artifact@v4 + with: + name: perf-report + path: perf-report.txt + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Post message to PR + uses: mshick/add-pr-comment@dd126dd8c253650d181ad9538d8b4fa218fc31e8 + with: + message-path: perf-report.txt + issue: ${{ github.event.workflow_run.pull_requests[0].number }} diff --git a/.github/workflows/performance.yaml b/.github/workflows/performance.yaml index f24b4de36..5f3e93bdf 100644 --- a/.github/workflows/performance.yaml +++ b/.github/workflows/performance.yaml @@ -1,7 +1,7 @@ name: Performance on: - pull_request_target: + pull_request: branches: [main] jobs: @@ -37,8 +37,6 @@ jobs: runs-on: ubuntu-22.04 needs: build name: Benchmark chisel info (chisel-releases 24.04) - permissions: - pull-requests: write steps: - name: Download base uses: actions/download-artifact@v4 @@ -68,7 +66,9 @@ jobs: chmod +x base head hyperfine --export-markdown "$msg_file" "./base info --release ./chisel-releases 'python3.12_core'" -n "BASE" "./head info --release ./chisel-releases 'python3.12_core'" -n "HEAD" - - name: Post message to PR - uses: mshick/add-pr-comment@v2 + - name: Upload result + uses: actions/upload-artifact@v4 with: - message-path: ${{ steps.benchmark.outputs.msg_file }} + name: perf-report + path: ${{ steps.benchmark.outputs.msg_file }} + retention-days: 1 diff --git a/cmd/chisel/main.go b/cmd/chisel/main.go index 50792839b..a4f7253ee 100644 --- a/cmd/chisel/main.go +++ b/cmd/chisel/main.go @@ -19,6 +19,8 @@ import ( //"github.com/canonical/chisel/internal/logger" ) +// TEST + var ( // Standard streams, redirected for testing. Stdin io.Reader = os.Stdin