Skip to content

Commit 2427f08

Browse files
committed
Merge branch 'hiveos_integration' into main
2 parents ddae0b1 + c164c34 commit 2427f08

File tree

7 files changed

+205
-1
lines changed

7 files changed

+205
-1
lines changed

.github/workflows/ci.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ jobs:
5353
- name: Checkout sources
5454
uses: actions/checkout@v2
5555

56+
- name: Fix LibOpenCL on Linux
57+
if: runner.os == 'Linux'
58+
run: |
59+
sudo apt update
60+
sudo apt install ocl-icd-opencl-dev -y
61+
5662
- name: Fix CRLF on Windows
5763
if: runner.os == 'Windows'
5864
run: git config --global core.autocrlf false
@@ -126,6 +132,12 @@ jobs:
126132
- name: Checkout sources
127133
uses: actions/checkout@v2
128134

135+
- name: Fix LibOpenCL on Linux
136+
if: runner.os == 'Linux'
137+
run: |
138+
sudo apt update
139+
sudo apt install ocl-icd-opencl-dev -y
140+
129141
- name: Fix CRLF on Windows
130142
if: runner.os == 'Windows'
131143
run: git config --global core.autocrlf false

.github/workflows/deploy.yaml

+54-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
if: runner.os == 'Linux'
2222
run: |
2323
sudo apt update
24-
sudo apt install ocl-icd-opencl-dev
24+
sudo apt install ocl-icd-opencl-dev -y
2525
2626
- name: Check out code into the Go module directory
2727
uses: actions/checkout@v2
@@ -92,3 +92,56 @@ jobs:
9292
asset_path: "./${{ env.archive }}"
9393
asset_name: "${{ env.asset_name }}"
9494
asset_content_type: application/zip
95+
96+
intergrations:
97+
runs-on: ubuntu-18.04
98+
strategy:
99+
fail-fast: false
100+
matrix:
101+
# Build gnu-linux on ubuntu-18.04 and musl on ubuntu latest
102+
itegration: [ hiveos ]
103+
name: Integrating, ${{ matrix.itegration }}
104+
steps:
105+
- name: Fix LibOpenCL on Linux
106+
run: |
107+
sudo apt update
108+
sudo apt install ocl-icd-opencl-dev -y
109+
110+
- name: Check out code into the module directory
111+
uses: actions/checkout@v2
112+
113+
- name: Setup Rust
114+
uses: actions-rs/toolchain@v1
115+
with:
116+
profile: minimal
117+
toolchain: stable
118+
override: true
119+
120+
- name: Install CUDA Linux
121+
if: runner.os == 'Linux'
122+
uses: tmrlvi/cuda-toolkit@master
123+
with:
124+
cuda: '11.2.2'
125+
126+
- name: Build ${{ matrix.itegration }} Script
127+
run: |
128+
cargo build --target=x86_64-unknown-linux-gnu --release --all
129+
binary_name="kaspa-miner-${{ github.event.release.tag_name }}-linux-gnu-amd64"
130+
asset_name="kaspa-miner-${{ matrix.itegration }}"
131+
strip ./target/x86_64-unknown-linux-gnu/release/kaspa-miner
132+
mkdir ${asset_name}
133+
mv ./target/x86_64-unknown-linux-gnu/release/kaspa-miner ${asset_name}/${binary_name}
134+
mv ./target/x86_64-unknown-linux-gnu/release/libkaspa*.so ${asset_name}/
135+
bash integrations/${{ matrix.itegration }}/build.sh "${{ github.event.release.tag_name }}" "${binary_name}" "${asset_name}"
136+
echo "archive=${asset_name}.tgz" >> $GITHUB_ENV
137+
echo "asset_name=${asset_name}.tgz" >> $GITHUB_ENV
138+
139+
- name: Upload release asset
140+
uses: actions/upload-release-asset@v1
141+
env:
142+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143+
with:
144+
upload_url: ${{ github.event.release.upload_url }}
145+
asset_path: "./${{ env.archive }}"
146+
asset_name: "${{ env.asset_name }}"
147+
asset_content_type: application/zip

