Skip to content

Commit 6c45168

Browse files
committed
WIP: refactor CI
1 parent 434ac71 commit 6c45168

File tree

4 files changed

+238
-147
lines changed

4 files changed

+238
-147
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: "Set up Botan"
2+
description: "Build and install a specific Botan version from source"
3+
inputs:
4+
# TODO: for now, users have to provide full botan versions in
5+
# inputs.botan-version. It would be nice if we could handle incomplete botan
6+
# versions too, like haskell-actions/setup does for GHC and Cabal versions.
7+
# If I pass in only a MAJOR version (e.g. 3), then I'd want it to resolve
8+
# this the greatest MINOR and PATCH version (e.g., 3.8.1). Likewise, if I
9+
# pass in only a MAJOR and MINOR version (e.g., 3.8.1), then I'd want it to
10+
# resolve this to the greatest PATCH version (e.g., 3.8.1).
11+
botan-version:
12+
required: true
13+
description: "Botan version"
14+
run-tests:
15+
required: false
16+
description: "Run tests"
17+
runs:
18+
using: composite
19+
steps:
20+
- name: 📥 Checkout Botan repository
21+
uses: actions/checkout@v5
22+
with:
23+
repository: randombit/botan
24+
path: ./tmp-botan
25+
ref: ${{ inputs.botan-version }}
26+
27+
# The use of ccache/sccache drastically improves build times. The running time
28+
# of the setup-botan action goes from 10-20 minutes to ~1-2 minute.
29+
- name: 💾 Cache using ccache/sccache
30+
uses: hendrikmuhs/[email protected]
31+
with:
32+
create-symlink: true
33+
variant: ${{ runner.os == 'Windows' && 'sccache' || 'ccache' }}
34+
key: setup-botan-${{ runner.os }}-Botan-${{ inputs.botan-version }}
35+
evict-old-files: 'job'
36+
max-size: 50M
37+
38+
- name: 🛠️ Build Botan (Unix)
39+
if: ${{ runner.os == 'Linux' || runner.os == 'MacOS' }}
40+
shell: sh
41+
working-directory: ./tmp-botan
42+
run: |
43+
python3 ./configure.py \
44+
--compiler-cache=ccache \
45+
--build-targets=static,shared \
46+
--without-documentation
47+
make
48+
49+
- name: 🛠️ Build Botan (Windows)
50+
if: ${{ runner.os == 'Windows' }}
51+
shell: sh
52+
working-directory: ./tmp-botan
53+
run: |
54+
python3 ./configure.py --cc=gcc --os=mingw \
55+
--compiler-cache=sccache \
56+
--build-targets=static,shared \
57+
--without-documentation \
58+
--prefix="C:\mingw64"
59+
make
60+
61+
- name: 🛠️ Run tests (Unix)
62+
if: ${{ inputs.run-tests && (runner.os == 'Linux' || runner.os == 'MacOS') }}
63+
shell: sh
64+
working-directory: ./tmp-botan
65+
run: |
66+
make check
67+
68+
- name: 🛠️ Run tests (Windows)
69+
if: ${{ inputs.run-tests && runner.os == 'Windows' }}
70+
shell: sh
71+
working-directory: ./tmp-botan
72+
run: |
73+
make check
74+
75+
- name: 🛠️ Install Botan (Unix)
76+
if: ${{ runner.os == 'Linux' || runner.os == 'MacOS' }}
77+
shell: sh
78+
working-directory: ./tmp-botan
79+
run: |
80+
sudo make install
81+
82+
- name: 🛠️ Install Botan (Windows)
83+
if: ${{ runner.os == 'Windows' }}
84+
shell: sh
85+
working-directory: ./tmp-botan
86+
run: |
87+
make install

