diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index a414278..b1383b6 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -1,7 +1,7 @@ on: [push] name: benchmark jobs: - test: + benchmark: name: Run benchmark on GHC ${{ matrix.ghc }} runs-on: ubuntu-latest strategy: @@ -17,9 +17,15 @@ jobs: with: ghc-version: ${{ matrix.ghc }} cabal-version: ${{ matrix.cabal }} - - run: cabal bench --benchmark-options="--output hs-git-gsub-benchmark-${{ github.sha }}.html" + - run: cabal bench -v0 --benchmark-options="--output hs-git-gsub-benchmark-${{ github.sha }}.html" >> benchmark-results.txt - name: Upload Benchmark Results uses: actions/upload-artifact@v4 with: name: benchmark-results path: hs-git-gsub-benchmark-${{ github.sha }}.html + - name: Post Benchmark Results as PR Comment + if: ${{ github.event.issue.pull_request }} + run: | + COMMENT_BODY="## Benchmark Results on ${{ github.sha }}\n\`\`\`\n$(cat benchmark-results.txt)\n\`\`\`" + POST_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" + curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" -X POST --data "{\"body\": \"$COMMENT_BODY\"}" $POST_URL diff --git a/benchmark/Main.hs b/benchmark/Main.hs index 221f983..f95522f 100644 --- a/benchmark/Main.hs +++ b/benchmark/Main.hs @@ -1,13 +1,9 @@ -import qualified Cli import Criterion.Main import System.Directory -import System.Process benchmark1 :: IO () benchmark1 = do withCurrentDirectory "benchmark/git" $ do - Cli.run ["git", "svn"] - (exitcode, _, _) <- readProcessWithExitCode "git" ["reset", "--hard"] [] return () main :: IO ()