-
Notifications
You must be signed in to change notification settings - Fork 7
260 lines (243 loc) · 7.9 KB
/
applications.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Build and publish application binaries
on:
workflow_dispatch:
push:
paths:
- '**'
- '!.github/**'
- '.github/workflows/applications.yml'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["9.8.2", "9.10.1"]
cabal: ["3.12"]
os: ["ubuntu-20.04", "ubuntu-22.04", "macos-14"]
cabalcache: ["true"]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.kadena_cabal_cache_aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.kadena_cabal_cache_aws_secret_access_key }}
AWS_DEFAULT_REGION: us-east-1
# Aritfacts
ARTIFACT_BUCKET: kadena-cabal-cache
BINFILE: pact.${{ matrix.ghc }}.${{ matrix.os }}.${{ github.sha }}.tar.gz
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Needed for a certain test
- name: Download chain9 test file
run: |
mkdir -p pact-tests/legacy-db-regression
curl -L https://chainweb-chain-db.s3.amazonaws.com/test-objects/pact-v1-chain-9.sqlite \
-o pact-tests/legacy-db-regression/pact-v1-chain-9.sqlite
# Haskell Setup
- name: Set permissions for .ghcup (ubuntu)
if: startsWith(matrix.os, 'ubuntu-')
run: sudo chown -R $USER /usr/local/.ghcup
- name: Install GHC and Cabal
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- name: Confirm GHC and Cabal installation
run: |
ghc --version
cabal --version
- name: Setting up MPFR (Ubuntu)
if: startsWith(matrix.os, 'ubuntu-')
shell: bash
run: sudo apt-get update && sudo apt-get install -y libmpfr-dev
# Project Setup
- name: Create cabal.project.local
shell: bash
run: |
cat > cabal.project.local <<EOF
documentation: False
package pact
tests: True
benchmarks: True
documentation: False
optimization: 1
flags: ${{ matrix.flags }} +cryptonite-ed25519
extra-include-dirs:
/opt/local/include
/usr/local/opt/openssl/include
extra-lib-dirs:
/opt/local/lib
/usr/local/opt/openssl/lib/
EOF
- name: Extend cabal.project.local for GHC-9.0.2
if: "startsWith(matrix.ghc, '9')"
shell: bash
run: |
cat >> cabal.project.local <<EOF
package pact
ghc-options: -Wwarn -Wunused-packages
EOF
- name: Add check for unused packages
shell: bash
run: |
cat >> cabal.project.local <<EOF
package pact
ghc-options: -Wunused-packages
EOF
- name: Print cabal.project.local
shell: bash
run: cat cabal.project.local
- uses: actions/cache@v3
name: Cache dist-newstyle
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ matrix.os }}-${{ matrix.ghc }}-4-cabal
# Build
- name: Update package database
shell: bash
run: cabal update
- name: Display outdated packages
run: cabal outdated
- name: Configure build
run: |
cabal build --dry-run
cabal freeze
- name: Sync with cabal cache
if: matrix.cabalcache == 'true'
uses: larskuhtz/cabal-cache-action@4b537195b33898fcd9adc62cee2a44986fd7b1b6
with:
bucket: "kadena-cabal-cache"
region: "us-east-1"
folder: "packages/${{ matrix.os }}"
aws_access_key_id: "${{ secrets.kadena_cabal_cache_aws_access_key_id }}"
aws_secret_access_key: "${{ secrets.kadena_cabal_cache_aws_secret_access_key }}"
- name: Build dependencies
shell: bash
run: cabal build --only-dependencies
- name: Build
shell: bash
run: cabal build
- name: Test
shell: bash
run: cabal run tests
- name: Verify Binary Linking
shell: bash
if: "!contains(matrix.flags, '-build-tool')"
run: cabal run exe:pact -- --version
# Publish Artifacts
- name: Prepare artifacts
if: "!contains(matrix.flags, '-build-tool')"
shell: bash
run: |
export VER=$(grep '^version' pact-tng.cabal | sed -e 's/.*: *//')
mkdir -p artifacts/pact
cp $(cabal list-bin pact) artifacts/pact
cp CHANGELOG.md artifacts/pact
cp README.md artifacts/pact
cp LICENSE artifacts/pact
cp pact-tng.cabal artifacts/pact
cp cabal.project artifacts/pact
cp cabal.project.local artifacts/pact
cp cabal.project.freeze artifacts/pact
- name: Publish applications
if: "!contains(matrix.flags, '-build-tool')"
uses: actions/upload-artifact@v3
with:
name: pact-applications.${{ matrix.ghc }}.${{ matrix.os }}
path: artifacts/pact
# Publish to S3
- name: Publish applications to S3
if: "!contains(matrix.flags, '-build-tool')"
shell: bash
run: |
tar -C ./artifacts/pact/ -czf $BINFILE '.'
echo "created tar file: $BINFILE"
ls $BINFILE
aws s3 cp $BINFILE s3://$ARTIFACT_BUCKET/pact/
echo "uploaded tar file to S3"
aws s3api put-object-acl --bucket $ARTIFACT_BUCKET --key=pact/$BINFILE --acl public-read
echo "set public read permission"
# ########################################################################## #
# Build and publish docker image
docker-image:
name: Build and publish docker image
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- ghc: "9.10.1"
os: "ubuntu-22.04"
env:
OS: ${{ matrix.os }}
steps:
- name: Get build artifacts
uses: actions/download-artifact@v3
with:
name: pact-applications.${{ matrix.ghc }}.${{ matrix.os }}
path: pact
- name: Create Dockerfile
run: |
chmod 755 pact/pact
cat > Dockerfile <<EOF
FROM ubuntu:${OS#ubuntu-}
LABEL com.pact.docker.image.compiler="ghc-${{ matrix.ghc }}"
LABEL com.pact.docker.image.os="${{ matrix.os }}"
RUN apt-get update && apt-get install -y ca-certificates libgmp10 libmpfr-dev libssl3 zlib1g 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
ENV LANG=en_US.UTF-8
WORKDIR /pact
COPY pact/pact .
COPY pact/LICENSE .
COPY pact/README.md .
COPY pact/CHANGELOG.md .
COPY pact/pact-tng.cabal .
COPY pact/cabal.project .
COPY pact/cabal.project.local .
COPY pact/cabal.project.freeze .
STOPSIGNAL SIGTERM
ENTRYPOINT [ "/pact/pact" ]
EOF
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/kadena-io/pact-5
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: kadena-build
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
context: .
file: ./Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
nightly:
if: github.ref == 'refs/heads/master'
needs: [docker-image]
uses: kadena-io/pact-5/.github/workflows/release-manual.yml@master
secrets: inherit