Skip to content

Commit dc04b70

Browse files
committed
build: improve make tasks
1 parent 0bb09c2 commit dc04b70

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
with:
4848
deno-version: "v1.x"
4949

50+
- run: make npm-ci
51+
5052
- run: make fetch-data
5153
env:
5254
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
@@ -145,6 +147,7 @@ jobs:
145147
run: |
146148
sed -i 's/enableGitInfo: true/# enableGitInfo: true/' exampleSite/config/_default/config.yaml
147149
150+
- run: make npm-ci
148151
- run: make docker-build
149152

150153
setup:

Makefile

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,65 @@
1-
pwd := $(CURDIR)
2-
cmd := ""
1+
cmd := "version"
2+
opt := ""
33
DOCKER_COMPOSE := docker compose
44
GH_USER_ID := peaceiris
5-
5+
HUGO_VERSION := $(shell cd ./deps && go mod edit -json | jq -r '.Require[] | select(.Path == "github.com/gohugoio/hugo") | .Version | split("v") | .[1]')
6+
GO_VERSION := $(shell cd ./deps && go mod edit -json | jq -r '.Go')
67

78
.PHONY: bump-node
89
bump-node:
910
bash scripts/bump_node.sh
1011

1112
.PHONY: npm-ci
1213
npm-ci:
14+
cd ./exampleSite && \
1315
npm ci
1416

1517
.PHONY: docker-dev
16-
docker-dev: npm-ci
17-
$(eval opt := server --navigateToChanged --bind=0.0.0.0 --buildDrafts)
18-
export HUGO_VERSION=$(shell make get-hugo-version) && \
18+
docker-dev:
19+
$(eval opt := --bind=0.0.0.0)
20+
export HUGO_VERSION=${HUGO_VERSION} && \
1921
$(DOCKER_COMPOSE) up -d && \
20-
$(DOCKER_COMPOSE) exec hugo hugo $(opt)
22+
$(DOCKER_COMPOSE) exec hugo make dev opt=$(opt) || \
23+
$(DOCKER_COMPOSE) down
2124

2225
.PHONY: docker-hugo
23-
docker-hugo: npm-ci
24-
# make docker-hugo cmd="version"
25-
export HUGO_VERSION=$(shell make get-hugo-version) && \
26+
docker-hugo:
27+
@echo 'usage: make docker-hugo cmd="version"'
28+
export HUGO_VERSION=${HUGO_VERSION} && \
2629
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(cmd)
2730

2831
.PHONY: docker-build
29-
docker-build: npm-ci
30-
$(eval opt := --minify --cleanDestinationDir)
31-
export HUGO_VERSION=$(shell make get-hugo-version) && \
32-
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(opt)
32+
docker-build:
33+
export HUGO_VERSION=${HUGO_VERSION} && \
34+
$(DOCKER_COMPOSE) run --rm --entrypoint=make hugo build-prod
3335

3436
.PHONY: docker-test
35-
docker-test: npm-ci
36-
$(eval opt := --minify --renderToMemory --printPathWarnings --debug \
37-
--templateMetrics --templateMetricsHints)
38-
export HUGO_VERSION=$(shell make get-hugo-version) && \
39-
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(opt)
40-
41-
.PHONY: npm-ci
42-
npm-ci:
43-
cd ./exampleSite && \
44-
npm ci
37+
docker-test:
38+
export HUGO_VERSION=${HUGO_VERSION} && \
39+
$(DOCKER_COMPOSE) run --rm --entrypoint=make hugo test
4540

4641
.PHONY: dev
47-
dev: npm-ci
42+
dev:
4843
cd ./exampleSite && \
49-
hugo server --renderStaticToDisk --navigateToChanged --buildDrafts
44+
hugo server --renderStaticToDisk --navigateToChanged --buildDrafts $(opt)
5045

5146
.PHONY: test
52-
test: npm-ci
47+
test:
5348
cd ./exampleSite && \
54-
hugo --minify --renderToMemory --printPathWarnings --debug \
55-
--templateMetrics --templateMetricsHints
49+
hugo --minify --debug --renderToMemory \
50+
--templateMetrics --templateMetricsHints \
51+
--printPathWarnings --printUnusedTemplates
5652

5753
.PHONY: build-staging
58-
build-staging: npm-ci
54+
build-staging:
5955
cd ./exampleSite && \
60-
hugo --minify --cleanDestinationDir \
56+
hugo --minify --debug --cleanDestinationDir \
6157
--environment "staging" \
62-
--printPathWarnings --debug \
63-
--templateMetrics --templateMetricsHints
58+
--templateMetrics --templateMetricsHints \
59+
--printPathWarnings --printUnusedTemplates
6460

6561
.PHONY: build-prod
66-
build-prod: npm-ci
62+
build-prod:
6763
cd ./exampleSite && \
6864
hugo --minify --cleanDestinationDir --printPathWarnings && \
6965
wget -O ./public/report.html ${BASE_URL}/report.html || true
@@ -76,8 +72,8 @@ fetch-data:
7672

7773
.PHONY: get-go-version
7874
get-go-version:
79-
@cd ./deps && go mod edit -json | jq -r '.Go'
75+
@echo ${GO_VERSION}
8076

8177
.PHONY: get-hugo-version
8278
get-hugo-version:
83-
@cd ./deps && go mod edit -json | jq -r '.Require[] | select(.Path == "github.com/gohugoio/hugo") | .Version | split("v") | .[1]'
79+
@echo ${HUGO_VERSION}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ services:
1111
- ${HUGO_CACHEDIR}:/tmp/hugo_cache
1212
stdin_open: true
1313
tty: true
14-
working_dir: /src/hugo-theme-iris/exampleSite
14+
working_dir: /src/hugo-theme-iris
1515
entrypoint: bash

0 commit comments

Comments
 (0)