Skip to content

Commit

Permalink
Per #675, moved scripting logic from testing workflow file into scrip…
Browse files Browse the repository at this point in the history
…ts to call and moved name of steps to top of step to make workflow yml more readable. ci-run-all-diff
  • Loading branch information
georgemccabe committed Jan 18, 2022
1 parent 9aa9058 commit 857b68f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 36 deletions.
9 changes: 9 additions & 0 deletions .github/jobs/copy_output_to_artifact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /bin/bash

# Called from .github/workflows/testing.yml
# Creates directory for output data artifact and
# copies output data into directory

artifact_name=${{ steps.get-artifact-name.outputs.artifact_name }}
mkdir -p artifact/${artifact_name}
cp -r ${RUNNER_WORKSPACE}/output/* artifact/${artifact_name}/
16 changes: 16 additions & 0 deletions .github/jobs/create_dirs_for_database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash

# Create directories used for use case that uses METviewer and METdatadb
# Open up write permissions for these directories so that files can
# be written by METviewer Docker container.
# Called by .github/workflows/testing.yml

if [ -z "${RUNNER_WORKSPACE}" ]; then
echo "ERROR: RUNNER_WORKSPACE env var must be set"
exit 1
fi

mkdir -p $RUNNER_WORKSPACE/mysql
mkdir -p $RUNNER_WORKSPACE/output/metviewer
chmod a+w $RUNNER_WORKSPACE/mysql
chmod a+w $RUNNER_WORKSPACE/output/metviewer
21 changes: 21 additions & 0 deletions .github/jobs/run_difference_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/bash

# Called by .github/workflows/testing.yml
# Runs Python script to perform difference testing on use case output
# to compare output to truth data.
# If any differences were reported, set GHA output var upload_diff
# to true, copy difference files to artifact directory, and return
# non-zero status. If no differences were found, set GHA output var
# upload_diff to false

artifact_name=${{ steps.get-artifact-name.outputs.artifact_name }}
.github/jobs/setup_and_run_diff.py ${{ matrix.categories }} $artifact_name

if [ "$( ls -A ${RUNNER_WORKSPACE}/diff)" ]; then
echo ::set-output name=upload_diff::true
mkdir -p artifact/diff-${artifact_name}
cp -r ${RUNNER_WORKSPACE}/diff/* artifact/diff-${artifact_name}
exit 1
fi

echo ::set-output name=upload_diff::false
14 changes: 14 additions & 0 deletions .github/jobs/save_error_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/bash

# Called from .github/workflows/testing.yml
# Call Python script to copy logs from any use case that contains "ERROR:"
# into directory to create GitHub Actions artifact.
# Sets output variable upload_error_logs to 'true' if errors occurred or
# 'false' if no errors occurred

.github/jobs/copy_error_logs.py ${RUNNER_WORKSPACE}/output artifact/error_logs
if [ -d "artifact/error_logs" ]; then
echo ::set-output name=upload_error_logs::true
else
echo ::set-output name=upload_error_logs::false
fi
54 changes: 18 additions & 36 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@ jobs:
matrix: ${{fromJson(needs.job_control.outputs.matrix)}}
steps:
- name: Create directories for database
run: |
mkdir -p $RUNNER_WORKSPACE/mysql
mkdir -p $RUNNER_WORKSPACE/output/metviewer
chmod a+w $RUNNER_WORKSPACE/mysql
chmod a+w $RUNNER_WORKSPACE/output/metviewer
run: .github/jobs/create_dirs_for_database.sh
- name: Create directory for artifacts
run: mkdir -p artifact
- uses: actions/checkout@v2

- name: Get artifact name
id: get-artifact-name
run: |
artifact_name=`.github/jobs/get_artifact_name.sh ${{ matrix.categories }}`
echo ::set-output name=artifact_name::${artifact_name}
- uses: ./.github/actions/run_tests
# run use case tests
- name: Run Use Cases
uses: ./.github/actions/run_tests
id: run_tests
with:
categories: ${{ matrix.categories }}
Expand All @@ -125,61 +125,43 @@ jobs:
- name: Save error logs
id: save-errors
if: ${{ always() && steps.run_tests.conclusion == 'failure' && matrix.categories != 'pytests' }}
run: |
.github/jobs/copy_error_logs.py \
${RUNNER_WORKSPACE}/output \
artifact/error_logs
if [ -d "artifact/error_logs" ]; then
echo ::set-output name=upload_error_logs::true
else
echo ::set-output name=upload_error_logs::false
fi
run: .github/jobs/save_error_logs.sh

# run difference testing
- name: Run difference tests
id: run-diff
if: ${{ needs.job_control.outputs.run_diff == 'true' && steps.run_tests.conclusion == 'success' && matrix.categories != 'pytests' }}
run: |
artifact_name=${{ steps.get-artifact-name.outputs.artifact_name }}
.github/jobs/setup_and_run_diff.py ${{ matrix.categories }} $artifact_name
if [ "$( ls -A ${RUNNER_WORKSPACE}/diff)" ]; then
echo ::set-output name=upload_diff::true
mkdir -p artifact/diff-${artifact_name}
cp -r ${RUNNER_WORKSPACE}/diff/* artifact/diff-${artifact_name}
exit 1
else
echo ::set-output name=upload_diff::false
fi
run: .github/jobs/run_difference_tests.sh

# copy output data to save as artifact
- name: Save output data
id: save-output
if: ${{ always() && steps.run_tests.conclusion != 'skipped' && matrix.categories != 'pytests' }}
run: |
artifact_name=${{ steps.get-artifact-name.outputs.artifact_name }}
mkdir -p artifact/${artifact_name}
cp -r ${RUNNER_WORKSPACE}/output/* artifact/${artifact_name}/
run: .github/jobs/copy_output_to_artifact.sh

- uses: actions/upload-artifact@v2
name: Upload output data artifact
- name: Upload output data artifact
uses: actions/upload-artifact@v2
if: ${{ always() && steps.run_tests.conclusion != 'skipped' && matrix.categories != 'pytests' }}
with:
name: ${{ steps.get-artifact-name.outputs.artifact_name }}
path: artifact/${{ steps.get-artifact-name.outputs.artifact_name }}
- uses: actions/upload-artifact@v2
name: Upload error logs artifact

- name: Upload error logs artifact
uses: actions/upload-artifact@v2
if: ${{ always() && steps.save-errors.outputs.upload_error_logs }}
with:
name: error_logs
path: artifact/error_logs
if-no-files-found: ignore
- uses: actions/upload-artifact@v2
name: Upload difference data artifact

- name: Upload difference data artifact
uses: actions/upload-artifact@v2
if: ${{ always() && steps.run-diff.outputs.upload_diff == 'true' }}
with:
name: diff-${{ steps.get-artifact-name.outputs.artifact_name }}
path: artifact/diff-${{ steps.get-artifact-name.outputs.artifact_name }}
if-no-files-found: ignore

create_output_data_volumes:
name: Create Output Docker Data Volumes
runs-on: ubuntu-latest
Expand Down

0 comments on commit 857b68f

Please sign in to comment.