|
1 | 1 | name: CI
|
2 | 2 | on:
|
3 |
| - - pull_request |
4 |
| - - push |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + tags: |
| 7 | + - v* |
| 8 | + pull_request: |
| 9 | + release: |
| 10 | + |
| 11 | +env: |
| 12 | + GHC_FOR_RELEASE: "9.10" |
| 13 | + |
5 | 14 | jobs:
|
6 |
| - build_posix: |
7 |
| - name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} |
8 |
| - runs-on: ${{ matrix.os }} |
| 15 | + build: |
| 16 | + name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} ${{matrix.container}} |
9 | 17 | strategy:
|
| 18 | + fail-fast: false |
10 | 19 | matrix:
|
11 |
| - ghc: |
12 |
| - - "9.12.1" |
13 |
| - - "9.10.1" |
14 |
| - - "9.8.4" |
15 |
| - - "9.6.6" |
16 |
| - - "9.4.8" |
17 |
| - - "9.2.8" |
18 |
| - - "9.0.2" |
19 |
| - - "8.10.7" |
20 |
| - - "8.8.4" |
21 |
| - cabal: |
22 |
| - - "3.12.1.0" |
23 |
| - os: |
24 |
| - - ubuntu-latest |
| 20 | + os: [ubuntu-latest] |
| 21 | + ghc-version: ['9.12', '9.10', '9.8', '9.6', '9.4', '9.2'] |
| 22 | + container: [''] |
| 23 | + |
25 | 24 | include:
|
| 25 | + # The windows build is currently broken |
| 26 | + # See #135 |
| 27 | + #- os: windows-latest |
| 28 | + # ghc-version: '9.10' |
26 | 29 | - os: macos-latest
|
27 |
| - ghc: "9.12.1" |
28 |
| - cabal: "3.12.1.0" |
29 |
| - - os: macos-latest |
30 |
| - ghc: "9.10.1" |
31 |
| - cabal: "3.12.1.0" |
32 |
| - - os: macos-latest |
33 |
| - ghc: "9.8.2" |
34 |
| - cabal: "3.12.1.0" |
35 |
| - fail-fast: false |
| 30 | + ghc-version: '9.10' |
| 31 | + # gtk2hs is broken under apline |
| 32 | + # See https://github.com/gtk2hs/gtk2hs/issues/262 |
| 33 | + #- os: ubuntu-latest |
| 34 | + # ghc-version: '9.10' |
| 35 | + # container: alpine:3.21 |
| 36 | + |
| 37 | + runs-on: ${{ matrix.os }} |
| 38 | + container: ${{ matrix.container }} |
| 39 | + |
36 | 40 | steps:
|
37 |
| - - uses: actions/checkout@v2 |
38 |
| - - name: Set up Haskell |
39 |
| - id: setup-haskell-cabal |
40 |
| - uses: haskell-actions/setup@v2 |
41 |
| - with: |
42 |
| - ghc-version: ${{ matrix.ghc }} |
43 |
| - cabal-version: ${{ matrix.cabal }} |
44 |
| - - name: Cache cabal-store |
45 |
| - uses: actions/cache@v2 |
46 |
| - with: |
47 |
| - path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} |
48 |
| - key: ${{ runner.os }}-${{ matrix.ghc }}-cabal |
49 |
| - - name: Install system dependencies (Linux) |
50 |
| - if: runner.os == 'Linux' |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Install system dependencies (Alpine) |
| 44 | + if: ${{ startsWith(matrix.container, 'alpine') }} |
| 45 | + shell: sh |
| 46 | + run: | |
| 47 | + apk add bash curl sudo jq pkgconfig \ |
| 48 | + zlib-dev zlib-static binutils curl \ |
| 49 | + gcc g++ gmp-dev libc-dev libffi-dev make \ |
| 50 | + musl-dev ncurses-dev perl tar xz \ |
| 51 | + gtk+2.0-dev |
| 52 | +
|
| 53 | + - name: Install system dependencies (Ubuntu) |
| 54 | + if: runner.os == 'Linux' && !startsWith(matrix.container, 'alpine') |
51 | 55 | run: sudo apt-get update && sudo apt-get install libgtk2.0-dev
|
| 56 | + |
52 | 57 | - name: Install system dependencies (macOS)
|
53 | 58 | if: runner.os == 'macOS'
|
54 | 59 | run: brew install cairo gtk+ pkg-config
|
| 60 | + |
55 | 61 | - name: Set extra cabal build options (macOS)
|
56 | 62 | if: runner.os == 'macOS'
|
57 |
| - run: echo "CABAL_BUILD_OPTIONS=--constraint='gtk +have-quartz-gtk'" >> $GITHUB_ENV |
58 |
| - - name: Build Haskell dependencies |
| 63 | + run: printf 'package gtk\n flags: +have-quartz-gtk' >>cabal.project |
| 64 | + |
| 65 | + |
| 66 | + - name: Set up GHC ${{ matrix.ghc-version }} |
| 67 | + uses: haskell-actions/setup@v2 |
| 68 | + id: setup |
| 69 | + with: |
| 70 | + ghc-version: ${{ matrix.ghc-version }} |
| 71 | + |
| 72 | + - name: Enable static build (only on alpine) |
| 73 | + if: ${{ startsWith(matrix.container, 'alpine') }} |
59 | 74 | run: |
|
60 |
| - echo $CABAL_BUILD_OPTIONS |
61 |
| - eval cabal build $CABAL_BUILD_OPTIONS --enable-tests --enable-benchmarks --dep -j all |
62 |
| - eval cabal build $CABAL_BUILD_OPTIONS --disable-tests --disable-benchmarks --dep -j all |
63 |
| - - name: Build ThreadScope |
| 75 | + echo 'executable-static: true' >>cabal.project |
| 76 | + echo 'cc-options: -D_Noreturn=' >>cabal.project |
| 77 | +
|
| 78 | + - name: Configure the build |
64 | 79 | run: |
|
65 |
| - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) |
66 |
| - # Packaging... |
67 |
| - cabal v2-sdist all |
68 |
| - # Unpacking... |
69 |
| - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/ |
70 |
| - cd ${DISTDIR} || false |
71 |
| - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \; |
72 |
| - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \; |
73 |
| - PKGDIR_threadscope="$(find . -maxdepth 1 -type d -regex '.*/threadscope-[0-9.]*')" |
74 |
| - # Generate cabal.project |
75 |
| - rm -rf cabal.project cabal.project.local cabal.project.freeze |
76 |
| - touch cabal.project |
77 |
| - echo "packages: ${PKGDIR_threadscope}" >> cabal.project |
78 |
| - for pkg in $(ghc-pkg list --simple-output); do |
79 |
| - echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(threadscope)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; |
80 |
| - done |
81 |
| - cat cabal.project || true |
82 |
| - cat cabal.project.local || true |
83 |
| - # Building... |
84 |
| - # this builds all libraries and executables (without tests/benchmarks) |
85 |
| - eval cabal build $CABAL_BUILD_OPTIONS --disable-tests --disable-benchmarks all |
86 |
| - # Building with tests and benchmarks... |
87 |
| - # build & run tests, build benchmarks |
88 |
| - eval cabal build $CABAL_BUILD_OPTIONS --enable-tests --enable-benchmarks all |
89 |
| - # cabal check... |
90 |
| - (cd ${PKGDIR_threadscope} && cabal -vnormal check) |
91 |
| - # Building without installed constraints for packages in global-db... |
92 |
| - rm -f cabal.project.local |
93 |
| - eval cabal build $CABAL_BUILD_OPTIONS --disable-tests --disable-benchmarks all |
94 |
| - echo $(cabal v2-exec -v0 which threadscope) |
95 |
| - cp "$(cabal v2-exec -v0 which threadscope)" "$GITHUB_WORKSPACE/threadscope.$PLATFORM.ghc-$GHCVER" |
96 |
| - gzip -f "$GITHUB_WORKSPACE/threadscope.$PLATFORM.ghc-$GHCVER" |
| 80 | + cabal configure --enable-tests --enable-benchmarks --disable-documentation |
| 81 | + cabal build all --dry-run |
| 82 | +
|
| 83 | +
|
| 84 | + - name: Restore cached dependencies |
| 85 | + uses: actions/cache/restore@v4 |
| 86 | + id: cache |
97 | 87 | env:
|
98 |
| - GHCVER: ${{ matrix.ghc }} |
99 |
| - PLATFORM: ${{ matrix.os }} |
100 |
| - - name: Release |
101 |
| - uses: softprops/action-gh-release@v1 |
102 |
| - env: |
103 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
104 |
| - if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.ghc == '9.2.2' }} |
| 88 | + key: ${{ runner.os }}${{ matrix.container && '-container-' }}${{matrix.container}}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} |
105 | 89 | with:
|
106 |
| - files: threadscope.${{ matrix.os }}.ghc-${{ matrix.ghc }}.gz |
107 |
| - draft: false |
108 |
| - prerelease: false |
109 |
| - build_windows: |
110 |
| - if: false # This workflow is currently broken due to C library issues. See: https://github.com/haskell/ThreadScope/issues/135 |
111 |
| - name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} |
112 |
| - runs-on: ${{ matrix.os }} |
113 |
| - strategy: |
114 |
| - matrix: |
115 |
| - ghc: |
116 |
| - - "9.8.2" |
117 |
| - - "9.6.4" |
118 |
| - - "9.4.8" |
119 |
| - - "9.2.2" |
120 |
| - - "9.0.2" |
121 |
| - - "8.10.7" |
122 |
| - - "8.8.4" |
123 |
| - cabal: |
124 |
| - - "3.12.1.0" |
125 |
| - os: |
126 |
| - - windows-latest |
127 |
| - fail-fast: false |
128 |
| - steps: |
129 |
| - - uses: actions/checkout@v2 |
130 |
| - - name: Set up Haskell |
131 |
| - id: setup-haskell-cabal |
132 |
| - uses: haskell-actions/setup@v2 |
| 90 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 91 | + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} |
| 92 | + restore-keys: ${{ env.key }}- |
| 93 | + |
| 94 | + - name: Install dependencies |
| 95 | + # If we had an exact cache hit, the dependencies will be up to date. |
| 96 | + if: steps.cache.outputs.cache-hit != 'true' |
| 97 | + run: cabal build all --only-dependencies |
| 98 | + |
| 99 | + # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. |
| 100 | + - name: Save cached dependencies |
| 101 | + uses: actions/cache/save@v4 |
| 102 | + # If we had an exact cache hit, trying to save the cache would error because of key clash. |
| 103 | + if: steps.cache.outputs.cache-hit != 'true' |
133 | 104 | with:
|
134 |
| - ghc-version: ${{ matrix.ghc }} |
135 |
| - cabal-version: ${{ matrix.cabal }} |
136 |
| - - name: Install system dependencies |
| 105 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 106 | + key: ${{ steps.cache.outputs.cache-primary-key }} |
| 107 | + |
| 108 | + - name: Install system dependencies (Windows) |
| 109 | + if: ${{ startsWith(matrix.os, 'windows') }} |
137 | 110 | uses: msys2/setup-msys2@v2
|
138 | 111 | with:
|
139 | 112 | path-type: inherit
|
140 | 113 | install: >-
|
141 | 114 | mingw-w64-x86_64-pkg-config
|
142 | 115 | mingw-w64-x86_64-gtk2
|
143 |
| - - name: Cache cabal-store |
144 |
| - uses: actions/cache@v2 |
145 |
| - with: |
146 |
| - path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} |
147 |
| - key: ${{ runner.os }}-${{ matrix.ghc }}-cabal |
148 |
| - - name: Build Haskell dependencies |
149 |
| - run: cabal build -j all --dep |
150 |
| - shell: msys2 {0} |
151 |
| - - name: Build ThreadScope |
| 116 | +
|
| 117 | + - name: Build |
| 118 | + run: cabal build all |
| 119 | + |
| 120 | + - name: Run tests |
| 121 | + run: cabal test all |
| 122 | + |
| 123 | + - name: Check cabal file |
| 124 | + run: cabal check |
| 125 | + |
| 126 | + - name: Create bindist |
| 127 | + shell: sh |
152 | 128 | run: |
|
153 |
| - cabal build -j all |
154 |
| - cp -v $(find -name threadscope.exe) ./threadscope.exe |
155 |
| - 7z a threadscope.$PLATFORM.ghc-$GHCVER.zip threadscope.exe |
156 |
| - shell: msys2 {0} |
157 |
| - env: |
158 |
| - PLATFORM: ${{ matrix.os }} |
159 |
| - GHCVER: ${{ matrix.ghc }} |
| 129 | + cabal install --install-method=copy --installdir=dist |
| 130 | + BINDIST_NAME=threadscope-ghc-${{matrix.ghc-version}}-${{ matrix.os }}${{ matrix.container && '-' }}${{matrix.container && 'alpine'}} |
| 131 | + echo "BINDIST_NAME=$BINDIST_NAME" >> $GITHUB_ENV |
| 132 | + tar -czf "$BINDIST_NAME.tar.xz" -C dist threadscope |
| 133 | + echo bindist is $BINDIST_NAME.tar.xz |
| 134 | +
|
| 135 | + - name: Upload bindist to artifacts |
| 136 | + uses: actions/upload-artifact@v4 |
| 137 | + if: ${{ matrix.ghc-version == env.GHC_FOR_RELEASE }} |
| 138 | + with: |
| 139 | + name: ${{ env.BINDIST_NAME }} |
| 140 | + path: ${{ env.BINDIST_NAME}}.tar.xz |
| 141 | + |
160 | 142 | - name: Release
|
161 |
| - uses: softprops/action-gh-release@v1 |
162 |
| - env: |
163 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
164 |
| - if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.ghc == '9.2.2' }} |
| 143 | + uses: softprops/action-gh-release@v2 |
| 144 | + if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.ghc-version == env.GHC_FOR_RELEASE }} |
165 | 145 | with:
|
166 |
| - files: threadscope.${{ matrix.os }}.ghc-${{ matrix.ghc }}.zip |
167 |
| - draft: false |
168 |
| - prerelease: false |
| 146 | + files: ${{ env.BINDIST_NAME }}.tar.xz |
0 commit comments