forked from 256foundation/mujina
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
73 lines (60 loc) · 2.11 KB
/
justfile
File metadata and controls
73 lines (60 loc) · 2.11 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
_default:
@just --list --unsorted
[group('dev')]
fmt *args:
cargo fmt {{args}}
[group('dev')]
lint:
cargo clippy --release -- -D warnings
[group('dev')]
test:
cargo test
# Run all checks (before commit, push, merge, release)
[group('dev')]
@checks: (fmt "--check") lint test
[group('dev')]
run:
cargo run --bin mujina-minerd
BUILD_IMAGE := "mujina-build"
# Tag with a content hash of the Containerfile so we can detect
# staleness without rebuilding. This matters in CI where podman
# save/load doesn't preserve layer cache---podman build would
# rebuild from scratch even with a loaded image. The content-hash
# tag lets `podman image exists` skip the build entirely.
BUILD_TAG := `sha256sum build.Containerfile | cut -c1-12`
# Build the build toolchain image (skips if unchanged)
[group('container')]
build-image:
podman image exists {{BUILD_IMAGE}}:{{BUILD_TAG}} || \
podman build -t {{BUILD_IMAGE}}:{{BUILD_TAG}} -f build.Containerfile .
# Remove stale build toolchain images
[group('container')]
build-image-clean:
podman images --format '{{{{.Repository}}:{{{{.Tag}}' \
| grep '^{{BUILD_IMAGE}}:' \
| grep -v ':{{BUILD_TAG}}$' \
| xargs -r podman rmi
# Run a just recipe inside the build toolchain image
[group('container')]
in-container *args: build-image
mkdir -p .cache/cargo-registry .cache/cargo-git
podman run --rm \
-v "$(pwd)":/workspace:Z \
-v "$(pwd)/.cache/cargo-registry":/usr/local/cargo/registry \
-v "$(pwd)/.cache/cargo-git":/usr/local/cargo/git \
-w /workspace \
{{BUILD_IMAGE}}:{{BUILD_TAG}} \
just {{args}}
# The CI pipeline. This is what GitHub Actions runs.
[group('ci')]
ci: (in-container "checks")
[group('container')]
container-build tag=`git rev-parse --abbrev-ref HEAD`:
podman build -t mujina-minerd:{{tag}} -f Containerfile .
[group('container')]
container-push tag=`git rev-parse --abbrev-ref HEAD`:
podman tag mujina-minerd:{{tag}} ghcr.io/256foundation/mujina-minerd:{{tag}}
podman push ghcr.io/256foundation/mujina-minerd:{{tag}}
[group('setup')]
hooks:
./scripts/setup-hooks.sh