Skip to content

Commit b996c8e

Browse files
Merge pull request #2 from kda-community/kda_tool_renewal
Kda tool renewal
2 parents 3b0a243 + 0d1ffe5 commit b996c8e

File tree

18 files changed

+231
-285
lines changed

18 files changed

+231
-285
lines changed

.github/workflows/build.yml

Lines changed: 95 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
1-
name: Build project
21

3-
on: push
2+
name: Build
3+
4+
on:
5+
workflow_dispatch:
6+
7+
push:
8+
paths:
9+
- '**'
10+
- '!.github/**'
11+
- '.github/workflows/applications.yml'
412

513
jobs:
614
build:
7-
name: Build
15+
if: "!startsWith(github.ref, 'refs/tags/')"
816
runs-on: ${{ matrix.os }}
917
strategy:
1018
fail-fast: false
1119
matrix:
12-
ghc: ['9.6.4']
13-
cabal: ['3.8']
14-
os: ['ubuntu-20.04', 'ubuntu-22.04', 'macOS-latest']
20+
ghc: ["9.10.3"]
21+
cabal: ["3.12"]
22+
os: ["ubuntu-22.04", "ubuntu-24.04", "macos-14", "macos-15"]
1523

1624
steps:
17-
# Setup
1825
- name: Checkout repository
19-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ inputs.commit_sha || github.sha }}
2029

2130
# Haskell Setup
31+
- name: Set permissions for .ghcup (ubuntu)
32+
if: startsWith(matrix.os, 'ubuntu-')
33+
run: sudo chown -R $USER /usr/local/.ghcup
2234
- name: Install GHC and Cabal
2335
uses: haskell-actions/setup@v2
2436
with:
@@ -29,140 +41,95 @@ jobs:
2941
ghc --version
3042
cabal --version
3143
32-
# System dependencies
33-
- if: startsWith(matrix.os, 'macOS')
34-
name: Set up system depdendencies
35-
run: |
36-
brew install openssl
44+
- name: Setting up MPFR (Ubuntu)
45+
if: startsWith(matrix.os, 'ubuntu-')
46+
shell: bash
47+
run: sudo apt-get update && sudo apt-get install -y libmpfr-dev
3748

49+
# Project Setup
50+
- name: Create cabal.project.local
51+
shell: bash
52+
run: |
3853
cat > cabal.project.local <<EOF
39-
package *
40-
extra-include-dirs:
41-
/opt/homebrew/include
42-
/opt/homebrew/opt/openssl/include
43-
extra-lib-dirs:
44-
/opt/homebrew/lib
45-
/opt/homebrew/opt/openssl/lib
54+
documentation: False
55+
package pact
56+
tests: True
57+
benchmarks: True
58+
documentation: False
59+
optimization: 1
60+
flags: ${{ matrix.flags }} +cryptonite-ed25519
61+
extra-include-dirs:
62+
/opt/local/include
63+
/usr/local/opt/openssl/include
64+
extra-lib-dirs:
65+
/opt/local/lib
66+
/usr/local/opt/openssl/lib/
4667
EOF
4768
48-
# dist cache
49-
# the cache-key forces uploading of cache at least once a day, which ensures that
50-
# upstream dependency changes are captured regularly.
51-
- name: Create date file for dist-newstyle cache key
52-
id: cache-date
69+
- name: Extend cabal.project.local for GHC-9.0.2
70+
if: "startsWith(matrix.ghc, '9')"
71+
shell: bash
5372
run: |
54-
echo "value=$(date +%Y.%j)" >> $GITHUB_OUTPUT
55-
- uses: actions/cache@v3
56-
name: Cache dist-newstyle
57-
with:
58-
path: |
59-
~/.cabal/packages
60-
~/.cabal/store
61-
dist-newstyle
62-
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ steps.cache-date.outputs.value }}-${{ hashFiles('cabal.*', '*.cabal', 'src/**', 'test/**') }}
63-
restore-keys: |
64-
${{ matrix.os }}-${{ matrix.ghc }}-${{ steps.cache-date.outputs.value }}-
65-
${{ matrix.os }}-${{ matrix.ghc }}-
66-
67-
# Build
68-
- name: Update package database
69-
run: cabal update
70-
- name: Display outdated packages
71-
run: cabal outdated
72-
- name: Install build dependencies
73-
run: cabal build --only-dependencies
74-
- name: Build
75-
run: cabal build
76-
- name: Show installed packages
77-
run: cabal freeze && cat cabal.project.freeze
78-
79-
# Upload artifacts
80-
- name: Copy build artifact
81-
run: cp `cabal list-bin exe:kda` .
82-
- name: Stripping binary
83-
run: strip kda
84-
- uses: actions/upload-artifact@v4
85-
with:
86-
name: kda-build-${{ matrix.os }}-${{ matrix.ghc }}
87-
path: kda
88-
89-
# Test
90-
- name: Test
91-
run: cabal test
73+
cat >> cabal.project.local <<EOF
74+
package pact
75+
ghc-options: -Wwarn -Wunused-packages
76+
EOF
9277
93-
# ########################################################################## #
94-
# Build and publish docker image
78+
- name: Add check for unused packages
79+
shell: bash
80+
run: |
81+
cat >> cabal.project.local <<EOF
82+
package pact
83+
ghc-options: -Wunused-packages
84+
EOF
9585
96-
docker-image:
97-
name: Build and publish docker image
98-
needs: [build]
99-
runs-on: ${{ matrix.os }}
100-
strategy:
101-
fail-fast: false
102-
matrix:
103-
ghc: ["9.6.4"]
104-
os: ["ubuntu-20.04"]
86+
- name: Print cabal.project.local
87+
shell: bash
88+
run: cat cabal.project.local
10589

