Skip to content

Commit

Permalink
Go back to managing Postgres with asdf
Browse files Browse the repository at this point in the history
Single tool to rule them all ✊ icu4c seems to be working on macOS 14.7
ARM now. Checked that the new command works as expected. Also confirmed
that CI works locally.

Also run:

    npx browserslist@latest --update-db

Signed-off-by: Gerhard Lazu <[email protected]>
  • Loading branch information
gerhard authored and jerodsanto committed Nov 27, 2024
1 parent 0cf7922 commit c1aaeb7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 36 deletions.
4 changes: 0 additions & 4 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ export GITHUB_REF_NAME="master"
export IMAGE_OWNER=thechangelog
export GHCR_USERNAME=$USER

# Required for Postgres imports to work locally
export PATH=$(brew --prefix)/opt/postgresql@16/bin:$PATH
export PGDATA=$(brew --prefix)/var/postgresql@16

# Load secrets if configured - only available to changelog.com team members:
# https://github.com/orgs/thechangelog/people
source_env_if_exists .envrc.secrets
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ flyctl 0.2.65
golang 1.22.4
nodejs 20.14.0
yarn 1.22.22
postgres 16.5
19 changes: 7 additions & 12 deletions assets/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1479,15 +1479,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0:
version "1.0.30001338"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001338.tgz#b5dd7a7941a51a16480bdf6ff82bded1628eec0d"
integrity sha512-1gLHWyfVoRDsHieO+CaeYe7jSo/MT7D7lhaXUiwwbuR5BwQxORs0f1tAwUSQr3YbxRXJvxHM/PA5FfPQRnsPeQ==

caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001426, caniuse-lite@^1.0.30001449:
version "1.0.30001458"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz#871e35866b4654a7d25eccca86864f411825540c"
integrity sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001426, caniuse-lite@^1.0.30001449:
version "1.0.30001684"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001684.tgz"
integrity sha512-G1LRwLIQjBQoyq0ZJGqGIJUXzJ8irpbjHLpVRXDvBEScFJ9b17sgK6vlx0GAJFE21okD7zXl08rRRUfq6HdoEQ==

chalk@^2.0.0:
version "2.4.2"
Expand Down Expand Up @@ -2862,13 +2857,13 @@ pegjs@^0.10.0:
integrity sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==

"phoenix@file:../deps/phoenix":
version "1.7.11"
version "1.7.14"

"phoenix_html@file:../deps/phoenix_html":
version "3.3.3"
version "3.3.4"

"phoenix_live_view@file:../deps/phoenix_live_view":
version "0.20.9"
version "0.20.17"

picocolors@^1.0.0:
version "1.0.0"
Expand Down
31 changes: 13 additions & 18 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,23 @@ imagemagick: brew
@[ -d $(brew --prefix)/opt/imagemagick ] \
|| brew install imagemagick

[private]
check-postgres-envs:
@(grep -q postgresql@16 <<< $PATH) \
|| (echo "{{ REDB }}{{ WHITE }}Postgres 16 not present in PATH.{{ RESET }} To fix this, run: {{ GREENB }}{{ WHITE }}direnv allow{{ RESET }}" && exit 127)

export OP_ACCOUNT := "changelog.1password.com"

# Create .envrc.secrets with credentials from 1Password
[group('team')]
envrc-secrets:
op inject --in-file envrc.secrets.op --out-file .envrc.secrets

[private]
postgres: brew
@[ -d $(brew --prefix)/opt/postgresql@16 ] \
|| brew install postgresql@16

[private]
gpg: brew
@[ -d $(brew --prefix)/opt/gpg ] \
|| brew install gpg

[private]
icu4c: brew
@brew --prefix icu4c 1> /dev/null 2>&1 \
|| brew install icu4c pkg-config

# https://tldp.org/LDP/abs/html/exitcodes.html
[private]
asdf:
Expand All @@ -68,9 +63,9 @@ asdf-shell: brew

# Install all system dependencies
[group('contributor')]
install: asdf brew imagemagick postgres gpg
install: asdf brew imagemagick gpg icu4c
@awk '{ system("asdf plugin-add " $1) }' < .tool-versions
@asdf install
@PKG_CONFIG_PATH="$(brew --prefix icu4c)/lib/pkgconfig:$PKG_CONFIG_PATH" asdf install

export ELIXIR_ERL_OPTIONS := if os() == "linux" { "+fnu" } else { "" }

Expand All @@ -91,25 +86,25 @@ deps: add-oban-pro-repo
[private]
pg_ctl:
@which pg_ctl >/dev/null \
|| (echo "{{ REDB }}{{ WHITE }}Postgres 16 is not installed.{{ RESET }} To fix this, run: {{ GREENB }}{{ WHITE }}just install{{ RESET }}" && exit 127)
|| (echo "{{ REDB }}{{ WHITE }}Postgres is not installed.{{ RESET }} To fix this, run: {{ GREENB }}{{ WHITE }}just install{{ RESET }}" && exit 127)

# Start Postgres server
[group('contributor')]
postgres-up: pg_ctl check-postgres-envs
postgres-up: pg_ctl
@(pg_ctl status | grep -q "is running") || pg_ctl start

# Stop Postgres server
[group('contributor')]
postgres-down: pg_ctl check-postgres-envs
postgres-down: pg_ctl
@(pg_ctl status | grep -q "no server running") || pg_ctl stop

[private]
postgres-db db: check-postgres-envs
postgres-db db:
@(psql --list --quiet --tuples-only | grep -q {{ db }}) \
|| createdb {{ db }}

export DB_USER := `whoami`

export PGUSER := "postgres"
export DB_USER := PGUSER

# Delete & replace changelog_dev with a prod db dump
[confirm("This DELETEs and REPLACEs changelog_dev with the prod db dump. Are you sure that you want to continue?")]
Expand Down
4 changes: 2 additions & 2 deletions magefiles/tools/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func (v *Versions) Nodejs() string {
}

// https://www.postgresql.org/docs/release
// Hard-coding & installing via brew (keep hitting icu4c & root permissions with asdf)
// asdf list all postgres
func (v *Versions) Postgres() string {
return "16"
return v.toolVersions["postgres"]
}

// https://github.com/yarnpkg/yarn/releases
Expand Down

0 comments on commit c1aaeb7

Please sign in to comment.