Skip to content

Commit

Permalink
migrate makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
maxheld83 committed Jan 18, 2025
0 parents commit c3481ad
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Lint
on:
push:
pull_request:
permissions:
contents: read
checks: write
jobs:
lint:
name: Lint
uses: ./.github/workflows/lint_reusable.yml
27 changes: 27 additions & 0 deletions .github/workflows/lint_reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Lint
on: workflow_call
permissions:
contents: read
checks: write
jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0
- name: Load super-linter configuration
# source
# https://github.com/super-linter/super-linter/blob/main/docs/run-linter-locally.md#share-environment-variables-between-environments
run: grep -v '^#' super-linter.env >> "$GITHUB_ENV"
- name: Lint Code Base
# must be in sync with version in compose file
uses: super-linter/[email protected]
env:
# To report GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions .muggle/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include .muggle/help.make
.DELETE_ON_ERROR:

.PHONY: all help lint

.DEFAULT_GOAL := help

## Run all targets
all: render

## Lint code base
lint:
@echo "Linting ..."
docker compose up super-linter
@echo "... linting done."
55 changes: 55 additions & 0 deletions .muggle/help.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# from https://gist.github.com/klmr/575726c7e05d8780505a
# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
# sed script explained:
# /^##/:
# * save line in hold space
# * purge line
# * Loop:
# * append newline + line to hold space
# * go to next line
# * if line starts with doc comment, strip comment character off and loop
# * remove target prerequisites
# * append hold space (+ newline) to line
# * replace newline plus comments by `---`
# * print line
# Separate expressions are necessary because labels cannot be delimited by
# semicolon; see <http://stackoverflow.com/a/11799865/1968>
.PHONY: help
help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)"
@echo
@sed -n -e "/^## / { \
h; \
s/.*//; \
:doc" \
-e "H; \
n; \
s/^## //; \
t doc" \
-e "s/:.*//; \
G; \
s/\\n## /---/; \
s/\\n/ /g; \
p; \
}" ${MAKEFILE_LIST} \
| LC_ALL='C' sort --ignore-case \
| awk -F '---' \
-v ncol=$$(tput cols) \
-v indent=19 \
-v col_on="$$(tput setaf 6)" \
-v col_off="$$(tput sgr0)" \
'{ \
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
n = split($$2, words, " "); \
line_length = ncol - indent; \
for (i = 1; i <= n; i++) { \
line_length -= length(words[i]) + 1; \
if (line_length <= 0) { \
line_length = ncol - indent - length(words[i]) - 1; \
printf "\n%*s ", -indent, " "; \
} \
printf "%s ", words[i]; \
} \
printf "\n"; \
}' \
| more $(shell test $(shell uname) == Darwin && echo '--no-init --raw-control-chars')
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Max Held Social Data Products

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!make

include .muggle/Makefile
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# workflows

Reusable GitHub Actions (GHA) Workflows
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
services:
super-linter:
# version needs to be in sync with version in .github/*.yml
image: ghcr.io/super-linter/super-linter:slim-v7.2.1
environment:
- RUN_LOCAL=true
# fix for amd64 bug as per https://github.com/super-linter/super-linter/issues/5070
- SHELL=/bin/bash
platform: linux/amd64
env_file:
- ./super-linter.env
volumes:
- .:/tmp/lint
8 changes: 8 additions & 0 deletions super-linter.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DEFAULT_BRANCH=main
FILTER_REGEX_EXCLUDE='.*\.(pdf|PDF)$'
IGNORE_GENERATED_FILES=true
IGNORE_GITIGNORED_FILES=true
LINTER_RULES_PATH=./
LOG_LEVEL=WARN
VALIDATE_GIT_COMMITLINT=false
VALIDATE_NATURAL_LANGUAGE=false

0 comments on commit c3481ad

Please sign in to comment.