Skip to content

Commit 30ed7c4

Browse files
build: simplifying Makefile (#190)
1 parent d6d810a commit 30ed7c4

File tree

7 files changed

+30
-32
lines changed

7 files changed

+30
-32
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
- name: Checkout code.
4444
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4545
- name: Unit test.
46-
run: make unit-test
46+
run: make unit-test

Makefile

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,76 @@
1-
# So new files are owned by the user.
1+
DOCKER_RUN_OPTS := --rm -v $(PWD):/workspace -w /workspace
2+
23
UID := $(shell id -u)
34
GID := $(shell id -g)
5+
DOCKER_RUN_WRITE_OPTS := $(DOCKER_RUN_OPTS) -u $(UID):$(GID)
46

5-
.PHONY: check-clean-git-history check-conventional-commits-linting check-rust-formatting check-python-formatting check-yaml-formatting fix-rust-formatting fix-python-formatting fix-yaml-formatting check-rust-linting check-github-actions-workflows-linting compile unit-test static-binary-test end-to-end-test publish-binary publish-crate
7+
.PHONY: default
8+
default: compile
69

710
# renovate: depName=ghcr.io/developerc286/clean_git_history
811
CLEAN_GIT_HISTORY_VERSION=1.0.4@sha256:5783341a3377a723e409e72b9ec0826a75ba944288d030978355de05ef65b186
912

13+
.PHONY: check-clean-git-history
1014
check-clean-git-history:
11-
docker pull ghcr.io/developerc286/clean_git_history:$(CLEAN_GIT_HISTORY_VERSION)
12-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/developerc286/clean_git_history:$(CLEAN_GIT_HISTORY_VERSION) $(FROM)
15+
docker run $(DOCKER_RUN_WRITE_OPTS) ghcr.io/developerc286/clean_git_history:$(CLEAN_GIT_HISTORY_VERSION) $(FROM)
1316

1417
# renovate: depName=ghcr.io/developerc286/conventional_commits_linter
1518
CONVENTIONAL_COMMITS_LINTER_VERSION=0.15.0@sha256:b631a3cdcbed28c8938a2a6b63e16ecfd0d7ff71c28e878815adf9183e1fb599
1619

20+
.PHONY: check-conventional-commits-linting
1721
check-conventional-commits-linting:
18-
docker pull ghcr.io/developerc286/conventional_commits_linter:$(CONVENTIONAL_COMMITS_LINTER_VERSION)
19-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/developerc286/conventional_commits_linter:$(CONVENTIONAL_COMMITS_LINTER_VERSION) --allow-angular-type-only $(FROM)
22+
docker run $(DOCKER_RUN_WRITE_OPTS) ghcr.io/developerc286/conventional_commits_linter:$(CONVENTIONAL_COMMITS_LINTER_VERSION) --allow-angular-type-only $(FROM)
2023

24+
.PHONY: check-rust-formatting
2125
check-rust-formatting:
2226
docker build -t check-rust-formatting -f ci/check-rust-formatting.Dockerfile .
23-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) check-rust-formatting
27+
docker run $(DOCKER_RUN_OPTS) check-rust-formatting
2428

2529
# renovate: depName=mvdan/shfmt
2630
SHFMT_VERSION=v3.11.0-alpine@sha256:394d755b6007056a2e6d7537ccdbdcfca01b9855ba91e99df0166ca039c9d422
2731