integrations/hiveos/build.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
integrations/hiveos/createmanifest.sh $1 $2
2+
mkdir $3
3+
cp h-manifest.conf integrations/hiveos/*.sh $2/* $3
4+
tar czvf $3.tgz $3

integrations/hiveos/createmanifest.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
####################################################################################
2+
###
3+
### kaspa-miner
4+
### https://github.com/tmrlvi/kaspa-miner/releases
5+
###
6+
### Hive integration: Merlin
7+
###
8+
####################################################################################
9+
10+
if [ "$#" -ne "2" ]
11+
then
12+
echo "No arguments supplied. Call using createmanifest.sh <VERSION_NUMBER> <MINER BINARY NAME>"
13+
exit
14+
fi
15+
cat > h-manifest.conf << EOF
16+
####################################################################################
17+
###
18+
### kaspa-miner
19+
### https://github.com/tmrlvi/kaspa-miner/releases
20+
###
21+
### Hive integration: Merlin
22+
###
23+
####################################################################################
24+
25+
# The name of the miner
26+
CUSTOM_NAME=kaspa-miner
27+
28+
# Optional version of your custom miner package
29+
CUSTOM_VERSION=$1
30+
CUSTOM_BUILD=0
31+
CUSTOM_MINERBIN=$2
32+
33+
# Full path to miner config file
34+
CUSTOM_CONFIG_FILENAME=/hive/miners/custom/$CUSTOM_NAME/config.ini
35+
36+
# Full path to log file basename. WITHOUT EXTENSION (don't include .log at the end)
37+
# Used to truncate logs and rotate,
38+
# E.g. /var/log/miner/mysuperminer/somelogname (filename without .log at the end)
39+
CUSTOM_LOG_BASENAME=/var/log/miner/$CUSTOM_NAME
40+
41+
WEB_PORT=3338
42+
EOF

integrations/hiveos/h-config.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
####################################################################################
2+
###
3+
### kaspa-miner
4+
### https://github.com/tmrlvi/kaspa-miner/releases
5+
###
6+
### Hive integration: Merlin
7+
###
8+
####################################################################################
9+
10+
#!/usr/bin/env bash
11+
[[ -e /hive/custom ]] && . /hive/custom/kaspa-miner/h-manifest.conf
12+
[[ -e /hive/miners/custom ]] && . /hive/miners/custom/kaspa-miner/h-manifest.conf
13+
conf=""
14+
conf+=" --kaspad-address=$CUSTOM_URL --mining-address $CUSTOM_TEMPLATE"
15+
16+
17+
[[ ! -z $CUSTOM_USER_CONFIG ]] && conf+=" $CUSTOM_USER_CONFIG"
18+
19+
echo "$conf"
20+
echo "$conf" > $CUSTOM_CONFIG_FILENAME
21+

integrations/hiveos/h-run.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
####################################################################################
2+
###
3+
### kaspa-miner
4+
### https://github.com/tmrlvi/kaspa-miner/releases
5+
###
6+
### Hive integration: Merlin
7+
###
8+
####################################################################################
9+
10+
#!/usr/bin/env bash
11+
12+
cd `dirname $0`
13+
14+
[ -t 1 ] && . colors
15+
16+
. h-manifest.conf
17+
18+
echo $CUSTOM_NAME
19+
echo $CUSTOM_LOG_BASENAME
20+
echo $CUSTOM_CONFIG_FILENAME
21+
22+
[[ -z $CUSTOM_LOG_BASENAME ]] && echo -e "${RED}No CUSTOM_LOG_BASENAME is set${NOCOLOR}" && exit 1
23+
[[ -z $CUSTOM_CONFIG_FILENAME ]] && echo -e "${RED}No CUSTOM_CONFIG_FILENAME is set${NOCOLOR}" && exit 1
24+
[[ ! -f $CUSTOM_CONFIG_FILENAME ]] && echo -e "${RED}Custom config ${YELLOW}$CUSTOM_CONFIG_FILENAME${RED} is not found${NOCOLOR}" && exit 1
25+
26+
27+
./$CUSTOM_MINERBIN $(< $CUSTOM_CONFIG_FILENAME) $@ 2>&1 | tee $CUSTOM_LOG_BASENAME.log
28+
29+

integrations/hiveos/h-stats.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
####################################################################################
2+
###
3+
### kaspa-miner
4+
### https://github.com/tmrlvi/kaspa-miner/releases
5+
###
6+
### Hive integration: Merlin
7+
###
8+
####################################################################################
9+
10+
#!/usr/bin/env bash
11+
12+
#######################
13+
# MAIN script body
14+
#######################
15+
16+
. /hive/miners/custom/kaspa-miner/h-manifest.conf
17+
stats_raw=`cat $CUSTOM_LOG_BASENAME.log | grep -w "hashrate" | tail -n 1 `
18+
19+
#Calculate miner log freshness
20+
21+
maxDelay=120
22+
time_now=`date +%T | awk -F: '{ print ($1 * 3600) + $2*60 + $3 }'`
23+
time_rep=`echo $stats_raw | awk -FT '{print $2}' | awk -FZ '{print $1}' | awk -F: '{ print (($1+1)*3600) + $2*60 + $3}'`
24+
diffTime=`echo $((time_now-time_rep)) | tr -d '-'`
25+
26+
if [ "$diffTime" -lt "$maxDelay" ]; then
27+
total_hashrate=`echo $stats_raw | awk '{print $7}' | cut -d "." -f 1,2 --output-delimiter='' | sed 's/$/0/'`
28+
if [[ $stats_raw == *"Ghash"* ]]; then
29+
total_hashrate=$(($total_hashrate*1000))
30+
fi
31+
stats=$(jq -nc \
32+
--argjson hs "[$total_hashrate]"\
33+
--arg ver "$CUSTOM_VERSION" \
34+
--arg ths "$total_hashrate" \
35+
'{ hs: $hs, hs_units: "khs", algo : "heavyhash", ver:$ver }')
36+
khs=$total_hashrate
37+
else
38+
khs=0
39+
stats="null"
40+
fi
41+
42+
[[ -z $khs ]] && khs=0
43+
[[ -z $stats ]] && stats="null"

0 commit comments

Comments
 (0)