Tests: More fixes amd enhancments to run tests on Github Actions
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 16 May 2022 21:40:44 +0200
changeset 3459 69771a6ca4a6
parent 3458 2c712b8c736f
child 3460 d3c95ae44750
Tests: More fixes amd enhancments to run tests on Github Actions
.github/workflows/run_tests_in_docker.yml
tests/tools/Docker/beremiz-sikuli/Dockerfile
--- a/.github/workflows/run_tests_in_docker.yml	Mon May 16 13:01:54 2022 +0200
+++ b/.github/workflows/run_tests_in_docker.yml	Mon May 16 21:40:44 2022 +0200
@@ -12,18 +12,56 @@
 
     steps:
     - uses: actions/checkout@v3
-        
-    - name: Create docker image
+      with:
+          path: beremiz
+
+    - uses: actions/checkout@v3
+      with:
+          repository: beremiz/matiec
+          ref: 2a25f4dbf4e2b1e017a3a583db7dede4771fe523
+          path: matiec
+
+    - name: Cache docker image
+      id: cache-docker
+      uses: actions/cache@v3
+      env:
+        cache-name: cache-docker
+      with:
+        path: /tmp/latest.tar
+        key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('beremiz/tests/tools/Docker/beremiz-sikuli') }}
+        restore-keys: |
+          ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('beremiz/tests/tools/Docker/beremiz-sikuli') }}
+
+    - if: ${{ steps.cache-docker.outputs.cache-hit == false }}
+      name: Create docker image
       run: |
-        cd tests/tools/Docker/beremiz-sikuli
+        cd beremiz/tests/tools/Docker/beremiz-sikuli
         ./build_docker_image.sh
-        
+        docker export --output="/tmp/latest.tar" beremiz_sikuli
+
+    - if: ${{ steps.cache-docker.outputs.cache-hit == true }}
+      name: Re-use docker image
+      run: |
+        docker load --input="/tmp/latest.tar" 
+
     - name: Create docker container
       run: |
-        cd tests/tools/Docker/beremiz-sikuli
+        cd beremiz/tests/tools/Docker/beremiz-sikuli
         ./create_docker_container.sh
         
     - name: Run tests in docker
       run: |
-        cd tests/tools/Docker/beremiz-sikuli
-        ./build_in_docker.sh
+        mkdir ${{ github.workspace }}/test
+        cd beremiz/tests/tools/Docker/beremiz-sikuli
+        ./build_in_docker.sh test_dir=${{ github.workspace }}/test
+
+    - name: Collect test results
+      run: |
+        tar cvfz /tmp/test_results.tgz ${{ github.workspace }}/test
+
+    - name: Upload test resuts artifact
+      uses: actions/upload-artifact@v3
+      with:
+        name: test_results
+        path: /tmp/test_results.tgz
+        retention-days: 5
--- a/tests/tools/Docker/beremiz-sikuli/Dockerfile	Mon May 16 13:01:54 2022 +0200
+++ b/tests/tools/Docker/beremiz-sikuli/Dockerfile	Mon May 16 21:40:44 2022 +0200
@@ -48,7 +48,7 @@
     ) | install /dev/stdin /usr/local/bin/sikulix
 
 
-RUN echo -e '#!/bin/bash\nmake -f /home/testing/src/beremiz/tests/Makefile' > /usr/local/bin/do_tests
+RUN echo -e '#!/bin/bash\nmake -f /home/testing/src/beremiz/tests/Makefile $*' > /usr/local/bin/do_tests
 RUN chmod +x /usr/local/bin/do_tests
 
 USER $UNAME