Testing Docker image #161
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 greenness_test:latest ./ | |
- name: Compress docker image | |
run: docker save greenness_test:latest | gzip -7 -c - > greenness_test_image.tar.gz | |
- name: Upload docker image | |
uses: actions/upload-artifact@v2 | |
with: | |
name: greenness_test_image | |
path: greenness_test_image.tar.gz | |
- name: Folder contents | |
run: | | |
echo "Current folder" && ls -l | |
echo "Inputs folder" && ls -l ./inputs | |
echo "Outputs folder" && ls -l ./outputs | |
- name: Run docker test | |
run: docker run --rm -v "${PWD}/inputs:/inputs" -v "${PWD}/outputs:/outputs" greenness_test:latest --working_space /outputs --metadata /inputs/experiment.yaml /inputs/rgb_1_2_E.tif | |
- name: Output folder contents | |
run: echo "Outputs folder" && ls -l ./outputs | |
- name: Check outputs | |
run: | | |
cat "outputs/rgb_plot.csv" | |
chmod +x "./.github/workflows/docker_test_check.sh" | |
"./.github/workflows/docker_test_check.sh" | |
- name: Data quality check | |
run: | | |
curl -sfL https://raw.githubusercontent.com/aswinkarthik/csvdiff/master/install.sh | sh -s -- -b ./csvdiff | |
echo "Showing differenced - if any" | |
./csvdiff/csvdiff './test_data/rgb_plot.csv' './outputs/rgb_plot.csv' --ignore-columns "0,1,2,3,4,5,6,7" --primary-key 4 --format rowmark | |
echo "Running check" | |
if [[ "$(./csvdiff/csvdiff './test_data/rgb_plot.csv' './outputs/rgb_plot.csv' --ignore-columns "0,1,2,3,4,5,6,7" --primary-key 4 --format rowmark 2>&1 | grep -A 5 'Rows:' | wc -l | tr -d '[:space:]')" == "1" ]]; then echo "Test greenness indicies content matches expected"; exit 0; else echo "Error - greenness indicies contents mismatch from test_data/rgb_plot.csv"; exit 1; fi; | |
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: greenness_test_image |