Skip to content

Commit 3b3f2da

Browse files
committed
Resolve conflicts
2 parents c27c1db + 3c868b1 commit 3b3f2da

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
bin/
2+
go/
23
*.snap

DEVELOPMENT.md

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# Development
2+
13
Setup the development environment on a node with access to the Slurm user
24
command-line interface, in particular with the `sinfo`, `squeue`, and `sdiag`
35
commands.
46

5-
### Install Go from source
7+
## Install Go from source
68

79
```bash
810
export VERSION=1.15 OS=linux ARCH=amd64
@@ -13,51 +15,40 @@ export PATH=$PWD/go/bin:$PATH
1315

1416
_Alternatively install Go using the packaging system of your Linux distribution._
1517

16-
Use Git to clone the source code of the exporter, and download all Go dependency
17-
modules:
18+
## Clone this repository and build
19+
20+
Use Git to clone the source code of the exporter, run all the tests and build the binary:
1821

1922
```bash
2023
# clone the source code
2124
git clone https://github.com/vpenso/prometheus-slurm-exporter.git
2225
cd prometheus-slurm-exporter
23-
# download dependencies
24-
export GOPATH=$PWD/go/modules
25-
go mod download
26-
```
27-
28-
### Build
29-
30-
Build the exporter:
31-
32-
```bash
33-
go build -o bin/prometheus-slurm-exporter {main,accounts,cpus,gpus,partitions,node,nodes,queue,scheduler,sshare,users}.go
26+
make
3427
```
3528

36-
Run all tests included in `_test.go` files:
29+
To just run the tests:
3730

3831
```bash
39-
go test -v *.go
32+
make test
4033
```
4134

4235
Start the exporter (foreground), and query all metrics:
4336

4437
```bash
45-
bin/prometheus-slurm-exporter
38+
./bin/prometheus-slurm-exporter
4639
```
4740

4841
If you wish to run the exporter on a different port, or the default port (8080) is already in use, run with the following argument:
4942

5043
```bash
51-
bin/prometheus-slurm-exporter --listen-address="0.0.0.0:<port>"
44+
./bin/prometheus-slurm-exporter --listen-address="0.0.0.0:<port>"
5245
...
5346

5447
# query all metrics (default port)
5548
curl http://localhost:8080/metrics
5649
```
5750

58-
### Development
59-
60-
References:
51+
## References
6152

6253
* [GOlang Package Documentation](https://godoc.org/github.com/prometheus/client_golang/prometheus)
6354
* [Metric Types](https://prometheus.io/docs/concepts/metric_types/)

Makefile

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
PROJECT_NAME = prometheus-slurm-exporter
2-
ifndef GOPATH
3-
GOPATH=$(shell pwd):/usr/share/gocode
4-
endif
5-
GOFILES=accounts.go cpus.go gpus.go main.go node.go nodes.go partitions.go queue.go scheduler.go sshare.go users.go
6-
GOBIN=bin/$(PROJECT_NAME)
2+
SHELL := $(shell which bash) -eu -o pipefail
73

8-
build:
9-
mkdir -p $(shell pwd)/bin
10-
@echo "Build $(GOFILES) to $(GOBIN)"
11-
@GOPATH=$(GOPATH) go build -o $(GOBIN) $(GOFILES)
4+
GOPATH := $(shell pwd)/go/modules
5+
GOBIN := bin/$(PROJECT_NAME)
6+
GOFILES := $(shell ls *.go)
127

13-
test:
14-
@GOPATH=$(GOPATH) go test -v *.go
8+
.PHONY: build
9+
build: test $(GOBIN)
1510

16-
run:
17-
@GOPATH=$(GOPATH) go run $(GOFILES)
11+
$(GOBIN): go/modules/pkg/mod $(GOFILES)
12+
mkdir -p bin
13+
@echo "Building $(GOBIN)"
14+
go build -v -o $(GOBIN)
15+
16+
go/modules/pkg/mod: go.mod
17+
go mod download
18+
19+
.PHONY: test
20+
test: go/modules/pkg/mod $(GOFILES)
21+
go test -v
22+
23+
run: $(GOBIN)
24+
$(GOBIN)
1825

1926
clean:
20-
if [ -f ${GOBIN} ] ; then rm -f ${GOBIN} ; fi
27+
go clean -modcache
28+
rm -fr bin/ go/

0 commit comments

Comments
 (0)