Skip to content

Commit

Permalink
https://github.com/bonfire-networks/bonfire-app/issues/836
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Nov 12, 2024
1 parent a4c5e28 commit 5ea2029
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 56 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ deps.path.*
deps.*.path
/libs/
# /forks/
/forks/*/
/extensions/*/
/forks/*
/extensions/*

# Dev artifacts
.elixir_ls
Expand Down Expand Up @@ -118,3 +118,4 @@ archeometer_bonfire.db
!/reports/dev/static/livemd/index.livemd
docs/xref_graph.svg

lib/mix/tasks
4 changes: 2 additions & 2 deletions git-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function maybe_rebase {
}

function rebase {
# if jungle is available and we can assume fetches were already done by just and so we rebase, otherwise we rebase pull
command -v jungle && git rebase || git pull --rebase || fail "Please resolve conflicts before continuing."
# if rebasing we assume that jungle already fetched, so we try to directly rebase
git rebase || fail "Please resolve conflicts before continuing."
}

function fail {
Expand Down
123 changes: 71 additions & 52 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ update-dep-simple dep:

# Pull the latest commits from all forks
@update-forks:
(jungle git fetch && just update-forks-all rebase) || (echo "Jungle not available, will fetch one by one instead." && just update-forks-all pull)
(just git-fetch-all && just update-forks-all rebase) || (echo "Fetch all clones with Jungle not available, will fetch one by one instead." && just update-forks-all pull)

update-forks-all cmd='pull':
just update-fork-path $EXT_PATH $cmd
Expand All @@ -367,14 +367,14 @@ update-fork-path path cmd='pull' mindepth='0' maxdepth='1':

# Fetch locked versions of deps (Elixir and JS), including ones also cloned locally
@deps-fetch *args='':
just deps-get $@
-just mix-remote deps.get $@ || echo "Oops, could not download mix deps"
just deps-get {{args}}
-just mix-remote deps.get {{args}} || echo "Oops, could not download mix deps"
just _deps-post-get
just js-deps-fetch

# Fetch locked versions of Elixir deps (except ones also cloned locally)
@deps-get *args='':
just mix deps.get $@
just mix deps.get {{args}}

@_deps-post-get: extension-post-install
ln -sf ../../../priv/static extensions/bonfire/priv/static || ln -sf ../../../priv/static deps/bonfire/priv/static || echo "Could not find a priv/static dir to use"
Expand All @@ -386,7 +386,7 @@ update-fork-path path cmd='pull' mindepth='0' maxdepth='1':
-cd priv/static/data && ln -s ../../../data/uploads

deps-clean *args='':
just mix deps.clean --build $@
just mix deps.clean --build {{args}}

@deps-clean-data:
just mix bonfire.deps.clean.data
Expand Down Expand Up @@ -473,7 +473,7 @@ deps-clone-local-all:

# Utility to manage the deps in deps.hex, deps.git, and deps.path (eg. `just messctl help`)
# messctl *args='': init
# {{ if WITH_DOCKER == "no" { "messctl $@" } else { "just docker-compose run web messctl $@" } }}
# {{ if WITH_DOCKER == "no" { "messctl $args" } else { "just docker-compose run web messctl $args" } }}

#### CONTRIBUTION RELATED COMMANDS ####

Expand Down Expand Up @@ -507,9 +507,7 @@ contrib-app-release: _pre-push-hooks contrib-app-release-increment git-publish

# Increment the app version number
@contrib-app-release-increment:
mkdir -p lib/mix
cd lib/mix/ && (ln -sf ../../extensions/bonfire_common/lib/mix_tasks tasks || ln -sf ../../deps/bonfire_common/lib/mix_tasks tasks)
cd lib/mix/tasks/release/ && mix escript.build && ./release ../../../../../ $APP_VSN_EXTRA
just escript_common release "./ $APP_VSN_EXTRA"

contrib-forks-publish: update-forks

Expand All @@ -519,6 +517,11 @@ contrib-rel-push: contrib-release rel-build rel-push
cloc:
cloc lib config extensions/*/lib extensions/*/test test

# Fetch latest remote commits from all extensions/forks git repos (does not checkout or rebase though)
git-fetch-all:
just escript_dep jungle
# jungle git fetch || just escript_dep jungle # ^ experimental: replaced racket script with escript

# Run the git add command on each fork
git-forks-add: deps-git-fix
find $EXT_PATH -mindepth 1 -maxdepth 1 -type d -exec echo add {} \; -exec git -C '{}' add --all . \;
Expand Down Expand Up @@ -556,42 +559,42 @@ deps-git-fix:

# Run tests. You can also run only specific tests, eg: `just test extensions/bonfire_social/test`
test *args='':
@echo "Testing $@..."
MIX_ENV=test just mix test $@
@echo "Testing $args..."
MIX_ENV=test just mix test $args

# test-federation *args='':
# MIX_TEST_ONLY=federation just test --exclude ui backend --include federation $@
# MIX_TEST_ONLY=federation just test --exclude ui backend --include federation $args

test-backend *args='':
MIX_TEST_ONLY=backend just test --exclude ui --exclude federation --exclude todo --include backend $@
MIX_TEST_ONLY=backend just test --exclude ui --exclude federation --exclude todo --include backend $args

test-ui *args='':
MIX_TEST_ONLY=ui just test --exclude backend --exclude federation --exclude todo --include ui $@
MIX_TEST_ONLY=ui just test --exclude backend --exclude federation --exclude todo --include ui $args

# Run only stale tests
test-stale *args='':
@echo "Testing $@..."
MIX_ENV=test just mix test --stale $@
@echo "Testing {{args}}..."
MIX_ENV=test just mix test --stale {{args}}

# Run tests (ignoring changes in local forks)
test-remote *args='':
@echo "Testing $@..."
MIX_ENV=test just mix-remote test $@
@echo "Testing {{args}}..."
MIX_ENV=test just mix-remote test {{args}}

# Run stale tests, and wait for changes to any module code, and re-run affected tests
test-watch *args='':
@echo "Testing $@..."
MIX_ENV=test just mix mneme.watch --stale $@
# MIX_ENV=test just mix test.watch --stale --exclude mneme $@
@echo "Testing {{args}}..."
MIX_ENV=test just mix mneme.watch --stale {{args}}
# MIX_ENV=test just mix test.watch --stale --exclude mneme {{args}}

test-watch-full *args='':
@echo "Testing $@..."
MIX_ENV=test just mix mneme.watch $@
# MIX_ENV=test just mix test.watch --exclude mneme $@
@echo "Testing {{args}}..."
MIX_ENV=test just mix mneme.watch {{args}}
# MIX_ENV=test just mix test.watch --exclude mneme {{args}}

# Run stale tests, and wait for changes to any module code, and re-run affected tests, and interactively choose which tests to run
test-interactive *args='':
@MIX_ENV=test just mix test.interactive --stale $@
@MIX_ENV=test just mix test.interactive --stale {{args}}

ap_lib := "forks/activity_pub/test/activity_pub"
ap_integration := "extensions/bonfire_federate_activitypub/test/activity_pub_integration"
Expand All @@ -609,30 +612,30 @@ test-federation: test-federation-dance-positions
just test-federation-dance-positions

test-federation-lib *args=ap_lib: test-federation-dance-positions
just test-watch $@
just test-watch {{args}}

test-federation-bonfire *args=ap_integration: test-federation-dance-positions
just test-watch $@
just test-watch {{args}}

test-federation-boundaries *args="extensions/bonfire_federate_activitypub/test/boundaries": test-federation-dance-positions
just test-watch $@
just test-watch {{args}}

test-federation-in-extensions *args=ap_ext: test-federation-dance-positions
just test-watch $@
just test-watch {{args}}

test-federation-dance *args='': test-federation-dance-positions test-db-federation-dance-reset
TEST_INSTANCE=yes HOSTNAME=localhost just test --only test_instance $@
TEST_INSTANCE=yes HOSTNAME=localhost just test --only test_instance {{args}}
just test-federation-dance-positions

test-federation-dance-unsigned *args='': test-federation-dance-positions test-db-federation-dance-reset
ACCEPT_UNSIGNED_ACTIVITIES=1 TEST_INSTANCE=yes HOSTNAME=localhost just test --only test_instance $@
ACCEPT_UNSIGNED_ACTIVITIES=1 TEST_INSTANCE=yes HOSTNAME=localhost just test --only test_instance {{args}}
just test-federation-dance-positions

test-federation-dance-positions:
TEST_INSTANCE=yes MIX_ENV=test just mix deps.clean bonfire --build

test-federation-live-DRAGONS *args='':
FEDERATE=yes PHX_SERVER=yes HOSTNAME=`just local-tunnel-hostname` PUBLIC_PORT=443 just test --only live_federation $@
FEDERATE=yes PHX_SERVER=yes HOSTNAME=`just local-tunnel-hostname` PUBLIC_PORT=443 just test --only live_federation {{args}}

load_testing:
TEST_INSTANCE=yes just mix bonfire.load_testing
Expand Down Expand Up @@ -853,13 +856,13 @@ _db-shell docker_compose cmd="psql" compose_args="" extra_args="":

# Run a specific command in the container (if used), eg: `just cmd messclt` or `just cmd time` or `just cmd "echo hello"`
@cmd *args='': init docker-stop-web
{{ if WITH_DOCKER == "total" { "echo Run $@ in docker && just docker-compose run --name $WEB_CONTAINER --service-ports web $@" } else {" echo Run $@ && $@"} }}
{{ if WITH_DOCKER == "total" { "echo Run $args in docker && just docker-compose run --name $WEB_CONTAINER --service-ports web $args" } else {" echo Run $args && $args"} }}

cwd *args:
cd {{invocation_directory()}}; $@
cd {{invocation_directory()}}; {{args}}

cwd-test *args:
cd {{invocation_directory()}}; MIX_ENV=test mix test $@
cd {{invocation_directory()}}; MIX_ENV=test mix test {{args}}

# Open the shell of the web container, in dev mode
shell:
Expand All @@ -870,10 +873,10 @@ shell:
-docker rm $WEB_CONTAINER

@docker *args='':
export $(./tool-versions-to-env.sh 3 | xargs) && export $(grep -v '^#' .tool-versions.env | xargs) && export ELIXIR_DOCKER_IMAGE="${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION}" && docker $@
export $(./tool-versions-to-env.sh 3 | xargs) && export $(grep -v '^#' .tool-versions.env | xargs) && export ELIXIR_DOCKER_IMAGE="${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION}" && docker {{args}}

@docker-compose *args='':
just docker compose $@
just docker compose {{args}}

@docker-stop:
just docker-compose stop
Expand All @@ -882,27 +885,27 @@ shell:

# Open an interactive console
@imix *args='':
just cmd iex -S mix $@
just cmd iex -S mix {{args}}

# Run a specific mix command, eg: `just mix deps.get` or `just mix "deps.update needle"`
@mix *args='':
echo % mix $@
{{ if MIX_ENV == "prod" { "just mix-maybe-prod $@" } else { "just cmd mix $@" } }}
echo % mix {{args}}
{{ if MIX_ENV == "prod" { "just mix-maybe-prod $args" } else { "just cmd mix $args" } }}

@mix-eval *args='': init
echo % mix eval "$@"
{{ if MIX_ENV == "prod" {"echo Skip"} else { 'mix eval "$@"' } }}
echo % mix eval "{{args}}"
{{ if MIX_ENV == "prod" {"echo Skip"} else { 'mix eval "$args"' } }}

@mix-maybe-prod *args='':
{{ if WITH_DOCKER != "no" { "echo Ignoring mix commands when using docker in prod" } else { "just mix-maybe-prod-pre-release $@" } }}
{{ if WITH_DOCKER != "no" { "echo Ignoring mix commands when using docker in prod" } else { "just mix-maybe-prod-pre-release $args" } }}

@mix-maybe-prod-pre-release *args='':
{{ if path_exists("./_build/prod/rel/bonfire/bin/bonfire")=="true" { "echo Ignoring mix commands since we already have a prod release (delete _build/prod/rel/bonfire/bin/bonfire if you want to build a new release)" } else { "just cmd mix $@" } }}
{{ if path_exists("./_build/prod/rel/bonfire/bin/bonfire")=="true" { "echo Ignoring mix commands since we already have a prod release (delete _build/prod/rel/bonfire/bin/bonfire if you want to build a new release)" } else { "just cmd mix $args" } }}

# Run a specific mix command, while ignoring any deps cloned into forks, eg: `just mix-remote deps.get` or `just mix-remote deps.update needle`
mix-remote *args='': init
echo % WITH_FORKS=0 mix $@
{{ if WITH_DOCKER == "total" { "just docker-compose run -e WITH_FORKS=0 web mix $@" } else {"WITH_FORKS=0 mix $@"} }}
echo % WITH_FORKS=0 mix {{args}}
{{ if WITH_DOCKER == "total" { "just docker-compose run -e WITH_FORKS=0 web mix $args" } else {"WITH_FORKS=0 mix $args"} }}

xref-dot:
just mix xref graph --format dot --include-siblings
Expand All @@ -911,7 +914,7 @@ xref-dot:

# Run a specific exh command, see https://github.com/rowlandcodes/exhelp
exh *args='':
just cmd "exh -S mix $@"
just cmd "exh -S mix {{args}}"

deps-licenses:
@mkdir -p docs/DEPENDENCIES/
Expand Down Expand Up @@ -966,14 +969,30 @@ localise-extract:
just rand

@mix-secrets:
{{ if path_exists("lib/mix/tasks")=="true" { "echo ." } else {"just ln-mix-tasks"} }}
cd lib/mix/tasks/secrets/ && mix escript.build
./lib/mix/tasks/secrets/secrets --file .env
just escript_common secrets --file .env
# ./lib/mix/tasks/secrets/secrets 128 3

@escript_common name *args='':
-rm lib/mix/tasks
{{ if path_exists("lib/mix/tasks")=="true" { "echo ." } else {"just ln-mix-tasks"} }}
just escript lib/mix/tasks {{name}} {{args}}

@escript_ext name *args='':
{{ if path_exists("extensions/"+name)=="true" { "just escript extensions/ $name $args" } else {"just escript_dep $name $args"} }}

@escript_dep name *args='':
just dep-check {{name}}
{{ if path_exists("forks/"+name)=="true" { "just escript forks/ $name $args" } else {"just escript deps/$name $name $args"} }}

@escript path name *args='':
cd {{path}}/{{name}}/ && (stat {{name}} || mix escript.build)
{{path}}/{{name}}/{{name}} {{args}}

@dep-check name:
{{ if path_exists("forks/"+name)=="true" { "echo ." } else {"just deps-get"} }}

@ln-mix-tasks:
just mix deps.get
cd lib/mix/ && {{ if path_exists("../../extensions/bonfire_common/lib/mix_tasks")=="true" { "ln -sf ../../extensions/bonfire_common/lib/mix_tasks tasks" } else {"ln -sf ../../deps/bonfire_common/lib/mix_tasks tasks"} }}
mkdir -p lib/mix && cd lib/mix/ && {{ if path_exists("extensions/bonfire_common/lib/mix_tasks")=="true" { "echo Link to bonfire_common to dev clone && ln -sf ../../extensions/bonfire_common/lib/mix_tasks tasks" } else {"echo Link to bonfire_common to mix deps && just deps-get && ln -sf ../../deps/bonfire_common/lib/mix_tasks tasks"} }}

@rand:
echo {{ uuid() }}-{{ uuid() }}-{{ uuid() }}-{{ uuid() }}
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ defmodule Bonfire.Umbrella.MixProject do
# {:changelog, "~> 0.1", only: [:dev, :test], runtime: false}, # retrieve changelogs of latest dependency versions
# changelog generation
{:versioce, "~> 2.0.0", only: :dev},
{:jungle, git: "https://github.com/bonfire-networks/jungle", only: :dev},
# needed for changelog generation
{:git_cli, "~> 0.3.0", only: :dev},
{
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
"json_ptr": {:hex, :json_ptr, "1.2.0", "07a757d1b0a86b7fd73f5a5b26d4d41c5bc7d5be4a3e3511d7458293ce70b8bb", [:mix], [{:jason, "~> 1.4.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e58704ac304cbf3832c0ac161e76479e7b05f75427991ddd57e19b307ae4aa05"},
"json_serde": {:hex, :json_serde, "1.1.1", "5315570dda1a0adc531a68b4d3946b5d9a1e9147391df2c53c327f4d5f213eed", [:mix], [{:brex_result, "~> 0.4.0", [hex: :brex_result, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "0a7acdfac16efceb5337547e98418d3de083c066bbc05f3b5dd96c434d533922"},
"jumper": {:hex, :jumper, "1.0.2", "68cdcd84472a00ac596b4e6459a41b3062d4427cbd4f1e8c8793c5b54f1406a7", [:mix], [], "hexpm", "9b7782409021e01ab3c08270e26f36eb62976a38c1aa64b2eaf6348422f165e1"},
"jungle": {:git, "https://github.com/bonfire-networks/jungle", "75b2b5df6a3710c24eefd36e9b192197a1e9fef5", []},
"linkify": {:git, "https://github.com/bonfire-networks/linkify", "74b8a46c56e7a2b5749c5b38dffe86d6406a3044", []},
"live_select": {:hex, :live_select, "1.4.3", "ec9706952f589d8e2e6f98a0e1633c5b51ab5b807d503bd0d9622a26c999fb9a", [:mix], [{:ecto, "~> 3.8", [hex: :ecto, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.6.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_html_helpers, "~> 1.0", [hex: :phoenix_html_helpers, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "58f7d702b0f786c73d31e60a342c0a49afaf56ca5a6a078b51babf3490465220"},
"live_view_native": {:hex, :live_view_native, "0.3.1", "da64f1507e772b6cf8be99c85c6b300a03d64c46ceabc9f00b1f97962cc49e2d", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.20.10", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0.4", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.5", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.5", [hex: :sourceror, repo: "hexpm", optional: false]}, {:text_diff, "~> 0.1", [hex: :text_diff, repo: "hexpm", optional: false]}], "hexpm", "fd526dd025f58393a2d648c9ec22383464037f7effe5d62061029743e7572a86"},
Expand Down

0 comments on commit 5ea2029

Please sign in to comment.