Testing Docker image #212
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Testing Docker image | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
branches: | |
- main | |
- develop | |
tags: | |
- v* | |
schedule: | |
# Every 01:00 Sunday re-run the test on the main branch | |
- cron: '0 1 * * 0' | |
workflow_dispatch: | |
jobs: | |
docker_testing: | |
runs-on: ubuntu-latest | |
name: Running Docker testing | |
steps: | |
- name: Fetch source code | |
uses: actions/checkout@v2 | |
- name: Create folders | |
run: | | |
mkdir ./inputs && chmod 777 ./inputs | |
mkdir ./outputs && chmod 777 ./outputs | |
- name: List folder contents | |
run: | | |
echo "Current folder" && ls -la | |
echo "test_data" && ls -l ./test_data | |
- name: Copy testing data files | |
run: | | |
cp "${PWD}/test_data"/* "${PWD}/inputs/" | |
echo "inputs" && ls -l ./inputs | |
- name: Folder contents | |
run: | | |
echo "Current folder" && ls -l | |
echo "Inputs folder" && ls -l ./inputs | |
echo "Outputs folder" && ls -l ./outputs | |
- name: Build docker image | |
run: docker build -t canopycover_test:latest ./ | |
- name: Compress docker image | |
run: docker save canopycover_test:latest | gzip -7 -c - > canopycover_test_image.tar.gz | |
- name: Upload docker image | |
uses: actions/upload-artifact@v2 | |
with: | |
name: canopycover_test_image | |
path: canopycover_test_image.tar.gz | |
- name: Run docker test | |
run: docker run --rm -v "${PWD}/inputs:/inputs" -v "${PWD}/outputs:/outputs" canopycover_test:latest --working_space /outputs --metadata /inputs/meta.yaml /inputs/rgb_17_7_W.tif /inputs/mask_1.tif | |
- name: Output folder contents | |
run: echo "Outputs folder" && ls -l ./outputs | |
- name: Check outputs | |
run: | | |
cat outputs/canopycover.csv | |
chmod +x "./.github/workflows/docker_test_check_rgb.sh" | |
"./.github/workflows/docker_test_check_rgb.sh" | |
artifact_cleanup: | |
runs-on: ubuntu-latest | |
needs: [docker_testing] | |
name: Cleanup artifacts upon success | |
steps: | |
- name: Remove docker artifact | |
uses: geekyeggo/delete-artifact@v1 | |
with: | |
name: canopycover_test_image |