Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub actions for scrcpy server #3721

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
push:

jobs:
server:
runs-on: ubuntu-latest
container: cimg/android:2022.12.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who created this image? Can we get an image with the necessary to build both the server and the client? (sorry, I'm a newbie in this domain)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These images are generated and maintained by Circle CI, a provider of CI tooling & infrastructure. I had a look at the container images which can be used for building Android apps, and this seemed to be one of the most maintained ones. The source repo is here: https://github.com/CircleCI-Public/cimg-android.

That's a long way to say I think they are fairly trustworthy. I tried to start from ubuntu:jammy and then install ADK from the Ubuntu package repositories, but the ADK that ships with Ubuntu is too old. The other option is to start from a vanilla ubuntu:jammy image (or the vanilla image for your favorite distro) and manually install the ADK. Or not run in a container at all, but directly on the GitHub actions VM, which ship with the ADK as well: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#android.

In general, I think you're better of using containers because it shields you from any changes on the underlying build machines.

For the app, I would recommend running the build for the app in a separate job in a separate container, as the build dependencies are quite different: the server requires the ADK, the app itself requires headers for libav*, libusb, mingw and a bunch of other dependencies.

I originally had a job which would build the client as well, but then decided against it as I didn't have the time to fully complete that work (done is better than perfect, I guess).

Copy link
Contributor

@yume-chan yume-chan Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My dev container dockerfile is also based on cimg/android, just only contains the essential components for building Scrcpy: https://github.com/yume-chan/scrcpy-devcontainer/blob/9a7b20391574d25617241d07b75457c9f22dd1a2/.devcontainer/Dockerfile#L30-L51. The origin one needs much more disk space but it should not be an issue on CI.

steps:
- uses: actions/checkout@v2
- name: Build
run: |
./gradlew -p server assembleRelease
- uses: actions/upload-artifact@v2
with:
name: scrcpy
path: ./server/build/outputs/apk/release/
1 change: 1 addition & 0 deletions server/build_without_gradle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ echo "Compiling java sources..."
cd ../java
javac -bootclasspath "$ANDROID_JAR" -cp "$CLASSES_DIR" -d "$CLASSES_DIR" \
-source 1.8 -target 1.8 \
-encoding UTF-8 \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my information, was there a problem without it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_without_gradle.sh would fail when being invoked from within a vanilla Ubuntu container. I think this is because C_LANG and friends were set to ASCII. Since this repository uses UTF-8, it seemed to make sense to enforce that here as well, and this fixed the issue.
The PR as it currently stands no longer calls build_without_gradle directly so this is not needed for this MR. I can undo the change if you want, but I don't think it's wrong ;-).

com/genymobile/scrcpy/*.java \
com/genymobile/scrcpy/wrappers/*.java

Expand Down