-
Notifications
You must be signed in to change notification settings - Fork 15
/
justfile
79 lines (66 loc) · 2.03 KB
/
justfile
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
# SPDX-FileCopyrightText: 2023 Rivos Inc.
#
# SPDX-License-Identifier: Apache-2.0
build_dir := "./build"
coverage := "coverage"
vpython := "venv/bin/python3"
# default ld_library and include paths that work within container
ld_library := "/usr/lib64/lib/slurm"
include_path := "/usr/lib64/include"
set dotenv-load
set shell := ["bash", "-ceuo", "pipefail"]
# list all recipes
default:
just --list
init:
go mod tidy
rm -rf venv
python3 -m venv venv
{{vpython}} -m pip install -U pip pre-commit psutil requests
./venv/bin/pre-commit install --install-hooks
if ! [ -f .env ]; then printf "SLURM_LIB_DIR={{ld_library}}\nSLURM_INCLUDE_DIR={{include_path}}\n" > .env; fi
build:
rm -rf {{build_dir}}
mkdir {{build_dir}}
CGO_ENABLED=0 go build -o {{build_dir}}/slurm_exporter .
devel: build
{{build_dir}}/slurm_exporter \
-trace.enabled \
-slurm.cli-fallback \
-slurm.collect-limits \
-slurm.collect-diags \
-slurm.collect-licenses \
-slurm.squeue-cli "cat exporter/fixtures/squeue_fallback.txt" \
-slurm.sinfo-cli "cat exporter/fixtures/sinfo_fallback.txt" \
-slurm.diag-cli "cat exporter/fixtures/sdiag.json" \
-slurm.lic-cli "cat exporter/fixtures/license_out.json" \
-slurm.sacctmgr-cli "cat exporter/fixtures/sacctmgr.txt"
prod: build
{{build_dir}}/slurm_exporter -slurm.cli-fallback -web.listen-address :9093
test-exporter:
source venv/bin/activate && CGO_ENABLED=0 go test ./exporter
cover:
CGO_ENABLED=0 go test -coverprofile=c.out
go tool cover -html="c.out"
fmt:
go fmt
docker:
docker build -t slurmcprom .
test-all:
#!/bin/bash
set -aeuxo pipefail
CGO_CXXFLAGS="-I${SLURM_INCLUDE_DIR}"
CGO_LDFLAGS="-L${SLURM_LIB_DIR} -lslurmfull"
LD_LIBRARY_PATH="${SLURM_LIB_DIR}"
go test ./exporter ./slurmcprom
crun:
#!/bin/bash
set -aeuxo pipefail
rm -rf {{build_dir}}
mkdir -p {{build_dir}}
CGO_CXXFLAGS="-I${SLURM_INCLUDE_DIR}"
CGO_LDFLAGS="-L${SLURM_LIB_DIR} -lslurmfull"
POLL_LIMIT=1
LD_LIBRARY_PATH="${SLURM_LIB_DIR}"
go build -o {{build_dir}}/cexporter cmain.go
{{build_dir}}/cexporter