106-
steps:
107-
- name: Get build artifacts
108-
uses: actions/download-artifact@v3
109-
with:
110-
name: kda-build-${{ matrix.os }}-${{ matrix.ghc }}
111-
path: .
90+
- name: Update package database
91+
shell: bash
92+
run: cabal update
11293

113-
- name: Create Dockerfile
94+
- name: Configure build / and freeze
11495
run: |
115-
chmod 755 kda
116-
export OS=${{ matrix.os }}
117-
cat > Dockerfile <<EOF
118-
FROM ubuntu:${OS#ubuntu-}
119-
LABEL com.chainweb.docker.image.compiler="ghc-${{ matrix.ghc }}"
120-
LABEL com.chainweb.docker.image.os="${OS}"
121-
RUN apt-get update && apt-get install -y ca-certificates libgmp10 libssl1.1 locales && rm -rf /var/lib/apt/lists/* && locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
122-
ENV LANG=en_US.UTF-8
123-
WORKDIR /home/kda
124-
COPY kda /usr/bin/
125-
ENTRYPOINT ["/usr/bin/kda"]
126-
EOF
96+
cabal build --dry-run
97+
cabal freeze
12798
128-
- name: Docker meta
129-
id: meta
130-
uses: docker/metadata-action@v3
131-
with:
132-
images: ghcr.io/kadena-io/kda-tool
133-
tags: |
134-
type=sha
135-
type=ref,event=branch
136-
type=ref,event=tag
137-
type=ref,event=pr
138-
139-
- name: Set up Docker Buildx
140-
uses: docker/setup-buildx-action@v1
141-
142-
- name: Cache Docker layers
143-
uses: actions/cache@v3
99+
- name: Generate cache key
100+
id: cache-key
101+
run: |
102+
grep -v '^index-state:' cabal.project.freeze > freeze-deps-only
103+
FREEZE_HASH=$(shasum freeze-deps-only | cut -d' ' -f1)
104+
echo "freeze-hash=$FREEZE_HASH" >> $GITHUB_OUTPUT
105+
rm freeze-deps-only
106+
107+
- name: Restore Cabal store
108+
id: restore-cabal
109+
uses: actions/cache/restore@v4
144110
with:
145-
path: /tmp/.buildx-cache
146-
key: ${{ runner.os }}-buildx-${{ github.sha }}
111+
path: ~/.cabal/store
112+
key: cabal-${{ matrix.os }}-${{ matrix.ghc }}-${{ steps.cache-key.outputs.freeze-hash }}
147113
restore-keys: |
148-
${{ runner.os }}-buildx-
114+
cabal-${{ matrix.os }}-${{ matrix.ghc }}
149115
150-
- name: Login to GitHub Container Registry
151-
uses: docker/login-action@v1
152-
with:
153-
registry: ghcr.io
154-
username: kadena-build
155-
password: ${{ secrets.GITHUB_TOKEN }}
116+
- name: Build dependencies
117+
if: steps.restore-cabal.outputs.cache-hit != 'true'
118+
shell: bash
119+
run: cabal build --only-dependencies
156120

157-
- name: Build and push
158-
id: docker_build
159-
uses: docker/build-push-action@v2
121+
- name: Cache Cabal store if necessary
122+
if: steps.restore-cabal.outputs.cache-hit != 'true'
123+
uses: actions/cache/save@v4
160124
with:
161-
push: true
162-
context: .
163-
file: ./Dockerfile
164-
tags: ${{ steps.meta.outputs.tags }}
165-
labels: ${{ steps.meta.outputs.labels }}
166-
cache-from: type=local,src=/tmp/.buildx-cache
167-
cache-to: type=local,dest=/tmp/.buildx-cache
125+
path: ~/.cabal/store
126+
key: cabal-${{ matrix.os }}-${{ matrix.ghc }}-${{ steps.cache-key.outputs.freeze-hash }}
127+
128+
- name: Build
129+
shell: bash
130+
run: cabal build
168131

132+
- name: Verify Binary Linking
133+
shell: bash
134+
if: "!contains(matrix.flags, '-build-tool')"
135+
run: cabal run exe:kda -- --version

.github/workflows/nix.yml

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

cabal.project

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,63 @@
11
packages: kda-tool.cabal
22

3+
program-options
4+
ghc-options: -Wno-missed-extra-shared-lib
5+
6+
if os(darwin)
7+
if arch(aarch64)
8+
package *
9+
extra-include-dirs:
10+
/opt/homebrew/include
11+
/opt/homebrew/opt/openssl/include
12+
extra-lib-dirs:
13+
/opt/homebrew/lib
14+
/opt/homebrew/opt/openssl/lib
15+
else
16+
package *
17+
extra-include-dirs:
18+
/opt/local/include
19+
/usr/local/opt/openssl/include
20+
extra-lib-dirs:
21+
/opt/local/lib
22+
/usr/local/opt/openssl/lib/
323
package pact
424
ghc-options: -Wwarn
525
-- avoid conflict with cryptonite during linking
626
flags: +cryptonite-ed25519 -build-tool +no-advice
727

828
source-repository-package
929
type: git
10-
location: https://github.com/kadena-io/HsYAML.git
11-
tag: b3c49dbceb39733dfc07c22f2097d3c74fc86e74
12-
--sha256: sha256-lnnUni7D949nM4faMrORMetZi5wJy2Qhchm9ne6Cqv8=
30+
location: https://github.com/kda-community/chainweb-api.git
31+
tag: 1b2de025cfdc09698bfb1ec3807cd85405d6a339
1332

1433
source-repository-package
1534
type: git
16-
location: https://github.com/kadena-io/HsYAML-aeson.git
17-
tag: 84292468200166b96ff4e8c7324ee01e6ab6d181
18-
--sha256: sha256-zaDcqwSs4ASb7PO3+E9oGzmSXlSt7bL1NiP0red7CiY=
35+
location: https://github.com/kda-community/pact-5.git
36+
tag: f9bb9979091f8eae658a804e88bf313b57c924be
1937

2038
source-repository-package
21-
type: git
22-
location: https://github.com/kadena-io/cardano-crypto.git
23-
tag: 4590efa638397e952a51a8994b5543e4ea3c1ecd
24-
--sha256: 0hl2n3bba5v2j0lmxhs7hs01z3aznh2bwf9cb434icq2g0bl8ms3
39+
type: git
40+
location: https://github.com/kda-community/pact-json.git
41+
tag: 1d260bfaa48312b54851057885de4c43c420e35f
2542

2643
source-repository-package
27-
type: git
28-
location: https://github.com/kadena-io/chainweb-api.git
29-
tag: 1b2de025cfdc09698bfb1ec3807cd85405d6a339
30-
--sha256: sha256-06jvD1kmkmthcRkyWhVLTbytwabghInxqXQD/Lm7kbA=
44+
type: git
45+
location: https://github.com/kda-community/kadena-ethereum-bridge.git
46+
tag: 8df1cff7f279750490fea8ff580294f3e5a3fcaf
47+
--sha256: sha256-HyWTEtw/dKQduXl5avRckS0oNc9Z5yxeUxvX09wDkDY=
3148

3249
source-repository-package
33-
type: git
34-
location: https://github.com/kadena-io/pact.git
35-
tag: a1c7906efbf32095883e71594a53a21162fbe5a7
36-
--sha256: sha256-Mtgz/ilxa81TDUoBKQv5x3BlOftFjNV1Ak0uYzSguNQ=
50+
type: git
51+
location: https://github.com/kda-community/ralist.git
52+
tag: fd79fc4454e1b703299ab0a2aa5dabd86c9cacfa
53+
3754

3855
source-repository-package
39-
type: git
40-
location: https://github.com/kadena-io/pact-json.git
41-
tag: 1d260bfaa48312b54851057885de4c43c420e35f
42-
--sha256: 0fzq4mzaszj5clvixx9mn1x6r4dcrnwvbl2znd0p5mmy5h2jr0hh
56+
type: git
57+
location: https://github.com/kda-community/HsYAML.git
58+
tag: b3c49dbceb39733dfc07c22f2097d3c74fc86e74
4359

4460
source-repository-package
45-
type: git
46-
location: https://github.com/kadena-io/kadena-ethereum-bridge.git
47-
tag: a32d901e4a79be62af9c27c01152c9a4c3912a62
48-
--sha256: sha256-xdawv/tdjh61MbJKcBqm9Fje36+gVljuZsAxOTX1gP0=
61+
type: git
62+
location: https://github.com/kda-community/HsYAML-aeson.git
63+
tag: 84292468200166b96ff4e8c7324ee01e6ab6d181

0 commit comments

Comments
 (0)