diff --git a/.gitea/workflows/dfi.bash b/.gitea/workflows/dfi.bash index b5bb87b..ecb8a0e 100755 --- a/.gitea/workflows/dfi.bash +++ b/.gitea/workflows/dfi.bash @@ -378,19 +378,37 @@ function container::finance::edit() done "${ci_shell[@]}" "$_exec '$_edit type=add,iadd,manual,fetch,hledger,meta,shell,subscript & wait ; kill -9 %1'" "${ci_shell[@]}" "$_exec '$_edit type=rules,preprocess account=coinbase/platform,electrum/wallet-1 & wait ; kill -9 %1'" + + # + # Fetch: add API secrets for CI + # + + [[ -z "$CI_DFI_FETCH_MOBULA" || -z "$CI_DFI_FETCH_ETHERSCAN" ]] && exit 1 + + local -r _file="${HOME}/finance-flow/profiles/testprofile/${USER}/docker-finance.d/fetch/fetch.yaml" + [ ! -f "$_file" ] && exit 1 + + # `prices` + sed -i "77s/.*/ key: \"${CI_DFI_FETCH_MOBULA}\"/" "$_file" + [ ! -z "$CI_DFI_FETCH_COINGECKO" ] \ + && sed -i "118s/.*/ key: \"${CI_DFI_FETCH_COINGECKO}\"/" "$_file" \ + || echo "[INFO] CI_DFI_FETCH_COINGECKO is empty (using free plan)" + + # `accounts` + # + # NOTE: For CI, a single etherscan API key is used per account + # (but the flexibility remains to use multiple keys if needed) + # + sed -i "s:etherscan/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:etherscan/${CI_DFI_FETCH_ETHERSCAN}:g" "$_file" client::finance::down } -# TODO: vastly expand; requires realtime insertion of API keys derived from runner environment function container::finance::fetch() { client::finance::up local -r _exec="$ci_archlinux exec" local -r _fetch="$ci_profile fetch" - # Randomized test wallets (mockups) are guaranteed to be available for given year - local -r _year="2024" - # # `price` # @@ -400,32 +418,65 @@ function container::finance::fetch() "${ci_shell[@]}" "$_exec '$_fetch price=bitcoin/BTC,ethereum/ETH api=INVALID' || exit 0" # Valid - # TODO: uncomment after runner environment provides API key - # "${ci_shell[@]}" "$_exec '$_fetch price=bitcoin/BTC,ethereum/ETH api=mobula,coingecko'" - # "${ci_shell[@]}" "$_exec '$_fetch price=algorand/ALGO,tezos/XTZ api=mobula year=${_year}'" + "${ci_shell[@]}" "$_exec '$_fetch all=price'" + "${ci_shell[@]}" "$_exec '$_fetch price=bitcoin/BTC,ethereum/ETH api=mobula,coingecko'" + "${ci_shell[@]}" "$_exec '$_fetch price=algorand/ALGO,tezos/XTZ api=mobula year=2024'" # # `account` # - # TODO: all chains (after runner environment provides API keys) + # Test given wallet/chain arguments with test wallets picked at random (mockups) + # NOTE: these are also all caught with `all=account` or `all=all` local -r _algo_wallet="algorand/phone:mobile-1/55YXQ2AC7PUOOYIWUFIOGFZ7M5CBWFUDOIT7L3FMZVE7HGC3IKABL7HVOE" local -r _tezos_wallet="tezos/nano:x-1:staking-1/tz1S1ayWDiHzmL6zFNnY1ivvUkEgDcH88cjx" + local -r _ethereum_wallet="ethereum/laptop:wallet-1/0x6546d43EA6DE45EB7298A2074e239D5573cA02F3" + local -r _polygon_wallet="polygon/laptop:wallet-2/0xEad0B2b6f6ab84d527569835cd7fe364e067cFFf" + + local -r _arbitrum_wallet="arbitrum/phone:wallet-2/0xd3b29C94a67Cfa949FeD7dd1474B71d006fa0A2A" + local -r _base_wallet="base/laptop:wallet-3/0x4C7219b760b71B9415E0e01Abd34d0f65631e57e" + local -r _optimism_wallet="optimism/phone:wallet-3/0x53004E863Aa0F4028B154ECA65CFb32Eb5a8f5bB" + # Invalid - # TODO: all chains (after runner environment provides API keys) - "${ci_shell[@]}" "$_exec '$_fetch account=INVALID chain=algorand,tezos year=${_year}' || exit 0" - "${ci_shell[@]}" "$_exec '$_fetch account=ledger chain=INVALID year=${_year}' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=INVALID chain=algorand,tezos year=2024' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=ledger chain=INVALID year=2024' || exit 0" "${ci_shell[@]}" "$_exec '$_fetch account=ledger chain=algorand,tezos year=INVALID' || exit 0" - "${ci_shell[@]}" "$_exec '$_fetch account=INVALID chain=${_algo_wallet} year=${_year}' || exit 0" - "${ci_shell[@]}" "$_exec '$_fetch account=pera-wallet chain=INVALID year=${_year}' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=INVALID chain=${_algo_wallet} year=2024' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=pera-wallet chain=INVALID year=2024' || exit 0" "${ci_shell[@]}" "$_exec '$_fetch account=pera-wallet chain=${_algo_wallet} year=INVALID' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=ledger,pera-walletINVALID chain=${_tezos_wallet},${_algo_wallet} year=2024' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=ledger,pera-wallet chain=INVALID${_tezos_wallet},${_algo_wallet} year=2024' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=ledger,pera-wallet chain=${_tezos_wallet},${_algo_wallet} year=INVALID' || exit 0" + + "${ci_shell[@]}" "$_exec '$_fetch account=metamaskINVALID chain=arbitrum year=2025' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=metamask chain=INVALIDarbitrum year=2025' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=metamask chain=arbitrum year=INVALID' || exit 0" + + "${ci_shell[@]}" "$_exec '$_fetch account=metamaskINVALID chain=${_ethereum_wallet},${_polygon_wallet},${_arbitrum_wallet},${_base_wallet},${_optimism_wallet} year=2025' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=metamask chain=INVALID${_ethereum_wallet},${_polygon_wallet},${_arbitrum_wallet},${_base_wallet},${_optimism_wallet} year=2025' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=metamask chain=${_ethereum_wallet},${_polygon_wallet},${_arbitrum_wallet},${_base_wallet},${_optimism_wallet} year=INVALID' || exit 0" + + "${ci_shell[@]}" "$_exec '$_fetch account=INVALIDcoinbase-wallet,coinomi,ledger,metamask,pera-wallet chain=algorand,arbitrum,ethereum,polygon,tezos year=2024' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=coinbase-wallet,coinomi,ledger,metamask,pera-wallet chain=INVALIDalgorand,arbitrum,ethereum,polygon,tezos year=2024' || exit 0" + "${ci_shell[@]}" "$_exec '$_fetch account=coinbase-wallet,coinomi,ledger,metamask,pera-wallet chain=algorand,arbitrum,ethereum,polygon,tezos year=INVALID' || exit 0" + # Valid - # TODO: all chains (after runner environment provides API keys) - "${ci_shell[@]}" "$_exec '$_fetch account=ledger chain=${_tezos_wallet} year=${_year}'" - "${ci_shell[@]}" "$_exec '$_fetch account=pera-wallet chain=${_algo_wallet} year=${_year}'" + # + # NOTE: not currently fetching Optimism or Base for CI + # + # "[FATAL] Free API access is not supported for this chain. Please upgrade your api plan for full chain coverage. https://etherscan.io/apis" + # + "${ci_shell[@]}" "$_exec '$_fetch account=ledger chain=${_tezos_wallet} year=2024'" + "${ci_shell[@]}" "$_exec '$_fetch account=pera-wallet chain=${_algo_wallet} year=2024'" + "${ci_shell[@]}" "$_exec '$_fetch account=ledger,pera-wallet chain=${_tezos_wallet},${_algo_wallet} year=2024'" + + "${ci_shell[@]}" "$_exec '$_fetch account=metamask chain=arbitrum year=2025'" + "${ci_shell[@]}" "$_exec '$_fetch account=metamask chain=${_ethereum_wallet},${_polygon_wallet},${_arbitrum_wallet} year=2025'" + + "${ci_shell[@]}" "$_exec '$_fetch account=coinbase-wallet,coinomi,ledger,metamask,pera-wallet chain=algorand,arbitrum,ethereum,polygon,tezos year=2024'" client::finance::down }