Skip to content

Commit 89e78dd

Browse files
committed
first cut at API checking
Cabal-syntax and Cabal only; I assume cabal-install-solver is not a public API.
1 parent 969343a commit 89e78dd

File tree

3 files changed

+19809
-0
lines changed

3 files changed

+19809
-0
lines changed

.github/workflows/check-api.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Check API
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- "doc/**"
7+
- "**/README.md"
8+
- "CONTRIBUTING.md"
9+
branches:
10+
- master
11+
pull_request:
12+
paths-ignore:
13+
- "doc/**"
14+
- "**/README.md"
15+
- "CONTRIBUTING.md"
16+
release:
17+
types:
18+
- created
19+
workflow_call:
20+
21+
jobs:
22+
check-api:
23+
name: Check API using ${{ matrix.sys.os }} ghc-${{ matrix.ghc }}
24+
runs-on: ${{ matrix.sys.os }}
25+
strategy:
26+
matrix:
27+
# we check API only on one platform and ghc release, since it shouldn't
28+
# vary elsewhere and the API tracer is sensitive to both
29+
sys:
30+
- { os: ubuntu-latest }
31+
ghc:
32+
[
33+
# print-api only supports a small subset of ghc versions
34+
"9.10.1",
35+
]
36+
37+
steps:
38+
39+
- uses: actions/checkout@v4
40+
41+
- uses: haskell-actions/setup@v2
42+
id: setup-haskell
43+
with:
44+
ghc-version: ${{ matrix.ghc }}
45+
cabal-version: 3.12.1.0 # see https://github.com/haskell/cabal/pull/10251
46+
ghcup-release-channel: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml
47+
48+
# I was going to use the canned action, but it only supports a single package and reinstalls the same binary each time
49+
- name: Install print-api
50+
run: |
51+
wget -q https://github.com/Kleidukos/print-api/releases/download/v0.1.0.1/print-api-0.1.0.1-Linux-static-${{ matrix.ghc }}-x86_64.tar.gz
52+
tar -xzvf print-api-0.1.0.1-Linux-static-${{ matrix.ghc }}-x86_64.tar.gz
53+
chmod +x print-api
54+
55+
# print-api needs environment files. It also doesn't make a lot of sense to use the cached builds, sadly,
56+
# since they're special in different ways (bootstrap and validate) and we want a vanilla build. And there
57+
# isn't enough cache space to make a third cache, even though this is a very limited build.
58+
- name: Build Cabal with environment files
59+
run: cabal build Cabal-syntax Cabal --write-ghc-environment-files=always
60+
61+
- name: Generate Cabal-syntax and Cabal APIs
62+
run: |
63+
./print-api --package-name Cabal-syntax > Cabal-syntax-${{ matrix.ghc }}-${{ matrix.sys.os }}.api
64+
./print-api --package-name Cabal > Cabal-${{ matrix.ghc }}-${{ matrix.sys.os }}.api
65+
66+
# for convenience, since large changes would be a pain to reconstruct from diffs and
67+
# contributors aren't guaranteed to have ubuntu-latest handy
68+
# run this _before_ checking the API, so hopefully they're available on failure
69+
# because that's the point of making them artifacts!
70+
- uses: actions/upload-artifact@v4
71+
with:
72+
name: Cabal-api
73+
path: '*.api'
74+
75+
- name: Check Cabal-syntax and Cabal APIs
76+
run: |
77+
echo "Cabal-syntax API changes:"
78+
diff Cabal-syntax/Cabal-syntax-${{ matrix.ghc }}-${{ matrix.sys.os }}.api Cabal-syntax-${{ matrix.ghc }}-${{ matrix.sys.os }}.api
79+
echo
80+
echo "Cabal API changes:"
81+
diff Cabal/Cabal-${{ matrix.ghc }}-${{ matrix.sys.os }}.api Cabal-${{ matrix.ghc }}-${{ matrix.sys.os }}.api

0 commit comments

Comments
 (0)