32+
.PHONY: check-shell-formatting
2833
check-shell-formatting:
29-
docker pull mvdan/shfmt:$(SHFMT_VERSION)
30-
docker run --rm -v $(PWD):/workspace -w /workspace -u $(UID):$(GID) mvdan/shfmt:$(SHFMT_VERSION) --simplify --diff ci/*
34+
docker run $(DOCKER_RUN_OPTS) mvdan/shfmt:$(SHFMT_VERSION) --simplify --diff ci/*
3135

3236
# renovate: depName=ghcr.io/google/yamlfmt
3337
YAMLFMT_VERSION=0.17.2@sha256:fa6874890092db69f35ece6a50e574522cae2a59b6148a1f6ac6d510e5bcf3cc
3438

39+
.PHONY: check-yaml-formatting
3540
check-yaml-formatting:
36-
docker pull ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION)
37-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -lint -dstar .github/workflows/*
41+
docker run $(DOCKER_RUN_OPTS) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -lint -dstar .github/workflows/*
3842

43+
.PHONY: fix-rust-formatting
3944
fix-rust-formatting:
4045
docker build -t fix-rust-formatting -f ci/fix-rust-formatting.Dockerfile .
41-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) fix-rust-formatting
46+
docker run $(DOCKER_RUN_WRITE_OPTS) fix-rust-formatting
4247

48+
.PHONY: fix-shell-formatting
4349
fix-shell-formatting:
44-
docker pull mvdan/shfmt:$(SHFMT_VERSION)
45-
docker run --rm -v $(PWD):/workspace -w /workspace -u $(UID):$(GID) mvdan/shfmt:$(SHFMT_VERSION) --simplify --write ci/*
50+
docker run $(DOCKER_RUN_WRITE_OPTS) mvdan/shfmt:$(SHFMT_VERSION) --simplify --write ci/*
4651

52+
.PHONY: fix-yaml-formatting
4753
fix-yaml-formatting:
48-
docker pull ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION)
49-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -dstar .github/workflows/*
54+
docker run $(DOCKER_RUN_WRITE_OPTS) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -dstar .github/workflows/*
5055

56+
.PHONY: check-rust-linting
5157
check-rust-linting:
5258
docker build -t check-rust-linting -f ci/check-rust-linting.Dockerfile .
53-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) check-rust-linting
59+
docker run $(DOCKER_RUN_OPTS) check-rust-linting
5460

5561
# renovate: depName=rhysd/actionlint
5662
ACTIONLINT_VERSION=1.7.7@sha256:887a259a5a534f3c4f36cb02dca341673c6089431057242cdc931e9f133147e9
5763

64+
.PHONY: check-github-actions-workflows-linting
5865
check-github-actions-workflows-linting:
59-
docker pull rhysd/actionlint:$(ACTIONLINT_VERSION)
60-
docker run --rm -v $(PWD):/workspace -w /workspace -u $(UID):$(GID) rhysd/actionlint:$(ACTIONLINT_VERSION) -verbose -color
66+
docker run $(DOCKER_RUN_WRITE_OPTS) rhysd/actionlint:$(ACTIONLINT_VERSION) -verbose -color
6167

68+
.PHONY: compile
6269
compile:
6370
docker build -t compile -f ci/compile.Dockerfile .
64-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) compile
71+
docker run $(DOCKER_RUN_WRITE_OPTS) compile
6572

73+
.PHONY: unit-test
6674
unit-test:
6775
docker build -t unit-test -f ci/unit-test.Dockerfile .
68-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) unit-test
76+
docker run $(DOCKER_RUN_WRITE_OPTS) unit-test

ci/check-rust-formatting.Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
FROM rust:1.88.0-alpine3.21@sha256:9c6a4baf58661f99a5441b15e3ad8295dabf35e849c4935e77ad35d9809be1d2
22
RUN rustup component add rustfmt
33

4-
WORKDIR /workspace
5-
64
ENTRYPOINT ["cargo", "fmt", "--all", "--", "--check", "--config=group_imports=StdExternalCrate"]

ci/check-rust-linting.Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ RUN apk add --no-cache \
33
musl-dev=1.2.5-r9
44
RUN rustup component add clippy
55

6-
WORKDIR /workspace
7-
86
ENTRYPOINT ["cargo", "clippy", "--verbose", "--target=x86_64-unknown-linux-musl", "--locked", "--", "-D", "warnings"]

ci/compile.Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ FROM rust:1.88.0-alpine3.21@sha256:9c6a4baf58661f99a5441b15e3ad8295dabf35e849c49
22
RUN apk add --no-cache \
33
musl-dev=1.2.5-r9
44

5-
WORKDIR /workspace
6-
75
ENTRYPOINT ["cargo", "build", "--target=x86_64-unknown-linux-musl", "--locked"]

ci/fix-rust-formatting.Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
FROM rust:1.88.0-alpine3.21@sha256:9c6a4baf58661f99a5441b15e3ad8295dabf35e849c4935e77ad35d9809be1d2
22
RUN rustup component add rustfmt
33

4-
WORKDIR /workspace
5-
64
ENTRYPOINT ["cargo", "fmt", "--all", "--", "--config=group_imports=StdExternalCrate"]

ci/unit-test.Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ FROM rust:1.88.0-alpine3.21@sha256:9c6a4baf58661f99a5441b15e3ad8295dabf35e849c49
22
RUN apk add --no-cache \
33
musl-dev=1.2.5-r9
44

5-
WORKDIR /workspace
6-
75
ENTRYPOINT ["cargo", "test", "--verbose", "--target=x86_64-unknown-linux-musl", "--locked"]

0 commit comments

Comments
 (0)