Skip to content

Commit bdf2366

Browse files
build: simplifying Makefile (#226)
1 parent d8b9564 commit bdf2366

13 files changed

+50
-53
lines changed

.github/workflows/continuous-delivery.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
username: ${{ github.actor }}
4848
password: ${{ secrets.GITHUB_TOKEN }}
4949
- name: Publish Docker Image
50-
run: make publish-docker RELEASE="${GITHUB_REF_NAME}"
50+
run: make publish-docker RELEASE="${GITHUB_REF_NAME}"

.github/workflows/dogfood.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
ref: ${{ github.event.pull_request.head.sha }}
1717
fetch-depth: 0
1818
- name: Dogfooding Docker
19-
run: make dogfood-docker FROM="origin/${{ github.base_ref }}"
19+
run: make dogfood-docker FROM="origin/${{ github.base_ref }}"

Makefile

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,115 @@
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 end-to-end-test publish-binary publish-crate dogfood-docker publish-docker
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

36+
.PHONY: check-python-formatting
3237
check-python-formatting:
3338
docker build -t check-python-formatting -f ci/check-python-formatting.Dockerfile .
34-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) check-python-formatting
39+
docker run $(DOCKER_RUN_OPTS) check-python-formatting
40+
41+
# renovate: depName=ghcr.io/google/yamlfmt
42+
YAMLFMT_VERSION=0.17.2@sha256:fa6874890092db69f35ece6a50e574522cae2a59b6148a1f6ac6d510e5bcf3cc
3543

