1010 SED ?= sed
1111endif
1212
13+
14+ ifeq ($(LYCHEE_GITHUB_TOKEN ) ,)
15+ LYCHEE_GITHUB_TOKEN_ARG :=
16+ else :
17+ LYCHEE_GITHUB_TOKEN_ARG := --env GITHUB_TOKEN=$(LYCHEE_GITHUB_TOKEN )
18+ endif
19+
1320TOOLS_DIR := $(PWD ) /internal/tools
1421
1522MARKDOWN_LINK_CHECK_ARG = # pass extra arguments such as --exclude '^http'
@@ -27,13 +34,15 @@ CONTAINER_REPOSITORY=docker.io
2734WEAVER_CONTAINER_REPOSITORY =$(CONTAINER_REPOSITORY )
2835SEMCONVGEN_CONTAINER_REPOSITORY =$(CONTAINER_REPOSITORY )
2936OPA_CONTAINER_REPOSITORY =$(CONTAINER_REPOSITORY )
37+ LYCHEE_CONTAINER_REPOSITORY =$(CONTAINER_REPOSITORY )
3038
3139# Versioned, non-qualified references to containers used in this Makefile.
3240# These are parsed from dependencies.Dockerfile so dependabot will autoupdate
3341# the versions of docker files we use.
3442VERSIONED_WEAVER_CONTAINER_NO_REPO =$(shell cat dependencies.Dockerfile | awk '$$4=="weaver" {print $$2}')
3543VERSIONED_SEMCONVGEN_CONTAINER_NO_REPO =$(shell cat dependencies.Dockerfile | awk '$$4=="semconvgen" {print $$2}')
3644VERSIONED_OPA_CONTAINER_NO_REPO =$(shell cat dependencies.Dockerfile | awk '$$4=="opa" {print $$2}')
45+ VERSIONED_LYCHEE_CONTAINER_NO_REPO =$(shell cat dependencies.Dockerfile | awk '$$4=="lychee" {print $$2}')
3746
3847# Fully qualified references to containers used in this Makefile. These
3948# include the container repository, so that the build will work with tools
@@ -46,7 +55,7 @@ VERSIONED_OPA_CONTAINER_NO_REPO=$(shell cat dependencies.Dockerfile | awk '$$4==
4655WEAVER_CONTAINER =$(WEAVER_CONTAINER_REPOSITORY ) /$(VERSIONED_WEAVER_CONTAINER_NO_REPO )
4756SEMCONVGEN_CONTAINER =$(SEMCONVGEN_CONTAINER_REPOSITORY ) /$(VERSIONED_SEMCONVGEN_CONTAINER_NO_REPO )
4857OPA_CONTAINER =$(OPA_CONTAINER_REPOSITORY ) /$(VERSIONED_OPA_CONTAINER_NO_REPO )
49-
58+ LYCHEE_CONTAINER = $( LYCHEE_CONTAINER_REPOSITORY ) / $( VERSIONED_LYCHEE_CONTAINER_NO_REPO )
5059
5160CHECK_TARGETS =install-tools markdownlint misspell table-check compatibility-check \
5261 schema-check check-file-and-folder-names-in-docs
@@ -121,22 +130,23 @@ normalized-link-check:
121130
122131.PHONY : markdown-link-check
123132markdown-link-check : normalized-link-check
124- # pinning lychee to 0.18.1
125133 $(DOCKER_RUN ) --rm \
126- --mount 'type=bind,source=$(PWD),target=/home/repo' \
127- lycheeverse/lychee:sha-2aa22f8 \
134+ $(DOCKER_USER_IS_HOST_USER_ARG ) \
135+ --mount ' type=bind,source=$(PWD),target=/home/repo' $(LYCHEE_GITHUB_TOKEN_ARG ) \
136+ $(LYCHEE_CONTAINER ) \
128137 --config home/repo/.lychee.toml \
129138 --root-dir /home/repo \
130139 --verbose \
140+ --timeout=60 \
131141 $(MARKDOWN_LINK_CHECK_ARG ) \
132142 home/repo
133143
134144.PHONY : markdown-link-check-changelog-preview
135145markdown-link-check-changelog-preview :
136- # pinning lychee to 0.18.1
137146 $(DOCKER_RUN ) --rm \
138- --mount 'type=bind,source=$(PWD),target=/home/repo' \
139- lycheeverse/lychee:sha-2aa22f8 \
147+ $(DOCKER_USER_IS_HOST_USER_ARG ) \
148+ --mount ' type=bind,source=$(PWD),target=/home/repo' $(LYCHEE_GITHUB_TOKEN_ARG ) \
149+ $(LYCHEE_CONTAINER ) \
140150 --config /home/repo/.lychee.toml \
141151 --root-dir /home/repo \
142152 --verbose \
@@ -212,6 +222,7 @@ attribute-registry-generation:
212222.PHONY : table-check
213223table-check :
214224 $(DOCKER_RUN ) --rm \
225+ $(DOCKER_USER_IS_HOST_USER_ARG) \
215226 --mount 'type=bind,source=$(PWD)/templates,target=/home/weaver/templates,readonly' \
216227 --mount 'type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
217228 --mount 'type=bind,source=$(PWD)/docs,target=/home/weaver/target,readonly' \
@@ -300,6 +311,10 @@ LATEST_RELEASED_SEMCONV_VERSION := $(shell git ls-remote --tags https://github.c
300311.PHONY : check-policies
301312check-policies :
302313 $(DOCKER_RUN ) --rm \
314+ $(DOCKER_USER_IS_HOST_USER_ARG ) \
315+ --env USER=weaver \
316+ --env HOME=/home/weaver \
317+ -v $(shell mktemp -d) :/home/weaver/.weaver \
303318 --mount ' type=bind,source=$(PWD)/policies,target=/home/weaver/policies,readonly' \
304319 --mount ' type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
305320 ${WEAVER_CONTAINER} registry check \
@@ -310,7 +325,7 @@ check-policies:
310325# Test rego policies
311326.PHONY : test-policies
312327test-policies :
313- $(DOCKER_RUN ) --rm -v $(PWD ) /policies:/policies -v $(PWD ) /policies_test:/policies_test \
328+ $(DOCKER_RUN ) --rm $( DOCKER_USER_IS_HOST_USER_ARG ) -v $(PWD ) /policies:/policies -v $(PWD ) /policies_test:/policies_test \
314329 ${OPA_CONTAINER} test \
315330 --var-values \
316331 --explain fails \
@@ -321,5 +336,5 @@ test-policies:
321336# once github action requirements are updated.
322337.PHONY : compatibility-check
323338compatibility-check :
324- $(DOCKER_RUN ) --rm -v $(PWD ) /model:/source -v $(PWD ) /docs:/spec --pull=always \
339+ $(DOCKER_RUN ) --rm $( DOCKER_USER_IS_HOST_USER_ARG ) -v $(PWD ) /model:/source -v $(PWD ) /docs:/spec --pull=always \
325340 $(SEMCONVGEN_CONTAINER ) --continue-on-validation-errors -f /source compatibility --previous-version $(LATEST_RELEASED_SEMCONV_VERSION )
0 commit comments