Skip to content

Commit fa5f105

Browse files
committed
Updated base image and adjusted
1 parent 6e5ed83 commit fa5f105

File tree

20 files changed

+103
-115
lines changed

20 files changed

+103
-115
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,8 @@ jobs:
1515
- name: Checkout the repo
1616
uses: actions/checkout@v4
1717

18-
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v5
20-
with:
21-
python-version: ${{ matrix.python-version }}
22-
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
cd cli
27-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28-
29-
- name: Run test
30-
run: |
31-
cd cli && nosetests -v
18+
- name: Run unit-test
19+
run: script -e -c "./app.sh test emulator test 11.0 && sudo mv tmp/* ."
3220

3321
release_base:
3422
runs-on: ubuntu-24.04
@@ -56,9 +44,18 @@ jobs:
5644
- name: Checkout the repo
5745
uses: actions/checkout@v4
5846

47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
5950
- name: Get release version
6051
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
6152

53+
- name: Set up extension
54+
run: |
55+
echo "${{ secrets.extension }}" > extension.sh > /dev/null 2>&1
56+
chmod 700 extension.sh
57+
shell: bash
58+
6259
- name: Build and push emulator image ${{ matrix.android }} (${RELEASE_VERSION})
6360
run: |
6461
docker login -u=${{secrets.DOCKER_USERNAME}} -p=${{secrets.DOCKER_PASSWORD}}
@@ -72,9 +69,18 @@ jobs:
7269
- name: Checkout the repo
7370
uses: actions/checkout@v4
7471

72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
7575
- name: Get release version
7676
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
7777

78+
- name: Set up extension
79+
run: |
80+
echo "${{ secrets.extension }}" > extension.sh > /dev/null 2>&1
81+
chmod 700 extension.sh
82+
shell: bash
83+
7884
- name: Build and push genymotion image (${RELEASE_VERSION})
7985
run: |
8086
docker login -u=${{secrets.DOCKER_USERNAME}} -p=${{secrets.DOCKER_PASSWORD}}

.github/workflows/test.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,22 @@ jobs:
1515
- name: Checkout the repo
1616
uses: actions/checkout@v4
1717

18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Set up extension
22+
run: |
23+
echo "${{ secrets.extension }}" > extension.sh > /dev/null 2>&1
24+
chmod 700 extension.sh
25+
shell: bash
26+
1827
- name: Build base image
1928
run: script -e -c "./app.sh build base test"
2029

21-
- name: Build emulator image and run unit-test
30+
- name: Build sample image
31+
run: script -e -c "./app.sh build emulator test 11.0"
32+
33+
- name: Run unit-test
2234
run: script -e -c "./app.sh test emulator test 11.0 && sudo mv tmp/* ."
2335

2436
- name: Publish test result

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ tmp/
1717

1818
# Dev-files
1919
n*.txt
20-
test-*.sh
20+
e*.sh

app.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@ echo "${IMAGE_NAME_SPECIFIC_RELEASE} or ${IMAGE_NAME_LATEST} "
8181

