Added Unit Tests for CI Codes #34
Workflow file for this run
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: CI Unit Tests | |
on: [push, 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.8 | |
- 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 | |
- 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 | |
run: | | |
# Link python pacakges in ush/python | |
# TODO: This will be unnecessary when these are part of the virtualenv | |
packages=("wxflow" "jcb") | |
for package in "${packages[@]}"; do | |
cd "${GITHUB_WORKSPACE}/ush/python" || exit 1 | |
[[ -s "${package}" ]] && rm -f "${package}" | |
ln -fs "${GITHUB_WORKSPACE}/sorc/${package}/src/${package}" . | |
done | |
# Link wxflow in workflow and ci/scripts | |
# TODO: This will be unnecessary when wxflow is part of the virtualenv | |
cd "${GITHUB_WORKSPACE}/workflow" || exit 1 | |
[[ -s "wxflow" ]] && rm -f wxflow | |
ln -fs "${GITHUB_WORKSPACE}/sorc/wxflow/src/wxflow" . | |
cd "${GITHUB_WORKSPACE}/ci/scripts" || exit 1 | |
[[ -s "wxflow" ]] && rm -f wxflow | |
ln -fs "${GITHUB_WORKSPACE}/sorc/wxflow/src/wxflow" . | |
export PYTHONPATH="${GITHUB_WORKSPACE}/sorc/wxflow/src/wxflow:${GITHUB_WORKSPACE}/workflow:${GITHUB_WORKSPACE}/ci/scripts:${PYTHONPATH}" | |
cd $GITHUB_WORKSPACE/ci/scripts/tests | |
pytest -v --junitxml $GITHUB_WORKSPACE/ci/scripts/tests/test-results.xml | |
- name: List test directory | |
run: ls -la $GITHUB_WORKSPACE/ci/scripts/tests | |
- 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 |