Skip to content

Commit 9a660b5

Browse files
authored
build: reduces makefile boilerplate (#219)
1 parent 22e38c7 commit 9a660b5

File tree

6 files changed

+57
-56
lines changed

6 files changed

+57
-56
lines changed

.github/workflows/site.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ jobs:
2121
- run: make deps
2222
- run: make dev
2323
- run: make docs
24-
- run: |
25-
preview_url=$(make deploy | jq '.deploy_url' | tail -n 1 | tr -d '"')
26-
echo "# 🚀 Site Preview" >> $GITHUB_STEP_SUMMARY
27-
echo "$preview_url" >> $GITHUB_STEP_SUMMARY
24+
- id: preview
2825
working-directory: docs
2926
env:
3027
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
28+
run: |
29+
preview_url=$(make deploy | jq '.deploy_url' | tail -n 1 | tr -d '"')
30+
echo "# 🚀 Site Preview" >> $GITHUB_STEP_SUMMARY
31+
echo "$preview_url" >> $GITHUB_STEP_SUMMARY

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUN apt-get update && apt-get install -y make
44

55
WORKDIR /sdk
66

7-
COPY requirements.txt requirements-dev.txt Makefile ./
7+
COPY requirements.txt requirements-dev.txt vars.mk Makefile ./
88

99
RUN make deps
1010

Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
.DEFAULT_GOAL := all
2-
3-
NAME := posit-sdk
4-
PYTHON := python3
1+
include vars.mk
52

6-
ifneq ($(shell command -v uv 2>/dev/null),)
7-
PIP := uv pip
8-
else
9-
PIP := pip3
10-
endif
3+
.DEFAULT_GOAL := all
114

125
.PHONY: build clean cov default deps dev docs fmt fix install it lint test uninstall version
136

@@ -17,6 +10,8 @@ build:
1710
$(PYTHON) -m build
1811

1912
clean:
13+
$(MAKE) -C ./docs $@
14+
$(MAKE) -C ./integration $@
2015
rm -rf .coverage .mypy_cache .pytest_cache .ruff_cache *.egg-info build coverage.xml dist htmlcov coverage.xml
2116
find . -name "*.egg-info" -exec rm -rf {} +
2217
find . -name "*.pyc" -exec rm -f {} +

docs/Makefile

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
.DEFAULT_GOAL := all
1+
include ../vars.mk
2+
3+
VERSION := $(shell $(MAKE) -C ../ -s version)
24

3-
# Command aliases
4-
PIP ?= pip3
5-
QUARTO ?= quarto
6-
QUARTODOC ?= quartodoc
7-
8-
# Environment variables
9-
NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee
10-
CURRENT_YEAR ?= $(shell date +%Y)
11-
VERSION ?= $(shell make --silent -C ../ version | tail -n 1)
12-
ENV ?= dev
13-
14-
# Determine Netlify arguments from environment
15-
ifeq ($(ENV), prod)
16-
NETLIFY_ARGS := --prod
17-
else
18-
NETLIFY_ARGS :=
19-
endif
20-
21-
# Determine if `uv` is available
22-
ifneq ($(shell command -v uv 2>/dev/null),)
23-
PIP := uv pip
24-
else
25-
PIP := pip3
26-
endif
5+
.DEFAULT_GOAL := all
276

287
.PHONY: all \
298
api \

integration/Makefile

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
include ../vars.mk
2+
13
.DEFAULT_GOAL := all
24

35
.PHONY: $(CONNECT_VERSIONS) \
@@ -29,23 +31,6 @@ CONNECT_VERSIONS := 2024.05.0 \
2931
2022.12.0 \
3032
2022.11.0
3133

32-
# Environment Variables
33-
NAME = posit-sdk
34-
IMAGE_TAG ?= posit-sdk-py:latest
35-
CONNECT_BOOTSTRAP_SECRETKEY ?= $(shell head -c 32 /dev/random | base64)
36-
CONNECT_IMAGE ?= rstudio/rstudio-connect
37-
38-
# Binaries
39-
DOCKER_COMPOSE ?= docker compose
40-
PYTHON ?= python3
41-
42-
# Determine if `uv` is available
43-
ifneq ($(shell command -v uv 2>/dev/null),)
44-
PIP := uv pip
45-
else
46-
PIP := pip3
47-
endif
48-
4934
clean:
5035
rm -rf logs reports
5136
find . -type d -empty -delete

vars.mk

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Makefile variables file.
2+
#
3+
# Variables shared across project Makefiles via 'include vars.mk'.
4+
#
5+
# - ./Makefile
6+
# - ./docs/Makefile
7+
# - ./integration/Makefile
8+
9+
CONNECT_BOOTSTRAP_SECRETKEY ?= $(shell head -c 32 /dev/random | base64)
10+
11+
CONNECT_IMAGE ?= rstudio/rstudio-connect
12+
13+
CURRENT_YEAR ?= $(shell date +%Y)
14+
15+
DOCKER_COMPOSE ?= docker compose
16+
17+
ENV ?= dev
18+
19+
IMAGE_TAG ?= $(NAME):latest
20+
21+
NAME := posit-sdk-py
22+
23+
ifeq ($(ENV), prod)
24+
NETLIFY_ARGS := --prod
25+
else
26+
NETLIFY_ARGS :=
27+
endif
28+
29+
NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee
30+
31+
PYTHON := python3
32+
33+
ifneq ($(shell command -v uv 2>/dev/null),)
34+
PIP := uv pip
35+
else
36+
PIP := pip3
37+
endif
38+
39+
QUARTO ?= quarto
40+
41+
QUARTODOC ?= quartodoc

0 commit comments

Comments
 (0)