Skip to content

Commit

Permalink
Merge pull request #21 from abachma2/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yardasol authored Jul 17, 2024
2 parents 1ad3ae1 + 7b36520 commit 3723a28
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 141 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/changelog_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Changelog update check

on:
# allows us to run workflows manually
workflow_dispatch:
pull_request:

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
check_changelog_update:
runs-on: ubuntu-latest
container:
image: alpine:3.14

name: Check if Changelog has been updated
steps:
- name: Install latest git
run: |
apk add --no-cache bash git openssh
git --version
- name: Checkout repository
uses: actions/checkout@v4

- run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
cd $GITHUB_WORKSPACE
git remote add arfc https://github.com/arfc/openmcyclus.git
git fetch arfc
change=`git diff arfc/main -- CHANGELOG.rst | wc -l`
git remote remove arfc
if [ $change -eq 0 ]; then
echo "CHANGELOG.rst has not been updated"
exit 1
fi
26 changes: 7 additions & 19 deletions .github/workflows/test-openmcyclus.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: test-openmcyclus
on: [pull_request]
on: [pull_request, push]

jobs:
build-and-test:
integration-tests:
runs-on: ubuntu-latest
container:
image: cyclus/cycamore
defaults:
run:
shell: bash -l {0}
Expand All @@ -18,35 +16,25 @@ jobs:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: openmcyclus-env
environment-file: environment.yml
use-mamba: true

- name: Conda config
run: |
conda config --env --set pip_interop_enabled True
- name: Update Environment
- name: Install dependencies
run: |
pip install pytest
mamba env update -n openmcyclus-env -f environment.yml
mamba install -y cycamore openmc scipy=1.11 pytest
- name: Install OpenMC cross section library
run: $GITHUB_WORKSPACE/openmc-xs.bash

- name: Install OpenMC from Mamba
run: mamba install openmc

- name: Install OpenMC cross section library
run: echo "OPENMC_CROSS_SECTIONS=cross_sections.xml" >> $GITHUB_ENV
run: |
$GITHUB_WORKSPACE/openmc-xs.bash
echo "OPENMC_CROSS_SECTIONS=cross_sections.xml" >> $GITHUB_ENV
- name: Install OpenMCyclus
run: |
pip install .
# - name: Check environment
# run: |
# pip install pytest

# - name: Run Tests
# run: |
# pytest tests/integration_tests/test_depletereactor.py
5 changes: 2 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: unit-tests
on: [pull_request, push]

jobs:
build-and-unit-test:
unit-test:
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -16,7 +16,6 @@ jobs:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: openmcyclus-env
environment-file: environment.yml
use-mamba: true

- name: Conda config
Expand All @@ -25,7 +24,7 @@ jobs:
- name: Install OpenMC from Mamba
run:
mamba install openmc scipy=1.11
mamba install openmc scipy=1.11 pytest

- name: Install OpenMC cross section library
run: |
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@ Since last release:
* Add input parameters to `DepleteReactor` for the thermal
power (instead of just using `power_cap`) and flux
(required input for running OpenMC with new version) (#18)
* Add CI test to check if CHANGELOG has been updated (#21)

**Changed:**

* Change OpenMC dependency to v0.14.0, which includes adding
parameters for using `DepleteReactor` (#18)
* Simplify CI build environment, using conda builds instead of
building from source (#21)


**Removed:**

* Remove `check_existing_recipes` method in `DepleteReactor` (#18)
* Remove various files in repo that are no longer used for building
CI environment (#21)

**Fixed:**

Expand Down
7 changes: 0 additions & 7 deletions build-cyclus.sh

This file was deleted.

11 changes: 0 additions & 11 deletions build-openmc.sh

This file was deleted.

50 changes: 0 additions & 50 deletions environment.yml

This file was deleted.

45 changes: 0 additions & 45 deletions requirements.txt

This file was deleted.

15 changes: 9 additions & 6 deletions tests/unit_tests/test_depletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def setUp(self):
10,
100e-6,
"./examples/")
self.materials = openmc.Materials().from_xml("./examples/materials.xml")
self.materials = openmc.Materials().from_xml(
"./examples/materials.xml")
self.micro_xs = od.MicroXS.from_csv("./examples/micro_xs.csv")

def run_depletion(self, flux):
Expand Down Expand Up @@ -66,11 +67,11 @@ def test_update_materials(self):
openmc.material.NuclideTuple('U235', 0.05, 'wo'),
openmc.material.NuclideTuple('U238', 0.95, 'wo')]
assert materials[1].nuclides == [
openmc.material.NuclideTuple('Cs137', 0.1, 'wo'),
openmc.material.NuclideTuple('Kr85', 0.80, 'wo'),
openmc.material.NuclideTuple('Cs137', 0.1, 'wo'),
openmc.material.NuclideTuple('Kr85', 0.80, 'wo'),
openmc.material.NuclideTuple('Xe135', 0.10, 'wo')]
assert materials[2].nuclides == [
openmc.material.NuclideTuple('Pu239', 0.10, 'wo'),
openmc.material.NuclideTuple('Pu239', 0.10, 'wo'),
openmc.material.NuclideTuple('Pu241', 0.90, 'wo')]
assert material_ids == [5, 6, 7]

Expand All @@ -96,5 +97,7 @@ def test_get_spent_comps(self):
assert 551370000 in spent_comps[0].keys()
assert 922350000 in spent_comps[0].keys()
assert 932410000 not in spent_comps[0].keys()
assert spent_comps[0][922350000] == 10.650004036820036
assert spent_comps[0][942390000] == 0.22663550016678385
assert spent_comps[0][922350000] == pytest.approx(
10.650004036820036, rel=1e-5)
assert spent_comps[0][942390000] == pytest.approx(
0.22663550016678385, rel=1e-5)

0 comments on commit 3723a28

Please sign in to comment.