Skip to content

Commit

Permalink
add workflow for header test
Browse files Browse the repository at this point in the history
  • Loading branch information
bknueven committed Sep 14, 2024
1 parent 6d9aa5f commit b08bb41
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/testheaders.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: header test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

defaults:
run:
shell: bash -l {0}

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test_env
python-version: 3.8
auto-activate-base: false
- name: Install dependencies
run: |
conda install mpi4py "numpy<2" setuptools
pip install pyomo addheader pyyaml pytest
- name: setup the program
run: |
pip install -e .
- name: run headers test
timeout-minutes: 10
run: |
cd mpisppy/tests
python test_headers.py
34 changes: 34 additions & 0 deletions mpisppy/tests/test_headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
###############################################################################
# mpi-sppy: MPI-based Stochastic Programming in PYthon
#
# Copyright (c) 2024, Lawrence Livermore National Security, LLC, Alliance for
# Sustainable Energy, LLC, The Regents of the University of California, et al.
# All rights reserved. Please see the files COPYRIGHT.md and LICENSE.md for
# full copyright and license information.
###############################################################################

from pathlib import Path

import pytest

yaml = pytest.importorskip("yaml")
addheader = pytest.importorskip("addheader")

from addheader.add import FileFinder, detect_files
import mpisppy

def test_headers():
root = Path(mpisppy.__file__).parent.parent

conf = root / "addheader.yml"
with open(conf) as f:
conf = yaml.safe_load(f)
conf = conf["patterns"]

has_header, missing_header = detect_files(FileFinder(root, glob_patterns=conf))
nonempty_missing_header = []
for p in missing_header:
if p.stat().st_size == 0:
continue
nonempty_missing_header.append(p)
assert not nonempty_missing_header

0 comments on commit b08bb41

Please sign in to comment.