Skip to content

Commit b643f33

Browse files
thavelickclaude
andcommitted
Add Makefile and format checking workflow
- Add Makefile with dev server and prettier formatting - Add GitHub Actions workflow to check code formatting - Workflow fails if code needs formatting to maintain code quality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 019a25d commit b643f33

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

.github/workflows/format-check.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Format Check
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
format-check:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "18"
20+
21+
- name: Check code formatting
22+
run: npx prettier --check .

Makefile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Sane defaults
2+
SHELL := /bin/bash
3+
.ONESHELL:
4+
.SHELLFLAGS := -eu -o pipefail -c
5+
.DELETE_ON_ERROR:
6+
MAKEFLAGS += --warn-undefined-variables
7+
MAKEFLAGS += --no-builtin-rules
8+
9+
# ---------------------- COMMANDS ---------------------------
10+
dev: # Start development server
11+
@echo "Starting development server.."
12+
cd public_html && python -m http.server 8000
13+
14+
format: # Format code with prettier
15+
@echo "Formatting code.."
16+
npx prettier --write --check .
17+
18+
# -----------------------------------------------------------
19+
# CAUTION: If you have a file with the same name as make
20+
# command, you need to add it to .PHONY below, otherwise it
21+
# won't work. E.g. `make run` wouldn't work if you have
22+
# `run` file in pwd.
23+
.PHONY: help
24+
25+
# -----------------------------------------------------------
26+
# ----- (Makefile helpers and decoration) --------
27+
# -----------------------------------------------------------
28+
29+
.DEFAULT_GOAL := help
30+
# check https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
31+
NC = \033[0m
32+
ERR = \033[31;1m
33+
TAB := '%-20s' # Increase if you have long commands
34+
35+
# tput colors
36+
red := $(shell tput setaf 1)
37+
green := $(shell tput setaf 2)
38+
yellow := $(shell tput setaf 3)
39+
blue := $(shell tput setaf 4)
40+
cyan := $(shell tput setaf 6)
41+
cyan80 := $(shell tput setaf 86)
42+
grey500 := $(shell tput setaf 244)
43+
grey300 := $(shell tput setaf 240)
44+
bold := $(shell tput bold)
45+
underline := $(shell tput smul)
46+
reset := $(shell tput sgr0)
47+
48+
help:
49+
@printf '\n'
50+
@printf ' $(underline)Available make commands:$(reset)\n\n'
51+
@# Print commands with comments
52+
@grep -E '^([a-zA-Z0-9_-]+\.?)+:.+#.+$$' $(MAKEFILE_LIST) \
53+
| grep -v '^env-' \
54+
| grep -v '^arg-' \
55+
| sed 's/:.*#/: #/g' \
56+
| awk 'BEGIN {FS = "[: ]+#[ ]+"}; \
57+
{printf " make $(bold)$(TAB)$(reset) # %s\n", \
58+
$$1, $$2}'
59+
@grep -E '^([a-zA-Z0-9_-]+\.?)+:( +\w+-\w+)*$$' $(MAKEFILE_LIST) \
60+
| grep -v help \
61+
| awk 'BEGIN {FS = ":"}; \
62+
{printf " make $(bold)$(TAB)$(reset)\n", \
63+
$$1}' || true
64+
@echo -e ""

0 commit comments

Comments
 (0)