Skip to content

Commit

Permalink
ci(actions): Split out LuaRocks handling so it they can be cached
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jul 16, 2020
1 parent 0b3f6b6 commit f269da7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 43 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ jobs:
.fonts
.sources
key: fonts-${{ hashFiles('Makefile-fonts') }}
- name: Cache Lua Rocks
uses: actions/cache@v2
with:
path: |
lua_modules_dist
key: luarocks-${{ hashFiles('Makefile-luarocks', 'sile-dev-1.rockspec') }}
- name: Fetch Tags
run: git fetch --prune --tags
- name: Install System Dependencies
Expand Down
44 changes: 44 additions & 0 deletions Makefile-luarocks
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
SUPPORTED_LUAS = 5.3 5.2 5.1

LUAROCKS := luarocks --tree lua_modules --lua-version $(LUA_VERSION)

if !SYSTEM_LUAROCKS
nobase_nodist_pkgdata_DATA = $(LUAMODULES)
LUAMODLOCK := sile-dev-1.rockslock
LUAMODSPEC := sile-dev-1.rockspec
genrockslock := $(LUAROCKS) $(LUAROCKSARGS) list --porcelain | awk '{print $$1 " " $$2}'
rocksmatch := cmp -s $(LUAMODLOCK) <($(genrockslock))
endif

.PHONY: installrocks disallow-dist-with-system-luarocks
if !SYSTEM_LUAROCKS
installrocks: $(LUAMODLOCK) $(shell $(rocksmatch) || echo lua_modules)

lua_modules: $(LUAMODSPEC) $(shell $(rocksmatch) || echo force)
if test -e .git; then
$(LUAROCKS) $(LUAROCKSARGS) install --only-deps $<
else
rm -rf lua_modules
cp -a lua_modules_dist lua_modules
$(foreach LUA,$(filter-out $(LUA_VERSION),$(SUPPORTED_LUAS)),
find lua_modules -maxdepth 3 -type d -name "*$(LUA)" -execdir rm -rf {} \;)
fi

$(LUAMODLOCK): lua_modules $(LUAMODSPEC)
$(genrockslock) > $@

sile: installrocks

disallow-dist-with-system-luarocks: ;
else
disallow-dist-with-system-luarocks:
$(error In order to make dist you must configure --without-system-luarocks)
exit 1
endif

.PHONY: lua_modules_dist
lua_modules_dist: LUAROCKS = luarocks --tree lua_modules_dist
lua_modules_dist: $(LUAMODSPEC) force disallow-dist-with-system-luarocks
$(foreach LUA,$(SUPPORTED_LUAS),
$(LUAROCKS) $(LUAROCKSARGS) --lua-version $(LUA) install --only-deps $<)

46 changes: 3 additions & 43 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ else
SUBDIRS = libtexpdf src
endif

SUPPORTED_LUAS = 5.3 5.2 5.1

MANUAL = documentation/sile.pdf

Makefile-distfiles: build-aux/list-dist-files.sh .version
Expand All @@ -31,15 +29,6 @@ SHELL = bash
.DELETE_ON_ERROR:
am__remove_distdir =

LUAROCKS := luarocks --tree lua_modules --lua-version $(LUA_VERSION)
if !SYSTEM_LUAROCKS
nobase_nodist_pkgdata_DATA = $(LUAMODULES)
LUAMODLOCK := sile-dev-1.rockslock
LUAMODSPEC := sile-dev-1.rockspec
genrockslock := $(LUAROCKS) $(LUAROCKSARGS) list --porcelain | awk '{print $$1 " " $$2}'
rocksmatch := cmp -s $(LUAMODLOCK) <($(genrockslock))
endif

BUILT_SOURCES = .version

.version: $(shell test -e .git && awk '{print ".git/" $$2}' .git/HEAD)
Expand Down Expand Up @@ -109,38 +98,6 @@ update_libtexpdf:
gh-pages:
git worktree add -f $@ $@

.PHONY: installrocks disallow-dist-with-system-luarocks
if !SYSTEM_LUAROCKS
installrocks: $(LUAMODLOCK) $(shell $(rocksmatch) || echo lua_modules)

lua_modules: $(LUAMODSPEC) $(shell $(rocksmatch) || echo force)
if test -e .git; then
$(LUAROCKS) $(LUAROCKSARGS) install --only-deps $<
else
rm -rf lua_modules
cp -a lua_modules_dist lua_modules
$(foreach LUA,$(filter-out $(LUA_VERSION),$(SUPPORTED_LUAS)),
find lua_modules -maxdepth 3 -type d -name "*$(LUA)" -execdir rm -rf {} \;)
fi

$(LUAMODLOCK): lua_modules $(LUAMODSPEC)
$(genrockslock) > $@

sile: installrocks

disallow-dist-with-system-luarocks: ;
else
disallow-dist-with-system-luarocks:
$(error In order to make dist you must configure --without-system-luarocks)
exit 1
endif

.PHONY: lua_modules_dist
lua_modules_dist: LUAROCKS = luarocks --tree lua_modules_dist
lua_modules_dist: $(LUAMODSPEC) force disallow-dist-with-system-luarocks
$(foreach LUA,$(SUPPORTED_LUAS),
$(LUAROCKS) $(LUAROCKSARGS) --lua-version $(LUA) install --only-deps $<)

DEPDIR := .deps
REGRESSIONSCRIPT := ./tests/regressions.pl
LOCALTESTFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf
Expand Down Expand Up @@ -370,6 +327,9 @@ include $(wildcard $(DEPFILES))
# Actual rules for downloading test fonts are in a separate file
include Makefile-fonts

# All LuaRocks handling stuff consolidated
include Makefile-luarocks

CLEANFILES = $(bin_SCRIPTS) $(dist_man_MANS) $(DEPFILES) $(ACTUALS) $(TESTPDFS) $(MANUAL) Makefile-distfiles

.PHONY: docker
Expand Down

0 comments on commit f269da7

Please sign in to comment.