forked from thechangelog/changelog.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
194 lines (161 loc) Β· 5.19 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# vim: set tabstop=4 shiftwidth=4 expandtab:
[private]
default:
just --list
[private]
fmt:
just --fmt --check --unstable
[private]
brew:
@which brew >/dev/null \
|| (echo {{ GREEN }}πΊ Installing Homebrew...{{ RESET }} \
&& NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" \
&& echo {{ REDB }}{{ WHITE }} π You must follow NEXT STEPS above before continuing π {{ RESET }})
[private]
brew-linux-shell:
@echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'
[private]
just: brew
@[ -f $(brew--prefix)/bin/just ] \
|| brew install just
[private]
just0:
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | sudo bash -s -- --to /usr/local/bin
[private]
imagemagick: brew
@[ -d $(brew --prefix)/opt/imagemagick ] \
|| brew install imagemagick
PGPATH := "PATH=$(brew --prefix)/opt/postgresql@16/bin:" + env_var("PATH")
PGDATA := "PGDATA=$(brew --prefix)/var/postgresql@16"
PG := PGPATH + " " + PGDATA
[private]
postgres: brew
@[ -d $(brew --prefix)/opt/postgresql@16 ] \
|| brew install postgresql@16
[private]
gpg: brew
@[ -d $(brew --prefix)/opt/gpg ] \
|| brew install gpg
# https://tldp.org/LDP/abs/html/exitcodes.html
[private]
asdf:
@which asdf >/dev/null \
|| (brew install asdf \
&& echo {{ REDB }}{{ WHITE }} π You must follow CAVEATS above before continuing π {{ RESET }})
[private]
asdf-shell: brew
@echo "source $(brew --prefix)/opt/asdf/libexec/asdf.sh"
# Install all system dependencies
install: asdf brew imagemagick postgres gpg
@awk '{ system("asdf plugin-add " $1) }' < .tool-versions
@asdf install
export ELIXIR_ERL_OPTIONS := if os() == "linux" { "+fnu" } else { "" }
# Get app dependencies
deps:
mix local.hex --force
mix deps.get --only dev
mix deps.get --only test
[private]
pg_ctl:
@{{ PG }} which pg_ctl >/dev/null \
|| (echo "Please install Postgres using: {{ BOLD }}just install{{ RESET }}" && exit 127)
# Start Postgres server
postgres-up: pg_ctl
@({{ PG }} pg_ctl status | grep -q "is running") || {{ PG }} pg_ctl start
# Stop Postgres server
postgres-down: pg_ctl
@({{ PG }} pg_ctl status | grep -q "no server running") || {{ PG }} pg_ctl stop
[private]
postgres-db db:
@({{ PG }} psql --list --quiet --tuples-only | grep -q {{ db }}) \
|| {{ PG }} createdb {{ db }}
export DB_USER := `whoami`
[private]
changelog_test: postgres-up (postgres-db "changelog_test")
# Run app tests
test: changelog_test
mix test
[private]
changelog_dev: postgres-up (postgres-db "changelog_dev")
mix ecto.setup
[private]
yarn:
@which yarn >/dev/null \
|| (echo "Please install Node.js & Yarn using: {{ BOLD }}just install{{ RESET }}" && exit 127)
[private]
assets: yarn
cd assets && yarn install
# Run app in dev mode
dev: changelog_dev assets
mix phx.server
# Setup everything needed for your first contribution
contribute: install
#!/usr/bin/env bash
eval "$(just asdf-shell)"
just deps
just test
just dev
[private]
actions-runner:
docker run --interactive --tty \
--volume=changelog-linuxbrew:/home/linuxbrew/.linuxbrew \
--volume=changelog-asdf:/home/runner/.asdf \
--volume=.:/home/runner/work --workdir=/home/runner/work \
--env=HOST=$(hostname) --publish=4000:4000 \
--pull=always ghcr.io/actions/actions-runner
[linux]
[private]
do-it:
#!/usr/bin/env bash
sudo apt update
DEBIAN_FRONTEND=noninteractive sudo apt install -y build-essential curl git libncurses5-dev libssl-dev inotify-tools
just brew
eval "$(just brew-linux-shell)"
just asdf
eval "$(just asdf-shell)"
just contribute
# Tag Kaizen $version with $episode & $discussion at $commit (recording date)
[private]
tag-kaizen version episode discussion commit:
git tag --force --sign \
--message="Recorded as π§ <https://changelog.com/friends/{{ episode }}>" \
--message="Discussed in https://github.com/thechangelog/changelog.com/discussions/{{ discussion }}" \
kaizen.{{ version }} {{ commit }}
git push --force origin kaizen.{{ version }}
# https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/
BOLD := "$(tput bold)"
RESET := "$(tput sgr0)"
BLACK := "$(tput bold)$(tput setaf 0)"
RED := "$(tput bold)$(tput setaf 1)"
GREEN := "$(tput bold)$(tput setaf 2)"
YELLOW := "$(tput bold)$(tput setaf 3)"
BLUE := "$(tput bold)$(tput setaf 4)"
MAGENTA := "$(tput bold)$(tput setaf 5)"
CYAN := "$(tput bold)$(tput setaf 6)"
WHITE := "$(tput bold)$(tput setaf 7)"
BLACKB := "$(tput bold)$(tput setab 0)"
REDB := "$(tput setab 1)$(tput setaf 0)"
GREENB := "$(tput setab 2)$(tput setaf 0)"
YELLOWB := "$(tput setab 3)$(tput setaf 0)"
BLUEB := "$(tput setab 4)$(tput setaf 0)"
MAGENTAB := "$(tput setab 5)$(tput setaf 0)"
CYANB := "$(tput setab 6)$(tput setaf 0)"
WHITEB := "$(tput setab 7)$(tput setaf 0)"
# just actions-runner
# DEBIAN_FRONTEND=noninteractive sudo apt install -y curl
# eval $(grep j_ust.systems justfile)
# cd ../
# sudo chown -fR runner:runner work ~/.asdf
# cd work
# just do-it
#
# du -skh _build
# 72M
#
# du -skh deps
# 41M
#
# du -skh /home/linuxbrew/.linuxbrew
# 1.5G
# du -skh ~/.asdf
# 728M