Skip to content

Commit

Permalink
updated to python wget and renamed github action control file
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryMcGuinness-NOAA committed Jun 25, 2024
1 parent acc8d3c commit 6bcc3b5
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 10 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci_uint_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI Unit Tests
on: [pull_request, workflow_dispatch]

jobs:

ci_pytest:
runs-on: ubuntu-latest
name: Run unit tests on CI system
permissions:
checks: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10+

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y perl libxml-libxml-perl libxml-libxslt-perl libdatetime-perl
python -m pip install --upgrade pip
pip install pytest 7.2.1
pip install wxflow 0.2.0
pip install wget
- name: Cache Rocoto Install
uses: actions/cache@v4
with:
path: ~/rocoto
key: ${{ runner.os }}-rocoto-${{ hashFiles('**/ci-unit_tests.yaml') }}

- name: Install Rocoto
run: |
if [ ! -d "$HOME/rocoto/bin" ]; then
git clone https://github.com/christopherwharrop/rocoto.git $HOME/rocoto
cd $HOME/rocoto
./INSTALL
fi
echo "$HOME/rocoto/bin" >> $GITHUB_PATH
- name: Run tests
shell: bash
run: |
sudo mkdir -p /work/noaa
cd $GITHUB_WORKSPACE/sorc/wxflow
git submodule update --init
cd $GITHUB_WORKSPACE/sorc
./link_workflow.sh
cd $GITHUB_WORKSPACE/ci/scripts/tests
pytest -v --junitxml $GITHUB_WORKSPACE/ci/scripts/tests/test-results.xml
- name: Publish Test Results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: ci/scripts/tests/test-results.xml
job_summary: true
comment_mode: off
27 changes: 17 additions & 10 deletions ci/scripts/tests/test_rocotostat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import os
from shutil import rmtree
import wget

script_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(os.path.dirname(script_dir), 'utils'))
Expand All @@ -13,12 +14,15 @@
testdata_path = 'testdata/rocotostat'
testdata_full_path = os.path.join(script_dir, testdata_path)

wget = which('wget')

if not os.path.isfile(os.path.join(testdata_full_path, 'database.db')):
wget.add_default_arg([
'-P', testdata_full_path, test_data_url + str(testdata_path) + '/workflow.xml',
test_data_url + str(testdata_path) + '/database.db'])
wget()
workflow_url = test_data_url + str(testdata_path) + '/workflow.xml'
workflow_destination = os.path.join(testdata_full_path, 'workflow.xml')
wget.download(workflow_url, workflow_destination)

database_url = test_data_url + str(testdata_path) + '/database.db'
database_destination = os.path.join(testdata_full_path, 'database.db')
wget.download(database_url, database_destination)

try:
rocotostat = which('rocotostat')
Expand Down Expand Up @@ -63,12 +67,15 @@ def test_rocoto_stalled():
xml = os.path.join(testdata_full_path, 'stalled.xml')
db = os.path.join(testdata_full_path, 'stalled.db')

wget = which('wget')
if not os.path.isfile(os.path.join(testdata_full_path, 'stalled.db')):
wget.add_default_arg([
'-P', testdata_full_path, test_data_url + str(testdata_path) + '/stalled.xml',
test_data_url + str(testdata_path) + '/stalled.db'])
wget()
workflow_url = test_data_url + str(testdata_path) + '/stalled.xml'
database_url = test_data_url + str(testdata_path) + '/stalled.db'

workflow_destination = os.path.join(testdata_full_path, 'stalled.xml')
wget.download(workflow_url, workflow_destination)

database_destination = os.path.join(testdata_full_path, 'stalled.db')
wget.download(database_url, database_destination)

rocotostat = which('rocotostat')
rocotostat.add_default_arg(['-w', xml, '-d', db])
Expand Down

0 comments on commit 6bcc3b5

Please sign in to comment.