Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 675 Continuous Integration Documentation #1409

Merged
merged 41 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
857b68f
Per #675, moved scripting logic from testing workflow file into scrip…
georgemccabe Jan 18, 2022
18f66a7
checkout repo before calling scripts that were moved to the repo
georgemccabe Jan 18, 2022
badde7b
added whitespace for readability, ci-run-all-diff
georgemccabe Jan 18, 2022
3ee4356
pass in variables that are generated by GHA workflow into scripts as …
georgemccabe Jan 18, 2022
c3ed96f
Per #675, adding content to CI section of Contributor's Guide
georgemccabe Jan 19, 2022
c99fbca
formatting changes to workflow file
georgemccabe Jan 19, 2022
674ce6f
Per #675, do not trigger workflow on pull request synchronize to avoi…
georgemccabe Jan 19, 2022
c342011
made reference branch that triggered workflow from external repositor…
georgemccabe Jan 19, 2022
fb690fb
list GitHub username instead of email address in workflow triggered b…
georgemccabe Jan 19, 2022
e77644d
fixed URL
georgemccabe Jan 19, 2022
41bd571
Per #675, added images of screenshots from GHA
georgemccabe Jan 19, 2022
ed8fd1a
Per #675, moved outputs from job_control job after steps for readability
georgemccabe Jan 19, 2022
f32283f
per #675, added more content about CI
georgemccabe Jan 19, 2022
6338cf7
added CRITICAL documentation output to log summary, minor change to t…
georgemccabe Jan 19, 2022
c701fe6
fix critical errors by adjusting header notation
georgemccabe Jan 19, 2022
5c53bb4
Merge branch 'develop' into feature_675_ci_doc
georgemccabe Jan 25, 2022
cec3864
Per #675, added more information about CI
georgemccabe Jan 26, 2022
20c84da
Merge branch 'develop' into feature_675_ci_doc
georgemccabe Feb 2, 2022
600ccca
removed commit keyword overrides that are no longer relevant
georgemccabe Feb 2, 2022
1f7758e
added pull request synchronize back
georgemccabe Feb 2, 2022
045b32a
Per #675, added more content to documentation and adjusted headers
georgemccabe Feb 2, 2022
51f81cd
moved content from Adding New Use Case chapter to CI chapter and link…
georgemccabe Feb 3, 2022
6351f6e
removed dependency from use case list that is no longer used, ci-run-…
georgemccabe Feb 3, 2022
e71bc46
added cartopy dependencies back to all use cases file because it may …
georgemccabe Feb 3, 2022
502868a
Per #675, added more information about CI use case tests
georgemccabe Feb 3, 2022
5b202dc
fixed typo in reference label
georgemccabe Feb 3, 2022
056c76b
Per #675, renamed ci directory to scripts because the files in the di…
georgemccabe Feb 3, 2022
0040c31
fixed typos
georgemccabe Feb 3, 2022
37313fe
Per #675, move information about output artifacts to the appropriate …
georgemccabe Feb 3, 2022
fa07c71
Per #675, updated information about use case dependencies
georgemccabe Feb 3, 2022
fc16a56
testing that metdatadb and metplus dependencies can be removed from u…
georgemccabe Feb 3, 2022
795f86a
fixed headers
georgemccabe Feb 3, 2022
d0597ba
add metdatadb requirement back since it is needed for the use cases, …
georgemccabe Feb 3, 2022
6610fc8
Per #675, added documentation describing the difference testing
georgemccabe Feb 3, 2022
a049f2b
Per #675, remove logic to save job control status as artifact since i…
georgemccabe Feb 3, 2022
b994121
Per #675, clean up wording and formatting
georgemccabe Feb 3, 2022
ba66074
Update docs/Contributors_Guide/continuous_integration.rst ci-skip-all
georgemccabe Feb 3, 2022
90a8545
Update docs/Contributors_Guide/continuous_integration.rst ci-skip-all
georgemccabe Feb 3, 2022
0c87b42
Update docs/Contributors_Guide/continuous_integration.rst ci-skip-all
georgemccabe Feb 3, 2022
424b975
Per #675, various changes to doc based on feedback from PR review
georgemccabe Feb 3, 2022
d13afb0
Merge branch 'feature_675_ci_doc' of github.com:dtcenter/METplus into…
georgemccabe Feb 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/jobs/build_documentation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if [ -s $warning_file ]; then
echo Summary:
grep WARNING ${DOCS_DIR}/_build/warnings.log
grep ERROR ${DOCS_DIR}/_build/warnings.log
grep CRITICAL ${DOCS_DIR}/_build/warnings.log
echo Review this log file or download documentation_warnings.log artifact
exit 1
fi
Expand Down
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=$1
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
2 changes: 1 addition & 1 deletion .github/jobs/create_output_data_volumes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if [ $? != 0 ]; then
exit 1
fi

