@@ -0,0 +1,121 @@
1+name: Regression checking
2+
3+on: pull_request
4+
5+
6+# References:
7+# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
8+# https://docs.github.com/en/actions/using-workflows/reusing-workflows#reusable-workflows-and-starter-workflows
9+# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_call
10+# https://docs.github.com/en/actions/learn-github-actions/contexts#about-contexts-and-expressions
11+
12+jobs:
13+ check-regressions:
14+ env:
15+ BENCH_SH: bin/bench.sh
16+ BENCHMARKS: >-
17+ Data.Array
18+ Data.Array.Foreign
19+ Data.Array.Prim
20+ Data.Array.Prim.Pinned
21+ Data.Fold
22+ Data.Parser
23+ Data.Parser.ParserD
24+ Data.Parser.ParserK
25+ Data.SmallArray
26+ Data.Stream.StreamD
27+ Data.Stream.StreamDK
28+ Data.Stream.StreamK
29+ Data.Unfold
30+ FileSystem.Handle
31+ Prelude.Ahead
32+ Prelude.Async
33+ Prelude.Parallel
34+ Prelude.Serial
35+ Prelude.WAsync
36+ Prelude.WSerial
37+ Prelude.ZipAsync
38+ Prelude.ZipSerial
39+ Unicode.Char
40+ Unicode.Stream
41+ Unicode.Utf8
42+ FIELDS: allocated
43+ DIFF_CUTOFF_PERCENT: 3
44+
45+ runs-on: ubuntu-latest
46+
47+ steps:
48+
49+ - name: Setup haskell
50+ uses: actions/setup-haskell@v1
51+ with:
52+ ghc-version: 8.8.4
53+ cabal-version: 3.2
54+
55+ - uses: actions/cache@v2
56+ name: Cache ~/.cabal and bench-report
57+ with:
58+ path: |
59+ ~/.cabal
60+ ./benchmark/bench-report/bin/bench-report
61+ # Bump the key version to clear the cache
62+ key: cache-v1
63+
64+ - name: Cache charts from master
65+ id: cache-charts-master
66+ uses: actions/cache@v2
67+ with:
68+ path: charts-master
69+ # Bump the key version to clear the cache
70+ key: charts-master-v1
71+
72+ # -----------------------------------------------------------------
73+ # -- Generate reports for the base branch and upload
74+ # -----------------------------------------------------------------
75+
76+ - name: Checkout the base branch
77+ if: steps.cache-charts-master.outputs.cache-hit != 'true'
78+ uses: actions/checkout@v2
79+ with:
80+ ref: master
81+
82+ - name: Run benchmarks
83+ if: steps.cache-charts-master.outputs.cache-hit != 'true'
84+ run: |
85+ chmod +x $BENCH_SH
86+ $BENCH_SH --benchmarks "$BENCHMARKS" --raw
87+
88+ - name: Move charts to charts-master
89+ if: steps.cache-charts-master.outputs.cache-hit != 'true'
90+ run: mv charts charts-master
91+
92+ # -----------------------------------------------------------------
93+ # -- Download, generate reports for the current branch and append
94+ # -----------------------------------------------------------------
95+
96+ - name: Checkout the current branch
97+ uses: actions/checkout@v2
98+ with:
99+ clean: false
100+
101+ - name: Copy charts-master to charts
102+ run: cp -r charts-master charts
103+
104+ - name: Run benchmarks and append
105+ run: |
106+ chmod +x $BENCH_SH
107+ $BENCH_SH --benchmarks "$BENCHMARKS" --raw --append
108+
109+ # -----------------------------------------------------------------
110+ # -- Compare
111+ # -----------------------------------------------------------------
112+
113+ - name: Compare benchmarks
114+ run: |
115+ chmod +x $BENCH_SH
116+ ! $BENCH_SH --benchmarks "$BENCHMARKS" \
117+ --fields "$FIELDS" \
118+ --no-measure \
119+ --silent --append \
120+ --diff-cutoff-percent $DIFF_CUTOFF_PERCENT \
121+ | grep -v "^$"