Open Benjamin-Loison opened 2 months ago
Can investigate in Waydroid.
If I remember correctly I already investigated how to download GitHub action artefact.
No interesting issue for github.com]
(so takes into account api.github.com
, even if wrote as {api.,}.github.com
) in Improve_websites_thanks_to_open_source/issues using Benjamin-Loison/gitea/issues/9.
Related to Improve_websites_thanks_to_open_source/issues/936.
Well let us proceed again.
Before moving from commit to actual artefact download, let us focus on the latter.
https://github.com/termux/termux-api https://github.com/termux/termux-api/commit/c553bc2ba7de37ad5c42df23d71e699d2785d7c5 https://github.com/termux/termux-api/actions/runs/10155362023/job/28081990125 https://github.com/termux/termux-api/actions/runs/10155362023/artifacts/1753648493
If I remember correctly setting an account cookie is enough to download such URL.
wget 'https://github.com/termux/termux-api/actions/runs/10155362023/artifacts/1753648493'
--2024-09-17 00:16:01-- https://github.com/termux/termux-api/actions/runs/10155362023/artifacts/1753648493
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 307 Temporary Redirect
Location: https://github.com/termux/termux-api/suites/26571635387/artifacts/1753648493 [following]
--2024-09-17 00:16:01-- https://github.com/termux/termux-api/suites/26571635387/artifacts/1753648493
Reusing existing connection to github.com:443.
HTTP request sent, awaiting response... 404 Not Found
2024-09-17 00:16:01 ERROR 404: Not Found.
Hence the issue I was looking for should mention actions/runs/
.
I checked:
with no luck.
Benjamin_Loison/termux-boot/issues/6 does not help too.
minimizeCURL curl.sh 'HTTP/2 307'
history | grep '[u]ser_session'
does not return anything while I remember recently having looked for using headers with wget
.
wget --header='Cookie: user_session=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' https://github.com/termux/termux-api/suites/26571635387/artifacts/1753648493
works fine.
wget --header='Cookie: user_session=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' https://github.com/termux/termux-api/actions/runs/10155362023/artifacts/1753648493
too.
If I remember I was not able to use the GitHub API for this purpose. Note that the final download URL does not require to be authenticated, hence could in theory provide a service redirecting safely people to the wanted download without authenticating. The question is then how to prove that the redirection is correct. GitHub action logs seem to mention the checksum so with client verification it seems douable without trust.
My aim here is to retrieve APK by commit to bisect, so just retrieving last one as I remember does not interest me much. Maybe I was referring to https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#list-artifacts-for-a-repository.
history | grep 'termux.*apk'
does not bring interesting results.
https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#list-workflow-run-artifacts https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository
DuckDuckGo and Google results for GitHub API get workflow run by commit do not look interesting.
https://api.github.com/repos/termux/termux-app/actions/artifacts
curl -s https://api.github.com/repos/termux/termux-app/actions/artifacts | jq .artifacts[].name
does not mention 10155362023 and 28081990125.
gh api repos/termux/termux-api/actions/artifacts --jq ".artifacts[] | select(.workflow_run.head_sha == \"c553bc2ba7de37ad5c42df23d71e699d2785d7c5\")"
{
"message": "Bad credentials",
"documentation_url": "https://docs.github.com/rest",
"status": "401"
}
gh: Bad credentials (HTTP 401)
Source: the Stack Overflow answer 73119578
gh
gh auth
gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations on this host? SSH
? Upload your SSH public key to your GitHub account? /home/benjamin/.ssh/id_ed25519.pub
? Title for your SSH key: GitHub CLI
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: XXXX-XXXX
Press Enter to open github.com in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ SSH key already existed on your GitHub account: /home/benjamin/.ssh/id_ed25519.pub
✓ Logged in as Benjamin-Loison
! You were already logged in to this account
gh api repos/termux/termux-api/actions/artifacts --jq ".artifacts[] | select(.workflow_run.head_sha == \"c553bc2ba7de37ad5c42df23d71e699d2785d7c5\")"
REPOSITORY=termux-api
COMMIT=c553bc2ba7de37ad5c42df23d71e699d2785d7c5
RUN_ID=`curl -s "https://api.github.com/repos/termux/$REPOSITORY/actions/workflows/debug_build.yml/runs?head_sha=$COMMIT" | jq .workflow_runs[0].id`
ARTIFACT_ID=`curl -s "https://api.github.com/repos/termux/$REPOSITORY/actions/runs/$RUN_ID/artifacts" | jq .artifacts[0].id`
USER_SESSION=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
wget --header="Cookie: user_session=$USER_SESSION" https://github.com/termux/$REPOSITORY/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID
works as wanted.
REPOSITORY=termux-api
DEFAULT_BRANCH=`curl -s "https://api.github.com/repos/termux/$REPOSITORY" | jq -r .default_branch`
COMMIT=`curl -s "https://api.github.com/repos/termux/$REPOSITORY/commits/$DEFAULT_BRANCH" | jq -r .sha`
RUN_ID=`curl -s "https://api.github.com/repos/termux/$REPOSITORY/actions/workflows/debug_build.yml/runs?head_sha=$COMMIT" | jq .workflow_runs[0].id`
ARTIFACT_ID=`curl -s "https://api.github.com/repos/termux/$REPOSITORY/actions/runs/$RUN_ID/artifacts" | jq .artifacts[0].id`
USER_SESSION=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
wget --header="Cookie: user_session=$USER_SESSION" https://github.com/termux/$REPOSITORY/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID
works as wanted for last commit APK.
.apk
file extension is mandatory for adb install
.
REPOSITORY=termux-api
DEFAULT_BRANCH=`curl -s "https://api.github.com/repos/termux/$REPOSITORY" | jq -r .default_branch`
COMMIT=`curl -s "https://api.github.com/repos/termux/$REPOSITORY/commits/$DEFAULT_BRANCH" | jq -r .sha`
RUN_ID=`curl -s "https://api.github.com/repos/termux/$REPOSITORY/actions/workflows/debug_build.yml/runs?head_sha=$COMMIT" | jq .workflow_runs[0].id`
ARTIFACT=`curl -s "https://api.github.com/repos/termux/$REPOSITORY/actions/runs/$RUN_ID/artifacts" | jq .artifacts[0]`
ARTIFACT_NAME=`echo $ARTIFACT | jq -r .name`
ARTIFACT_ID=`echo "$ARTIFACT" | jq .id`
USER_SESSION=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
APK_FILE_NAME=$ARTIFACT_NAME.apk
wget --header="Cookie: user_session=$USER_SESSION" https://github.com/termux/$repository/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID
unzip $ARTIFACT_ID
adb install $APK_FILE_NAME
for file in `zipinfo -1 $ARTIFACT_ID`
do
rm $file
done
rm $ARTIFACT_ID
Source: the Super User answer 816676
USER_SESSION=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
REPOSITORIES=(termux-app termux-api)
for repository in "${REPOSITORIES[@]}"
do
DEFAULT_BRANCH=`curl -s "https://api.github.com/repos/termux/$repository" | jq -r .default_branch`
COMMIT=`curl -s "https://api.github.com/repos/termux/$repository/commits/$DEFAULT_BRANCH" | jq -r .sha`
RUN_ID=`curl -s "https://api.github.com/repos/termux/$repository/actions/workflows/debug_build.yml/runs?head_sha=$COMMIT" | jq .workflow_runs[0].id`
ARTIFACT=`curl -s "https://api.github.com/repos/termux/$repository/actions/runs/$RUN_ID/artifacts" | jq .artifacts[0]`
ARTIFACT_NAME=`echo $ARTIFACT | jq -r .name`
ARTIFACT_ID=`echo "$ARTIFACT" | jq .id`
APK_FILE_NAME=$ARTIFACT_NAME.apk
wget --header="Cookie: user_session=$USER_SESSION" https://github.com/termux/$repository/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID
unzip $ARTIFACT_ID
adb install $APK_FILE_NAME
for file in `zipinfo -1 $ARTIFACT_ID`
do
rm $file
done
rm $ARTIFACT_ID
done
Preferably test on recent Android version as otherwise the test may not be correct.
So testing on my really up-to-date phone seems the most appropriate, maybe just reinstalling Termux API is enough.
Maybe should check if there was recent update of termux-api
APT package.
find -name 'termux-api'
./packages/termux-api
termux-packages/tree/ca3e4fcbecd9636c39eab494a004c8d0840fb740/packages/termux-api which relies on termux-api-package. termux-api-package/commits/master/ does not show recent relevant activity so it does not seem to be the source of the issue.
Benjamin-Loison/android/issues/46#issuecomment-2357196559 would help.
Current allowed permissions are:
notification-test() {
termux-notification -t "Test $1" --button1 "Button $1" --button1-action "echo Button $1 >> termux_notification_action.txt"
}
notification-test 0
notification-test 1
While following --button1
label is correct, --button1-action
is stuck to the initial one, hence termux_notification_action.txt
is only made of Button 0 lines.
With commit/c553bc2ba7de37ad5c42df23d71e699d2785d7c5 on Fairphone 4 LineageOS.
adb install termux-api_v0.50.1+github-debug.apk
Performing Streamed Install
Success
does not list the app anymore when scroll up but it is in Settings > Apps > Recently opened apps > See all N apps.
This version solves the issue.
Should try the equivalent GitHub action one.
termux-api/commit/e315b53ec048e3dd321d69525c9e1162ca53f19f
Oldest GitHub action commit is commit/83c62b35188b2df7987992bb52263047444e4a90 but it shows The logs for this run have expired and are no longer available..
Oldest GitHub action commit with logs table of contents is commit/a9abc964b48bb3f9c54a2086df364ee8183cf523 but it shows Error: The log was not found. It may have been deleted based on retention settings..
Oldest GitHub action commit with artifact is commit/c553bc2ba7de37ad5c42df23d71e699d2785d7c5 which is the last commit hence by definition has the issue.
So have to compile on my own, related to #11.
Would be nice to at least use the version just before introducing the issue.
My own Debian 12 GNOME Pegasus last commit build has the issue.
rm termux-api_debug.apk; scp benjamin_loison@pegasus:/home/benjamin_loison/Desktop/BensFolder/DEV/GitHub/termux-api/app/build/outputs/apk/debug/termux-api_debug.apk . && adb install termux-api_debug.apk
git reset --hard e315b53ec048e3dd321d69525c9e1162ca53f19f
HEAD is now at e315b53 Bump to v0.50.1
I paid attention to no previous compilation file to be remaining.
git diff
Source: the Stack Overflow answer 75502295
Without having to restart Termux etc, my own build of v0.50.1 does not have the issue.
So it's time for Git bisect.
git bisect start
status: waiting for both good and bad commits
git bisect bad
status: waiting for good commit(s), bad commit known
git bisect good e315b53ec048e3dd321d69525c9e1162ca53f19f
Bisecting: 45 revisions left to test after this (roughly 6 steps)
[e7a684a9942e3d720975eb90e14e5f71bd6cb9b0] Changed: Remove redundant return variables
git log
commit e7a684a9942e3d720975eb90e14e5f71bd6cb9b0 (HEAD)
Author: agnostic-apollo <agnosticapollo@gmail.com>
Date: Mon Mar 14 22:58:06 2022 +0500
Changed: Remove redundant return variables
./gradlew assembleDebug
sudo ./gradlew assembleDebug
git status
sudo git clean -f -d -x
Removing .gradle/
Removing app/build/
does not help.
./gradlew assembleDebug
echo 'sdk.dir=/usr/lib/android-sdk' > local.properties
Then no significant difference with initial error.
grep -rI 'debugRuntimeClasspath'
does not return anything.
grep -rI 760ae78aff
app/build.gradle: implementation 'com.termux.termux-app:termux-shared:760ae78aff'
termux-shared does not exist.
Seems to refer to termux-app/tree/760ae78affdf5f53cefffcad073bd535b17e5a55/termux-shared.
./gradlew assembleDebug
echo 'sdk.dir=/usr/lib/android-sdk' > local.properties
./gradlew assembleDebug
sudo chown benjamin_loison: /usr/lib/android-sdk/ -R
./gradlew assembleDebug
./gradlew assembleDebug
ls -lh termux-shared/build/outputs/aar/
total 324K
-rw-r--r-- 1 benjamin_loison benjamin_loison 321K Sep 19 03:21 termux-shared-debug.aar
termux-api/blob/e7a684a9942e3d720975eb90e14e5f71bd6cb9b0/app/build.gradle#L70-L74 seems helpful.
below should be above, right?
termux-app/wiki/Termux-Libraries/c3a3fb546086e1b78a1d8d7c3df478d46e63529f seems helpful as well.
git diff app/build.gradle
Source: termux-app/wiki/Termux-Libraries/c3a3fb546086e1b78a1d8d7c3df478d46e63529f#termux-shared
solves the issue.
git bisect bad
Bisecting: 22 revisions left to test after this (roughly 5 steps)
[187e691cf957f8267ca215024a8691260bc0abd3] Changed: Rename PlayerService to MediaPlayerService
git bisect good
Bisecting: 11 revisions left to test after this (roughly 4 steps)
[d606d131f5e2407d41e0d427a048c51353d211e6] Changed: Suppress build.gradle validateVersionName() warnings
git bisect good
Bisecting: 5 revisions left to test after this (roughly 3 steps)
[3bea194249586a7dcb143e66b46c1694cb6ca21a] Changed: Remove hardcoded `com.termux` values
git bisect bad
Bisecting: 2 revisions left to test after this (roughly 2 steps)
[cfdcab920ef2b82a96096d924d21dbef2bdb6ad1] Fixed: Exit loop after "android.nfc.tech.Ndef" found in tech list
git bisect good
Bisecting: 0 revisions left to test after this (roughly 1 step)
[9a1e19cf5616fef1e7e5fbf78742bf007277f14c] Changed: Remove unused imports
./gradlew assembleDebug
git diff HEAD~ HEAD app/src/main/java/com/termux/api/apis/NotificationAPI.java
git checkout HEAD~ app/src/main/java/com/termux/api/apis/NotificationAPI.java
solves the issue.
git bisect good
3bea194249586a7dcb143e66b46c1694cb6ca21a is the first bad commit
commit 3bea194249586a7dcb143e66b46c1694cb6ca21a
Author: agnostic-apollo <agnosticapollo@gmail.com>
Date: Mon Mar 14 21:56:45 2022 +0500
Changed: Remove hardcoded `com.termux` values
.../main/java/com/termux/api/SocketListener.java | 3 +-
.../java/com/termux/api/TermuxAPIConstants.java | 14 +++++++++
.../activities/TermuxApiPermissionActivity.java | 3 +-
.../main/java/com/termux/api/apis/DialogAPI.java | 3 +-
.../java/com/termux/api/apis/JobSchedulerAPI.java | 27 ++++++++--------
.../java/com/termux/api/apis/NotificationAPI.java | 36 +++++++++++-----------
.../java/com/termux/api/apis/StorageGetAPI.java | 3 +-
app/src/main/java/com/termux/api/apis/UsbAPI.java | 3 +-
8 files changed, 57 insertions(+), 35 deletions(-)
create mode 100644 app/src/main/java/com/termux/api/TermuxAPIConstants.java
git reset --hard 3bea194249586a7dcb143e66b46c1694cb6ca21a
HEAD is now at 3bea194 Changed: Remove hardcoded `com.termux` values
After manual build, 3bea194249586a7dcb143e66b46c1694cb6ca21a has the issue.
git reset --hard 3bea194249586a7dcb143e66b46c1694cb6ca21a~
HEAD is now at 9a1e19c Changed: Remove unused imports
3bea194249586a7dcb143e66b46c1694cb6ca21a~ does not have the issue.
So it confirms git bisect
result that is 3bea194249586a7dcb143e66b46c1694cb6ca21a is to blame.
So the last working release is from 31 Dec, 2021 (termux-api/releases/tag/v0.50.1), the commit to blame (3bea194249586a7dcb143e66b46c1694cb6ca21a) is from Mar 14, 2022, 6:57 PM GMT+1, hence the last working commit (9a1e19cf5616fef1e7e5fbf78742bf007277f14c) is from Mar 14, 2022, 6:57 PM GMT+1.
The same time for these commits is not an error from my side.
The reason why I switched to more recent commits is #18 which has been patched on Sep 23, 2022, 11:32 PM GMT+2 (11eff5658cae1a2f0f2031a5da8df9351d4cb9e5) it seems, hence after the introduced issue, so have to investigate what went wrong in this commit.
So TERMUX_API_PACKAGE_NAME
is equivalent to com.termux.api
.
So only still have to review:
app/src/main/java/com/termux/api/TermuxAPIConstants.java
app/src/main/java/com/termux/api/apis/JobSchedulerAPI.java
app/src/main/java/com/termux/api/apis/NotificationAPI.java
commit/3bea194249586a7dcb143e66b46c1694cb6ca21a#diff-0dffbfbbf03868ae99fdf8ab411c64fa63d13590c7a1d8d2f11082d55e1eafc2R5 does not seem used at least in the 3 mentioned files.
app/src/main/java/com/termux/api/TermuxAPIConstants.java
on its own look right.
app/src/main/java/com/termux/api/apis/JobSchedulerAPI.java
has less changes than app/src/main/java/com/termux/api/apis/NotificationAPI.java
.
Can revert the problematic part of this commit on most recent commit to have the best of both worlds in theory.
See Benjamin_Loison/Food/issues/43.
+5
Problem description
Steps to reproduce
Expected behavior
Additional information