docker_data_output_dir=ci/docker/docker_data_output
docker_data_output_dir=scripts/docker/docker_data_output

success=1
for vol_name in use_cases_*; do
Expand Down
4 changes: 2 additions & 2 deletions .github/jobs/docker_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ duration=$(( SECONDS - start_seconds ))
echo "TIMING: docker pull ${DOCKERHUB_TAG} took `printf '%02d' $(($duration / 60))`:`printf '%02d' $(($duration % 60))` (MM:SS)"

# set DOCKERFILE_PATH that is used by docker hook script get_met_version
export DOCKERFILE_PATH=${GITHUB_WORKSPACE}/ci/docker/Dockerfile
export DOCKERFILE_PATH=${GITHUB_WORKSPACE}/scripts/docker/Dockerfile

MET_TAG=`${GITHUB_WORKSPACE}/ci/docker/hooks/get_met_version`
MET_TAG=`${GITHUB_WORKSPACE}/scripts/docker/hooks/get_met_version`

# if MET_FORCE_TAG variable is set and not empty, use that version instead
if [ ! -z "$MET_FORCE_TAG" ]; then
Expand Down
23 changes: 23 additions & 0 deletions .github/jobs/run_difference_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /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

matrix_categories=$1
artifact_name=$2

.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
35 changes: 3 additions & 32 deletions .github/jobs/set_job_controls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# a push to determine which jobs to run and which to skip.

# set default status for jobs
run_docs=true
run_get_image=true
run_get_input_data=true
run_unit_tests=true
Expand Down Expand Up @@ -49,7 +48,6 @@ else

# check commit messages for skip or force keywords
if grep -q "ci-skip-all" <<< "$commit_msg"; then
run_docs=false
run_get_image=false
run_get_input_data=false
run_unit_tests=false
Expand All @@ -66,18 +64,9 @@ else
run_unit_tests=false
fi

if grep -q "ci-only-docs" <<< "$commit_msg"; then
run_docs=true
run_get_image=false
run_get_input_data=false
run_unit_tests=false
run_use_cases=false
run_save_truth_data=false
run_diff=false
fi

if grep -q "ci-only-new-cases" <<< "$commit_msg"; then
run_all_use_cases=false
if grep -q "ci-run-all-cases" <<< "$commit_msg"; then
run_use_cases=true
run_all_use_cases=true
fi

if grep -q "ci-run-all-diff" <<< "$commit_msg"; then
Expand All @@ -89,26 +78,8 @@ else
run_diff=true
fi

if grep -q "ci-run-all-cases" <<< "$commit_msg"; then
run_use_cases=true
run_all_use_cases=true
fi

fi

touch job_control_status
echo run_docs=${run_docs} >> job_control_status
echo run_get_image=${run_get_image} >> job_control_status
echo run_get_input_data=${run_get_input_data} >> job_control_status
echo run_unit_tests=${run_unit_tests} >> job_control_status
echo run_use_cases=${run_use_cases} >> job_control_status
echo run_save_truth_data=${run_save_truth_data} >> job_control_status
echo run_all_use_cases=${run_all_use_cases} >> job_control_status
echo run_diff=${run_diff} >> job_control_status
echo external_trigger=${external_trigger} >> job_control_status
echo Job Control Settings:
cat job_control_status

