Skip to content

Commit

Permalink
build: reduces makefile boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein committed Jun 11, 2024
1 parent 7930dff commit c4fb140
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 56 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ jobs:
- run: make deps
- run: make dev
- run: make docs
- run: |
preview_url=$(make deploy | jq '.deploy_url' | tail -n 1 | tr -d '"')
echo "# 🚀 Site Preview" >> $GITHUB_STEP_SUMMARY
echo "$preview_url" >> $GITHUB_STEP_SUMMARY
- id: preview
working-directory: docs
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: |
preview_url=$(make deploy | jq '.deploy_url' | tail -n 1 | tr -d '"')
echo "# 🚀 Site Preview" >> $GITHUB_STEP_SUMMARY
echo "$preview_url" >> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN apt-get update && apt-get install -y make

WORKDIR /sdk

COPY requirements.txt requirements-dev.txt Makefile ./
COPY requirements.txt requirements-dev.txt vars.mk Makefile ./

RUN make deps

Expand Down
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
.DEFAULT_GOAL := all

NAME := posit-sdk
PYTHON := python3
include vars.mk

ifneq ($(shell command -v uv 2>/dev/null),)
PIP := uv pip
else
PIP := pip3
endif
.DEFAULT_GOAL := all

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

Expand All @@ -17,6 +10,8 @@ build:
$(PYTHON) -m build

clean:
$(MAKE) -C ./docs $@
$(MAKE) -C ./integration $@
rm -rf .coverage .mypy_cache .pytest_cache .ruff_cache *.egg-info build coverage.xml dist htmlcov coverage.xml
find . -name "*.egg-info" -exec rm -rf {} +
find . -name "*.pyc" -exec rm -f {} +
Expand Down
29 changes: 4 additions & 25 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
.DEFAULT_GOAL := all
include ../vars.mk

VERSION := $(shell $(MAKE) -C ../ -s version)

# Command aliases
PIP ?= pip3
QUARTO ?= quarto
QUARTODOC ?= quartodoc

# Environment variables
NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee
CURRENT_YEAR ?= $(shell date +%Y)
VERSION ?= $(shell make --silent -C ../ version | tail -n 1)
ENV ?= dev

# Determine Netlify arguments from environment
ifeq ($(ENV), prod)
NETLIFY_ARGS := --prod
else
NETLIFY_ARGS :=
endif

# Determine if `uv` is available
ifneq ($(shell command -v uv 2>/dev/null),)
PIP := uv pip
else
PIP := pip3
endif
.DEFAULT_GOAL := all

.PHONY: all \
api \
Expand Down
19 changes: 2 additions & 17 deletions integration/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include ../vars.mk

.DEFAULT_GOAL := all

.PHONY: $(CONNECT_VERSIONS) \
Expand Down Expand Up @@ -29,23 +31,6 @@ CONNECT_VERSIONS := 2024.05.0 \
2022.12.0 \
2022.11.0

# Environment Variables
NAME = posit-sdk
IMAGE_TAG ?= posit-sdk-py:latest
CONNECT_BOOTSTRAP_SECRETKEY ?= $(shell head -c 32 /dev/random | base64)
CONNECT_IMAGE ?= rstudio/rstudio-connect

# Binaries
DOCKER_COMPOSE ?= docker compose
PYTHON ?= python3

# Determine if `uv` is available
ifneq ($(shell command -v uv 2>/dev/null),)
PIP := uv pip
else
PIP := pip3
endif

clean:
rm -rf logs reports
find . -type d -empty -delete
Expand Down
41 changes: 41 additions & 0 deletions vars.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Makefile variables file.
#
# Variables shared across project Makefiles via 'include vars.mk'.
#
# - ./Makefile
# - ./docs/Makefile
# - ./integration/Makefile

CONNECT_BOOTSTRAP_SECRETKEY ?= $(shell head -c 32 /dev/random | base64)

CONNECT_IMAGE ?= rstudio/rstudio-connect

CURRENT_YEAR ?= $(shell date +%Y)

DOCKER_COMPOSE ?= docker compose

ENV ?= dev

IMAGE_TAG ?= $(NAME):latest

NAME := posit-sdk-py

ifeq ($(ENV), prod)
NETLIFY_ARGS := --prod
else
NETLIFY_ARGS :=
endif

NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee

PYTHON := python3

ifneq ($(shell command -v uv 2>/dev/null),)
PIP := uv pip
else
PIP := pip3
endif

QUARTO ?= quarto

QUARTODOC ?= quartodoc

0 comments on commit c4fb140

Please sign in to comment.