Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: reduces makefile boilerplate #219

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading