Skip to content

Commit

Permalink
Adding GHA CI file
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Aug 15, 2024
1 parent ca595cb commit 29741d8
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

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

jobs:
main:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: true
activate-environment: ""

- name: Install OpenMC
shell: bash
run: |
conda config --add channels conda-forge
conda install -c conda_forge openmc==0.15.0
- name: Clone OpenMC
run: |
git clone https://github.com/openmc-dev/openmc --branch v0.15.0 $HOME
- name: Test examples
run: |
OPENMC_EXAMPLES_DIR=$HOME/openmc/examples pytest -v ./test/test_examples.py
32 changes: 32 additions & 0 deletions test/test_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
from pathlib import Path

import pytest

from openmc_cad_adapter import to_cubit_journal
import openmc


examples = ["pincell/build_xml.py",
"lattice/hexagonal/build_xml.py",
"assembly/assembly.py"]

if 'OPENMC_EXAMPLES_DIR' not in os.environ:
raise EnvironmentError('Variable OPENMC_EXAMPLES_DIR is required')

OPENMC_EXAMPLES_DIR = Path(os.environ['OPENMC_EXAMPLES_DIR']).resolve()

def example_name(example):
return '-'.join(example.split('/')[:-1])

@pytest.mark.parametrize("example", examples, ids=example_name)
def test_example(example):

openmc.reset_auto_ids()
exec(open(OPENMC_EXAMPLES_DIR / example).read())

openmc.reset_auto_ids()
model = openmc.Model.from_xml()

world = [500, 500, 500]
to_cubit_journal(model.geometry, world=world, filename=example_name(example))

0 comments on commit 29741d8

Please sign in to comment.