echo ::set-output name=run_get_image::$run_get_image
echo ::set-output name=run_get_input_data::$run_get_input_data
echo ::set-output name=run_diff::$run_diff
Expand Down
105 changes: 50 additions & 55 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Testing

on:

push:
branches:
- develop
- develop-ref
- feature_*
- main_*
- bugfix_*
- 'feature_*'
- 'main_*'
- 'bugfix_*'
paths-ignore:
- docs/**
- 'docs/**'

pull_request:
types: [opened, reopened, synchronize]
types: [opened, synchronize, reopened]
paths-ignore:
- docs/**
- 'docs/**'

workflow_dispatch:
inputs:
repository:
Expand All @@ -23,14 +27,16 @@ on:
required: true
ref:
description: 'Branch that triggered event'
required: true
actor:
description: 'User that triggered the event'
pusher_email:
description: 'Email address of user who triggered push event'

jobs:

event_info:
name: "Trigger: ${{ github.event_name != 'workflow_dispatch' && github.event_name || github.event.inputs.repository }} ${{ github.event_name != 'workflow_dispatch' && 'local' || github.event.inputs.pusher_email }} ${{ github.event_name != 'workflow_dispatch' && 'event' || github.event.inputs.sha }}"
name: "Trigger: ${{ github.event_name != 'workflow_dispatch' && github.event_name || github.event.inputs.repository }} ${{ github.event_name != 'workflow_dispatch' && 'local' || github.event.inputs.actor }} ${{ github.event_name != 'workflow_dispatch' && 'event' || github.event.inputs.sha }}"
runs-on: ubuntu-latest
steps:
- name: Print GitHub values for reference
Expand All @@ -41,6 +47,15 @@ jobs:
job_control:
name: Determine which jobs to run
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set job controls
id: job_status
run: .github/jobs/set_job_controls.sh
env:
commit_msg: ${{ github.event.head_commit.message }}

outputs:
matrix: ${{ steps.job_status.outputs.matrix }}
run_some_tests: ${{ steps.job_status.outputs.run_some_tests }}
Expand All @@ -49,17 +64,7 @@ jobs:
run_diff: ${{ steps.job_status.outputs.run_diff }}
run_save_truth_data: ${{ steps.job_status.outputs.run_save_truth_data }}
external_trigger: ${{ steps.job_status.outputs.external_trigger }}
steps:
- uses: actions/checkout@v2
- name: Set job controls
id: job_status
run: .github/jobs/set_job_controls.sh
env:
commit_msg: ${{ github.event.head_commit.message }}
- uses: actions/upload-artifact@v2
with:
name: job_control_status
path: job_control_status

get_image:
name: Docker Setup - Get METplus Image
runs-on: ubuntu-latest
Expand All @@ -76,23 +81,28 @@ jobs:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
#MET_FORCE_TAG: 10.0.0

update_data_volumes:
name: Docker Setup - Update Data Volumes
runs-on: ubuntu-latest
needs: job_control
if: ${{ needs.job_control.outputs.run_get_input_data == 'true' }}
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.6'

- name: Install dependencies
run: python -m pip install --upgrade pip python-dateutil requests bs4

- name: Update Data Volumes
run: .github/jobs/docker_update_data_volumes.py
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

use_case_tests:
name: Use Case Tests
runs-on: ubuntu-latest
Expand All @@ -102,21 +112,24 @@ jobs:
fail-fast: false
matrix: ${{fromJson(needs.job_control.outputs.matrix)}}
steps:

- uses: actions/checkout@v2

- 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 +138,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 ${{ matrix.categories }} ${{ steps.get-artifact-name.outputs.artifact_name }}

# 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 ${{ steps.get-artifact-name.outputs.artifact_name }}

- 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
Loading