8282
function build() {
8383
# autopep8 --recursive --exclude=.git,__pycache__,venv --max-line-length=120 --in-place .
84-
cmd="docker build -t ${IMAGE_NAME_SPECIFIC_RELEASE} --build-arg DOCKER_ANDROID_VERSION=${r_v} "
84+
cmd="docker build --no-cache -t ${IMAGE_NAME_SPECIFIC_RELEASE} --build-arg DOCKER_ANDROID_VERSION=${r_v} "
8585
if [ -n "${a_v}" ]; then
86-
cmd+="--build-arg EMULATOR_ANDROID_VERSION=${a_v} --build-arg EMULATOR_API_LEVEL=${a_l} "
86+
DOCKER_BUILDKIT=1
87+
cmd="${cmd} --secret id=extension,src=extension.sh --build-arg EMULATOR_ANDROID_VERSION=${a_v} --build-arg EMULATOR_API_LEVEL=${a_l} "
88+
fi
89+
90+
if [[ "${p}" == *"genymotion"* ]]; then
91+
DOCKER_BUILDKIT=1
92+
cmd="${cmd} --secret id=extension,src=extension.sh "
8793
fi
8894

8995
cmd+="-f ${FOLDER_PATH} ."
@@ -97,18 +103,14 @@ function build() {
97103
}
98104

99105
function test() {
100-
cli_path="/home/androidusr/docker-android/cli"
101-
results_path="test-results"
102-
tmp_folder="tmp"
106+
tmp_folder="/app/tmp"
103107

104108
mkdir -p tmp
105-
build
106-
docker run -it --rm --name test --entrypoint /bin/bash \
107-
-v $PWD/${tmp_folder}:${cli_path}/${tmp_folder} ${IMAGE_NAME_SPECIFIC_RELEASE} \
108-
-c "cd ${cli_path} && sudo rm -rf ${tmp_folder}/* && \
109-
nosetests -v && sudo mv .coverage ${tmp_folder} && \
110-
sudo cp -r ${results_path}/* ${tmp_folder} && sudo chown -R 1300:1301 ${tmp_folder} &&
111-
sudo chmod a+x -R ${tmp_folder}"
109+
docker run -it --rm -v "$PWD":/app -w /app python:3.12-slim bash \
110+
-c "cd cli && rm -rf ${tmp_folder}/* && \
111+
pip install --upgrade pip && pip install -r requirements.txt && \
112+
PYTHONPATH=src pytest -v && mv test-results/* ${tmp_folder}/ && chown -R 1300:1301 ${tmp_folder} && \
113+
chmod a+x -R ${tmp_folder}"
112114
}
113115

114116
function push() {

cli/requirements.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
autopep8==2.3.1
2-
click==8.1.8
3-
coverage==7.6.1
1+
autopep8==2.3.2
2+
click==8.2.1
3+
coverage==7.8.1
44
mock==5.2.0
5-
nose==1.3.7
5+
pytest==8.4.1
6+
pytest-cov==6.2.1
7+
pytest-xdist==3.7.0
68
requests==2.32.3
9+
setuptools==80.8.0

cli/setup.cfg

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
[nosetests]
2-
cover-xml=true
3-
cover-xml-file=test-results/coverage.xml
4-
with-coverage=true
5-
cover-package=src
6-
cover-erase=true
7-
with-xunit=true
8-
xunit-file=test-results/xunit.xml
9-
cover-html=true
10-
cover-html-dir=test-results/coverage
1+
[tool:pytest]
2+
addopts =
3+
--cov=src
4+
--cov-report=html:test-results/html
5+
--cov-report=xml:test-results/coverage.xml
6+
--junit-xml=test-results/junit-report.xml
7+
testpaths = src/tests

cli/setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from setuptools import setup
3+
from setuptools import setup, find_packages
44

55

66
app_version = os.getenv("DOCKER_ANDROID_VERSION", "test-version")
@@ -10,12 +10,14 @@
1010

1111
setup(
1212
name="docker-android",
13-
version=app_version,
13+
version="0.1",
1414
url="https://github.com/budtmo/docker-android",
1515
description="CLI for docker-android",
1616
author="Budi Utomo",
1717
author_email="budtmo.os@gmail.com",
1818
install_requires=reqs,
19+
packages=find_packages(where="src"),
20+
package_dir={"": "src"},
1921
py_modules=["cli", "docker-android"],
20-
entry_points={"console_scripts": "docker-android=src.app:cli"}
21-
)
22+
entry_points={"console_scripts": "docker-android=app:cli"}
23+
)

cli/src/app.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
from enum import Enum
1010

11-
from src.application import Application
12-
from src.device import DeviceType
13-
from src.device.emulator import Emulator
14-
from src.device.geny_aws import GenyAWS
15-
from src.device.geny_saas import GenySAAS
16-
from src.helper import convert_str_to_bool, get_env_value_or_raise
17-
from src.constants import ENV
18-
from src.logger import log
11+
from application import Application
12+
from device import DeviceType
13+
from device.emulator import Emulator
14+
from device.geny_aws import GenyAWS
15+
from device.geny_saas import GenySAAS
16+
from helper import convert_str_to_bool, get_env_value_or_raise
17+
from constants import ENV
18+
from logger import log
1919

2020
log.init()
2121
logger = logging.getLogger("App")

cli/src/device/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from abc import ABC, abstractmethod
1010
from enum import Enum
1111

12-
from src.helper import convert_str_to_bool, get_env_value_or_raise
13-
from src.constants import DEVICE, ENV
12+
from helper import convert_str_to_bool, get_env_value_or_raise
13+
from constants import DEVICE, ENV
1414

1515

1616
class DeviceType(Enum):

cli/src/device/emulator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
from enum import Enum
77

8-
from src.device import Device, DeviceType
9-
from src.helper import convert_str_to_bool, get_env_value_or_raise, symlink_force
10-
from src.constants import ENV, UTF8
8+
from device import Device, DeviceType
9+
from helper import convert_str_to_bool, get_env_value_or_raise, symlink_force
10+
from constants import ENV, UTF8
1111

1212

1313
class Emulator(Device):

0 commit comments

Comments
 (0)