44+
.PHONY: check-yaml-formatting
3645
check-yaml-formatting:
37-
docker pull ghcr.io/google/yamlfmt:0.17.0
38-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/google/yamlfmt:0.17.0 -verbose -lint -dstar .github/workflows/*
46+
docker run $(DOCKER_RUN_OPTS) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -lint -dstar .github/workflows/*
3947

48+
.PHONY: fix-rust-formatting
4049
fix-rust-formatting:
4150
docker build -t fix-rust-formatting -f ci/fix-rust-formatting.Dockerfile .
42-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) fix-rust-formatting
51+
docker run $(DOCKER_RUN_WRITE_OPTS) fix-rust-formatting
4352

53+
.PHONY: fix-shell-formatting
4454
fix-shell-formatting:
45-
docker pull mvdan/shfmt:$(SHFMT_VERSION)
46-
docker run --rm -v $(PWD):/workspace -w /workspace -u $(UID):$(GID) mvdan/shfmt:$(SHFMT_VERSION) --simplify --write ci/*
55+
docker run $(DOCKER_RUN_WRITE_OPTS) mvdan/shfmt:$(SHFMT_VERSION) --simplify --write ci/*
4756

57+
.PHONY: fix-python-formatting
4858
fix-python-formatting:
4959
docker build -t fix-python-formatting -f ci/fix-python-formatting.Dockerfile .
50-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) fix-python-formatting
51-
52-
# renovate: depName=ghcr.io/google/yamlfmt
53-
YAMLFMT_VERSION=0.17.2@sha256:fa6874890092db69f35ece6a50e574522cae2a59b6148a1f6ac6d510e5bcf3cc
60+
docker run $(DOCKER_RUN_WRITE_OPTS) fix-python-formatting
5461

62+
.PHONY: fix-yaml-formatting
5563
fix-yaml-formatting:
56-
docker pull ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION)
57-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -dstar .github/workflows/*
64+
docker run $(DOCKER_RUN_WRITE_OPTS) ghcr.io/google/yamlfmt:$(YAMLFMT_VERSION) -verbose -dstar .github/workflows/*
5865

66+
.PHONY: check-rust-linting
5967
check-rust-linting:
6068
docker build -t check-rust-linting -f ci/check-rust-linting.Dockerfile .
61-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) check-rust-linting
69+
docker run $(DOCKER_RUN_OPTS) check-rust-linting
6270

6371
# renovate: depName=rhysd/actionlint
6472
ACTIONLINT_VERSION=1.7.7@sha256:887a259a5a534f3c4f36cb02dca341673c6089431057242cdc931e9f133147e9
6573

74+
.PHONY: check-github-actions-workflows-linting
6675
check-github-actions-workflows-linting:
67-
docker pull rhysd/actionlint:$(ACTIONLINT_VERSION)
68-
docker run --rm -v $(PWD):/workspace -w /workspace -u $(UID):$(GID) rhysd/actionlint:$(ACTIONLINT_VERSION) -verbose -color
76+
docker run $(DOCKER_RUN_WRITE_OPTS) rhysd/actionlint:$(ACTIONLINT_VERSION) -verbose -color
6977

78+
.PHONY: compile
7079
compile:
7180
docker build -t compile -f ci/compile.Dockerfile .
72-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) compile
81+
docker run $(DOCKER_RUN_WRITE_OPTS) compile
7382

83+
.PHONY: unit-test
7484
unit-test:
7585
docker build -t unit-test -f ci/unit-test.Dockerfile .
76-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) unit-test
86+
docker run $(DOCKER_RUN_WRITE_OPTS) unit-test
7787

88+
.PHONY: end-to-end-test
7889
end-to-end-test: compile
7990
docker build -t end-to-end-test -f ci/end-to-end-test.Dockerfile .
80-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) end-to-end-test
91+
docker run $(DOCKER_RUN_WRITE_OPTS) -w /workspace/end-to-end-tests end-to-end-test
8192

93+
.PHONY: release
8294
release:
8395
docker build -t compile -f ci/compile.Dockerfile .
84-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) compile --release
96+
docker run $(DOCKER_RUN_WRITE_OPTS) compile --release
8597

98+
.PHONY: publish-binary
8699
publish-binary: release
87100
docker build -t publish-binary -f ci/publish-binary.Dockerfile .
88-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) -e GH_TOKEN publish-binary $(RELEASE)
101+
docker run $(DOCKER_RUN_WRITE_OPTS) -e GH_TOKEN publish-binary $(RELEASE)
89102

103+
.PHONY: publish-crate
90104
publish-crate:
91105
docker build -t publish-crate -f ci/publish-crate.Dockerfile .
92-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) -e CARGO_REGISTRY_TOKEN publish-crate
106+
docker run $(DOCKER_RUN_WRITE_OPTS) -e CARGO_REGISTRY_TOKEN publish-crate
93107

108+
.PHONY: dogfood-docker
94109
dogfood-docker: release
95-
docker build -t conventional-commits-linter -f Dockerfile .
96-
docker run --rm -v $(PWD):/workspace -u $(UID):$(GID) conventional-commits-linter --from-version v1.0.0 $(FROM)
110+
docker build -t conventional_commits_next_version -f Dockerfile .
111+
docker run $(DOCKER_RUN_WRITE_OPTS) conventional_commits_next_version --from-version v1.0.0 $(FROM)
97112

113+
.PHONY: publish-docker
98114
publish-docker: release
99115
./ci/publish-docker.sh ${RELEASE}

ci/check-python-formatting.Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ FROM python:3.13.5-alpine3.21@sha256:c9a09c45a4bcc618c7f7128585b8dd0d41d0c31a8a1
22
RUN apk add --no-cache \
33
py3-autopep8=2.1.0-r1
44

5-
WORKDIR /workspace
6-
75
ENTRYPOINT ["autopep8", "--exit-code", "--diff", "--aggressive", "--aggressive", "--max-line-length", "120", "--recursive"]
86
CMD ["."]
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/end-to-end-test.Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ RUN apk add --no-cache \
55
COPY end-to-end-tests/requirements.txt ./
66
RUN pip3 install -r requirements.txt
77

8-
WORKDIR /workspace/end-to-end-tests
98
ENTRYPOINT ["behave"]

ci/fix-python-formatting.Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ FROM python:3.13.5-alpine3.21@sha256:c9a09c45a4bcc618c7f7128585b8dd0d41d0c31a8a1
22
RUN apk add --no-cache \
33
py3-autopep8=2.1.0-r1
44

5-
WORKDIR /workspace
6-
75
ENTRYPOINT ["autopep8", "--in-place", "--aggressive", "--aggressive", "--max-line-length", "120", "--recursive"]
86
CMD ["."]

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"]

0 commit comments

Comments
 (0)