Skip to content

Commit c35d4a0

Browse files
committed
ci: Build the image only once
1 parent d38698d commit c35d4a0

2 files changed

Lines changed: 34 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: echo "CONTAINER=ouisync-unit-test-linux-$GITHUB_RUN_ID" >> $GITHUB_ENV
3030

3131
- name: Start container
32-
run: ./docker/linux.sh --container $CONTAINER --srcdir . --cache start
32+
run: ./docker/linux.sh --container $CONTAINER --srcdir . --cache container start
3333

3434
- name: Analyze
3535
run: ./docker/linux.sh --container $CONTAINER analyze
@@ -38,7 +38,7 @@ jobs:
3838
run: ./docker/linux.sh --container $CONTAINER unit-test
3939

4040
- name: Stop container
41-
run: ./docker/linux.sh --container $CONTAINER stop
41+
run: ./docker/linux.sh --container $CONTAINER container stop
4242
if: always()
4343

4444
test_windows:
@@ -278,9 +278,16 @@ jobs:
278278
name: ${{ matrix.name }}
279279
path: releases/release_*/${{ matrix.artifact-files }}
280280

281+
build_image_for_integration_test_android:
282+
name: "build docker image to run integration tests on android"
283+
runs-on: self-hosted
284+
steps:
285+
- run: ./docker/linux.sh container build
286+
281287
integration_test_android:
282288
name: "run integration tests on android ${{ matrix.api-level }}"
283289
runs-on: self-hosted
290+
needs: ["build_image_for_integration_test_android"]
284291
strategy:
285292
fail-fast: false
286293
matrix:

docker/linux.sh

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,15 @@ function print_help() {
9090
echo
9191
echo "Usage: $0 analyze"
9292
;;
93-
"start")
94-
echo "Explicitly start the container"
93+
"container")
94+
echo "Explicitly manage the container"
9595
echo
96-
echo "Usage: $0 start"
96+
echo "Usage: $0 container <start|stop|build>"
9797
echo
98-
echo "Subsequent commands run on this container instead of starting a new one."
99-
;;
100-
"stop")
101-
echo "Explicitly stop the container"
102-
echo
103-
echo "Usage: $0 stop"
98+
echo "Commands:"
99+
echo " start Start the container"
100+
echo " stop Stop the container"
101+
echo " build Build the container image"
104102
;;
105103
"shell")
106104
echo "Run a shell session in the container"
@@ -128,8 +126,7 @@ function print_help() {
128126
echo " unit-test Run unit tests"
129127
echo " integration-test Run integration tests"
130128
echo " analyze Analyze the dart source code"
131-
echo " start Explicitly start the container"
132-
echo " stop Explicitly stop the container"
129+
echo " container Explicitly manage the container"
133130
echo
134131
echo "See '$0 help <command> for more information on a specific command"
135132
;;
@@ -326,6 +323,20 @@ function is_container_running() {
326323
fi
327324
}
328325

326+
function manage_container() {
327+
case $1 in
328+
start)
329+
start_container tail -f /dev/null
330+
;;
331+
stop)
332+
stop_container
333+
;;
334+
build)
335+
build_container
336+
;;
337+
esac
338+
}
339+
329340
function init() {
330341
# Auto-start the container unless already running
331342
is_container_running || auto_start_container
@@ -638,12 +649,6 @@ case "$1" in
638649
print_help ${@:2}
639650
exit
640651
;;
641-
start)
642-
start_container tail -f /dev/null
643-
;;
644-
stop)
645-
stop_container
646-
;;
647652
build|b)
648653
build ${@:2}
649654
;;
@@ -656,6 +661,9 @@ case "$1" in
656661
analyze)
657662
analyze ${@:2}
658663
;;
664+
container)
665+
manage_container ${@:2}
666+
;;
659667
shell|sh)
660668
init
661669
shell=1

0 commit comments

Comments
 (0)