Skip to content

Commit

Permalink
ci: Set HUGO_MODULE_REPLACEMENTS (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
peaceiris authored May 28, 2021
1 parent 5ef2180 commit be4263a
Show file tree
Hide file tree
Showing 11 changed files with 1,525 additions and 1,439 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
HUGO_VERSION=0.83.1
HUGO_CACHEDIR=~/.hugo_cache
HUGO_MODULE_REPLACEMENTS='replace github.com/peaceiris/hugo-theme-iris -> ../'
BASE_URL=https://hugothemeiris.peaceiris.app
25 changes: 9 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
schedule:
- cron: "13 13 * * *"

env:
HUGO_CACHEDIR: /tmp/hugo_cache

jobs:
deploy:
runs-on: ubuntu-18.04
Expand All @@ -35,7 +38,7 @@ jobs:

- uses: actions/[email protected]
with:
path: /tmp/hugo_cache
path: ${{ env.HUGO_CACHEDIR }}
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-hugomod-
Expand All @@ -58,18 +61,11 @@ jobs:
timeout-minutes: 1

- name: Build
working-directory: ./exampleSite
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export BASE_URL="https://hugothemeiris.peaceiris.app"
export GH_USER_ID="peaceiris"
bash ./scripts/fetch_data.sh "${GH_USER_ID}" > "./data/github/${GH_USER_ID}.json"
hugo --minify --cleanDestinationDir \
--themesDir ../../ \
--baseURL "${BASE_URL}" \
--i18n-warnings --path-warnings
wget -O ./public/report.html "${BASE_URL}/report.html" || true
make cibuild-prod
- name: Deploy
uses: peaceiris/[email protected]
Expand Down Expand Up @@ -131,20 +127,17 @@ jobs:

- uses: actions/[email protected]
with:
path: /tmp/hugo_cache
path: ${{ env.HUGO_CACHEDIR }}
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-hugomod-
- name: Build Testing with Docker
run: |
export HUGO_CACHEDIR=/tmp/hugo_cache
make build
- run: make build

test-setup:
runs-on: ubuntu-18.04
timeout-minutes: 2
if: github.event_name == 'push' || github.event_name == 'pull_request'
if: github.ref == 'refs/heads/main'
strategy:
matrix:
extended:
Expand All @@ -167,7 +160,7 @@ jobs:

- uses: actions/[email protected]
with:
path: /tmp/hugo_cache
path: ${{ env.HUGO_CACHEDIR }}
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-hugomod-
Expand Down
30 changes: 19 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
include .env

pwd := $(CURDIR)
cmd := ""
DOCKER_COMPOSE := docker-compose
OPEN_BROWSER := open http://localhost:1313
BASE_URL := https://hugothemeiris.peaceiris.app/
GH_USER_ID := $(GH_USER_ID)


.PHONY: up
up:
# $(OPEN_BROWSER)
$(DOCKER_COMPOSE) up -d
$(DOCKER_COMPOSE) exec hugo hugo \
server --navigateToChanged --bind=0.0.0.0 --buildDrafts --themesDir ../../ --i18n-warnings
server --navigateToChanged --bind=0.0.0.0 --buildDrafts --i18n-warnings

.PHONY: npm-up
npm-up:
cd ./exampleSite && \
hugo server --navigateToChanged --buildDrafts --themesDir ../../ --i18n-warnings
hugo server --navigateToChanged --buildDrafts --i18n-warnings

.PHONY: hugo
hugo:
Expand All @@ -28,29 +28,29 @@ bumphugo:

.PHONY: build
build:
$(eval opt := --minify --themesDir ../../ --baseURL $(BASE_URL) --cleanDestinationDir)
$(eval opt := --minify --baseURL $(BASE_URL) --cleanDestinationDir)
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(opt)

.PHONY: npm-build
npm-build:
cd ./exampleSite && \
hugo --minify --themesDir ../../ --baseURL $(BASE_URL) --cleanDestinationDir
hugo --minify --baseURL $(BASE_URL) --cleanDestinationDir

.PHONY: test
test:
$(eval opt := --minify --themesDir ../../ --baseURL $(BASE_URL) \
$(eval opt := --minify --baseURL $(BASE_URL) \
--renderToMemory --i18n-warnings --path-warnings --debug)
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(opt)

.PHONY: npm-test
npm-test:
cd ./exampleSite && \
hugo --minify --themesDir ../../ --baseURL $(BASE_URL) \
hugo --minify --baseURL $(BASE_URL) \
--renderToMemory --i18n-warnings --path-warnings --debug

.PHONY: metrics
metrics:
$(eval opt := --minify --themesDir ../../ --baseURL $(BASE_URL) \
$(eval opt := --minify --baseURL $(BASE_URL) \
--renderToMemory --i18n-warnings --path-warnings --debug \
--templateMetrics --templateMetricsHints)
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(opt)
Expand All @@ -59,8 +59,16 @@ metrics:
cibuild:
cd ./exampleSite && \
hugo --minify \
--themesDir ../../ \
--baseURL '/' \
--cleanDestinationDir \
--i18n-warnings --path-warnings --debug \
--templateMetrics --templateMetricsHints

.PHONY: cibuild-prod
cibuild-prod:
cd ./exampleSite && \
bash ./scripts/fetch_data.sh ${GH_USER_ID} > ./data/github/${GH_USER_ID}.json && \
hugo --minify --cleanDestinationDir \
--baseURL ${BASE_URL} \
--i18n-warnings --path-warnings && \
wget -O ./public/report.html ${BASE_URL}/report.html || true
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ services:
volumes:
- ${PWD}:/src/hugo-theme-iris
- ${HUGO_CACHEDIR}:/tmp/hugo_cache
environment:
- HUGO_MODULE_REPLACEMENTS
stdin_open: true
tty: true
working_dir: /src/hugo-theme-iris/exampleSite
Expand Down
Empty file added exampleSite/data/github/.json
Empty file.
4 changes: 1 addition & 3 deletions exampleSite/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ module github.com/peaceiris/hugo-theme-iris/exampleSite

go 1.15

require github.com/peaceiris/hugo-theme-iris v0.30.1 // indirect

replace github.com/peaceiris/hugo-theme-iris => ../
require github.com/peaceiris/hugo-theme-iris v0.31.3 // indirect
6 changes: 2 additions & 4 deletions exampleSite/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ github.com/jgthms/bulma v0.0.0-20210126190202-c5edaea84f28 h1:l23nUHHqgeVca6FSjU
github.com/jgthms/bulma v0.0.0-20210126190202-c5edaea84f28/go.mod h1:89FLBKXYFKfOKAoDeUT26V0pHGwzr205cMXAEqtAVOI=
github.com/mathjax/MathJax v0.0.0-20210423185613-be11806df1ae h1:MRvvIZfWnWglW4eQLZi+nYQgYBq7oueB82zfSisN5LQ=
github.com/mathjax/MathJax v0.0.0-20210423185613-be11806df1ae/go.mod h1:bgp6XP7Dtl25/x6vVIPVe2mkOCrg8wMk/A9gl0FzJLA=
github.com/mermaid-js/mermaid v8.8.5-0.20210318200249-a5cc75c1f7b7+incompatible h1:PS+QyQUZ8TqGSrBZmuyjcn6Fl3oTWDLugUVbMZ8DEgs=
github.com/mermaid-js/mermaid v8.8.5-0.20210318200249-a5cc75c1f7b7+incompatible/go.mod h1:pGJSm9DYANtp59DADJgNzFh1uIpkn5xaH3ZBdv1VNTI=
github.com/mermaid-js/mermaid v8.8.5-0.20210510161447-417428aceada+incompatible h1:4Tj/rDuxLhM9qLSPb0Z3ijdgtF/a1+FDzTpJlISTQxc=
github.com/mermaid-js/mermaid v8.8.5-0.20210510161447-417428aceada+incompatible/go.mod h1:pGJSm9DYANtp59DADJgNzFh1uIpkn5xaH3ZBdv1VNTI=
github.com/peaceiris/hugo-mod-bulma v0.2.0 h1:0Pyx3zT9+1nzYY5eT5JMmL+XGnhL1OFx7LTsSZbKOss=
github.com/peaceiris/hugo-mod-bulma v0.2.0/go.mod h1:sjw6OFwTiXqh6S26Wk6GYjlSlwgKjYZ06+Bj29FLIqQ=
github.com/peaceiris/hugo-mod-mathjax v0.1.3 h1:oHOnGDuw1EPS6N+BVvaZWYE7A/xs8uptVYocu9qgoio=
github.com/peaceiris/hugo-mod-mathjax v0.1.3/go.mod h1:32b9e8/O0oQvj5sfyvCSNHDnrVD4eDzni6x7dAYFPKk=
github.com/peaceiris/hugo-mod-mermaidjs v0.7.0 h1:xZrzeTxZQ7l1gstS0IhecGQJY5aFg55QQ657G1ssUzA=
github.com/peaceiris/hugo-mod-mermaidjs v0.7.0/go.mod h1:vLSaD5/vQovBDLEoSOtx+O/P0WQcOzqWqrNmim+iqjc=
github.com/peaceiris/hugo-mod-mermaidjs v0.9.0 h1:McUfF8bAmVYnQv1iX+7ds25e9L44o/49vEbFAHQ71wA=
github.com/peaceiris/hugo-mod-mermaidjs v0.9.0/go.mod h1:P49aHKrQgzZhguUe5Zd9rQDzsm4rzQZWyYMH7IGF8/I=
github.com/peaceiris/hugo-mod-revealjs v0.2.0 h1:uIdNBMhSiRujqaf7WHqcXb2qsmkodFVL1o2Vzm/aS6Q=
github.com/peaceiris/hugo-mod-revealjs v0.2.0/go.mod h1:j0j0jS675O/rIk2kBdyTbkQebg9wYSriFfDZG+SkHYs=
github.com/peaceiris/hugo-theme-iris v0.31.3 h1:VWFnSmKisXpwrcZYjxxE82PPkMeHlx0Nc8cnOf0eY1g=
github.com/peaceiris/hugo-theme-iris v0.31.3/go.mod h1:zZScs0rLDn9YU7RJ1sk1rGcLkGTDyq9/Qy3Rt/ikiAg=
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit be4263a

Please sign in to comment.