-
Notifications
You must be signed in to change notification settings - Fork 5
114 lines (98 loc) · 4.39 KB
/
Copy pathminingcore-image.yml
File metadata and controls
114 lines (98 loc) · 4.39 KB
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
name: Build Miningcore image (multi-arch)
on:
workflow_dispatch:
push:
branches: [main]
paths:
- "willitmod-dev-dgb/images/miningcore/**"
- ".github/workflows/miningcore-image.yml"
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout app store repo
uses: actions/checkout@v4
- name: Checkout upstream Miningcore source
uses: actions/checkout@v4
with:
repository: oliverw/miningcore
ref: a553f62301f44c6df80891e408b6526d1dd98692
path: _vendor/miningcore
fetch-depth: 0
- name: Ensure upstream checkout has a branch (GitVersion)
run: |
set -eux
cd _vendor/miningcore
git checkout -b axedgb-pinned
- name: Apply AxeDGB Miningcore patches
run: |
set -eux
cd _vendor/miningcore
git apply ../../willitmod-dev-dgb/images/miningcore/patches/axedgb-best-share.patch
git apply ../../willitmod-dev-dgb/images/miningcore/patches/axedgb-dgb-v9-compat.patch
# AxeDGB uses an older Postgres schema where blocks.status is INT (not TEXT).
# Upstream Miningcore uses TEXT comparisons in the /blocks API which 500s with:
# operator does not exist: integer = text
# Patch the paging queries to not filter by status (the app reads block history from Postgres directly).
python3 - <<'PY'
from pathlib import Path
path = Path("src/Miningcore/Persistence/Postgres/Repositories/BlockRepository.cs")
text = path.read_text(encoding="utf-8", errors="replace")
# 1) Pool-scoped paging query
old1 = '@"SELECT * FROM blocks WHERE poolid = @poolid AND status = ANY(@status)'
new1 = '@"SELECT * FROM blocks WHERE poolid = @poolid'
if old1 not in text:
raise SystemExit(f"expected query fragment not found: {old1}")
text = text.replace(old1, new1, 1)
# 2) Cluster-wide paging query
old2 = '@"SELECT * FROM blocks WHERE status = ANY(@status)'
new2 = '@"SELECT * FROM blocks'
if old2 not in text:
raise SystemExit(f"expected query fragment not found: {old2}")
text = text.replace(old2, new2, 1)
path.write_text(text, encoding="utf-8")
PY
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Read image tag
id: tag
run: |
echo "tag=$(cat willitmod-dev-dgb/images/miningcore/VERSION)" >> "$GITHUB_OUTPUT"
- name: Build and push (plain progress)
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
set -euo pipefail
set -x
if ! docker buildx build \
--progress=plain \
--platform linux/amd64,linux/arm64 \
-f ./willitmod-dev-dgb/images/miningcore/Dockerfile \
-t ghcr.io/willitmod/axedgb-miningcore:${TAG} \
--push \
./_vendor/miningcore 2>&1 | tee /tmp/buildx.log; then
# GitHub limits annotation size; keep this short and focused.
tail_msg="$(tail -n 80 /tmp/buildx.log | sed -e 's/%/%25/g' -e 's/\r/%0D/g' -e 's/$/%0A/g' | tr -d '\n')"
err_msg="$(grep -Ei '(^|[^a-z])error:|^ERROR:' /tmp/buildx.log | tail -n 80 | sed -e 's/%/%25/g' -e 's/\r/%0D/g' -e 's/$/%0A/g' | tr -d '\n')"
dotnet_ln="$(grep -n 'dotnet publish' /tmp/buildx.log | tail -n 1 | cut -d: -f1 || true)"
if [ -n "${dotnet_ln}" ]; then
start=$((dotnet_ln - 40)); if [ "${start}" -lt 1 ]; then start=1; fi
end=$((dotnet_ln + 120))
dotnet_ctx="$(sed -n "${start},${end}p" /tmp/buildx.log | tail -n 120)"
else
dotnet_ctx=""
fi
dotnet_ctx="$(printf '%s' "${dotnet_ctx}" | sed -e 's/%/%25/g' -e 's/\r/%0D/g' -e 's/$/%0A/g' | tr -d '\n')"
echo "::error title=buildx errors (last matches)::${err_msg}"
echo "::error title=dotnet publish context::${dotnet_ctx}"
echo "::error title=buildx tail (last 80 lines)::${tail_msg}"
exit 1
fi