.github/workflows/ci.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/haskell-ci.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Haskell CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
merge_group:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
# Set the default shell on all platforms.
18+
defaults:
19+
run:
20+
shell: sh
21+
22+
jobs:
23+
################################################################################
24+
# Build
25+
################################################################################
26+
build:
27+
runs-on: ${{ matrix.os }}
28+
timeout-minutes: 60
29+
30+
strategy:
31+
fail-fast: false
32+
# Picking matrix combinations is tricky as it's a trade-off: on the one
33+
# hand we want to test as many interesting combinations as possible, but
34+
# on the other hand we don't want combinatorial explosion. We strike a
35+
# balance as follows:
36+
#
37+
# * Build and test with all combinations of OS/GHC/Cabal, but with a fixed
38+
# Botan version, preferably the latest version which is currently
39+
# Botan-3.9.0.
40+
#
41+
# * Build and test with all Botan versions, but with a fixed OS/GHC/Cabal
42+
# combination, preferably Linux/GHC-9.6/Cabal-3.12
43+
matrix:
44+
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
45+
#ghc-version: ["9.2", "9.4", "9.6", "9.8", "9.10", "9.12"]
46+
ghc-version: ["9.6"]
47+
cabal-version: ["3.12"]
48+
botan-version: ["3.9.0"]
49+
#include:
50+
#- os: "ubuntu-latest"
51+
# ghc-version: "9.6"
52+
# cabal-version: "3.12"
53+
# botan-version: "3.0.0"
54+
#- os: "ubuntu-latest"
55+
# ghc-version: "9.6"
56+
# cabal-version: "3.12"
57+
# botan-version: "3.1.1"
58+
#- os: "ubuntu-latest"
59+
# ghc-version: "9.6"
60+
# cabal-version: "3.12"
61+
# botan-version: "3.2.0"
62+
#- os: "ubuntu-latest"
63+
# ghc-version: "9.6"
64+
# cabal-version: "3.12"
65+
# botan-version: "3.3.0"
66+
#- os: "ubuntu-latest"
67+
# ghc-version: "9.6"
68+
# cabal-version: "3.12"
69+
# botan-version: "3.4.0"
70+
#- os: "ubuntu-latest"
71+
# ghc-version: "9.6"
72+
# cabal-version: "3.12"
73+
# botan-version: "3.5.0"
74+
#- os: "ubuntu-latest"
75+
# ghc-version: "9.6"
76+
# cabal-version: "3.12"
77+
# botan-version: "3.6.1"
78+
#- os: "ubuntu-latest"
79+
# ghc-version: "9.6"
80+
# cabal-version: "3.12"
81+
# botan-version: "3.7.1"
82+
#- os: "ubuntu-latest"
83+
# ghc-version: "9.6"
84+
# cabal-version: "3.12"
85+
# botan-version: "3.8.1"
86+
87+
steps:
88+
- name: 📥 Checkout repository
89+
uses: actions/checkout@v5
90+
91+
- name: 🛠️ Setup Botan
92+
uses: ./.github/actions/setup-botan
93+
timeout-minutes: 30
94+
with:
95+
botan-version: ${{ matrix.botan-version }}
96+
97+
- name: 🛠️ Setup Haskell
98+
id: setup-haskell
99+
uses: haskell-actions/setup@v2
100+
with:
101+
ghc-version: ${{ matrix.ghc-version }}
102+
cabal-version: ${{ matrix.cabal-version }}
103+
104+
- name: 🛠️ Configure
105+
run: |
106+
cabal configure \
107+
--enable-tests \
108+
--enable-benchmarks \
109+
--disable-documentation \
110+
--ghc-options="-Werror" \
111+
cat "cabal.project.local"
112+
113+
# This step will generate a dist-newstyle/cache/plan.json file. This file is
114+
# hashed and the resulting hash is included in the cache key.
115+
- name: 💾 Generate Cabal plan
116+
run: |
117+
cabal build all --dry-run
118+
119+
- name: 💾 Restore cache
120+
uses: actions/cache/restore@v4
121+
id: restore-cabal-cache
122+
env:
123+
key: build-botan-${{ runner.os }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}-Botan-${{ matrix.botan-version }}
124+
with:
125+
path: ${{ steps.setup-haskell.outputs.cabal-store }}
126+
key: ${{ env.key }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
127+
restore-keys: ${{ env.key }}-
128+
129+
- name: 🛠️ Build Cabal dependencies
130+
run: |
131+
cabal build all --only-dependencies
132+
133+
- name: 💾 Save cache
134+
uses: actions/cache/save@v4
135+
if: ${{ steps.restore-cabal-cache.outputs.cache-hit != 'true' }}
136+
with:
137+
path: ${{ steps.setup-haskell.outputs.cabal-store }}
138+
key: ${{ steps.restore-cabal-cache.outputs.cache-primary-key }}
139+
140+
- name: 🏗️ Build
141+
run: |
142+
cabal build all
143+
144+
- name: 🧪 Test
145+
id: test
146+
run: |
147+
cabal test all -j1 --test-show-details=direct
148+
env:
149+
# Most tests in the repositoy use hspec instead of Tasty, but we make
150+
# sure to include a timeout for Tasty tests regardless.
151+
TASTY_TIMEOUT: "5m"

.github/workflows/main-ci.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)