Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update testing environment #21

Merged
merged 16 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this will only run when a pull request is created. On subsequent pushes to that PR it will not run. Not sure if this is the behavior you want or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it will run again if you push to the branch the PR originates from:

Runs your workflow when activity on a pull request in the workflow's repository occurs. 
For example, if no activity types are specified, the workflow runs when a pull request 
is opened or reopened or when the head branch of the pull request is updated. 

from https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to add a push trigger


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

jobs:
check_changelog_update:
runs-on: ubuntu-latest
container:
image: alpine:3.14
Comment on lines +14 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never used a container in GH actions. What's the function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for running on a Docker image. I don't think this is actually needed here. I'll remove it if it isn't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still curious about this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the docker image is needed. It's a standard Linux environment that is minimal in size: https://hub.docker.com/_/alpine/


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
Comment on lines +25 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This may not stay for long, as I'm noticing locally that when cyclus is installed locally it isn't able to find the archetype. I'll dig into this a bit more.

Copy link
Collaborator Author

@abachma2 abachma2 Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run the CI with the mamba build see run 129, I think it finds cyclus. So this build configuration will stay.


- 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)
Loading