Skip to content

Commit

Permalink
Merge pull request #188 from cyclus/convert-ci
Browse files Browse the repository at this point in the history
Update Cymetric CI
  • Loading branch information
gonuke authored Nov 29, 2023
2 parents acc20f5 + bc51f4a commit 77fcf6c
Show file tree
Hide file tree
Showing 21 changed files with 2,274 additions and 2,238 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build/Test for PR and collaborator push

on:
# allows us to run workflows manually
workflow_dispatch:
pull_request:
paths-ignore:
- '.github/workflows/build_test_publish.yml'
- 'docker/**'
- 'doc/**'
- 'CHANGELOG.rst'
push:
paths-ignore:
- '.github/workflows/build_test_publish.yml'
- 'docker/**'
- 'doc/**'
- 'CHANGELOG.rst'

jobs:
build-and-test:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ubuntu_versions : [
20.04,
22.04,
]
pkg_mgr : [
apt,
conda,
]
cycamore_tag: [
latest,
]

container:
image: ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{matrix.cycamore_tag}}

steps:
- name: Checkout Cymetric
uses: actions/checkout@v3

- name: Install Cymetric Apt Dependencies
if: matrix.pkg_mgr == 'apt'
run: |
apt update --fix-missing && apt install -y python3-pip python3-pytest
- name: Install Cymetric Conda Dependencies
if: matrix.pkg_mgr == 'conda'
run: |
mamba install -y pip pytest
- name: Build Cymetric
run: |
python -m pip install --target $(python -m site --user-site) .
- name: Cymetric Tests
run: |
export PYTHONPATH=$(find /root/.local/lib -type d -name 'cyclus-*-*.egg' -print -quit)
cd tests && python -m pytest
60 changes: 60 additions & 0 deletions .github/workflows/build_test_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build and Publish Cymetric Images

on:
# allows us to run workflows manually
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/build_test_publish.yml'
- 'docker/**'
push:
branches:
- main

jobs:
build-dependency-and-test-img:
runs-on: ubuntu-latest

strategy:
matrix:
ubuntu_versions : [
20.04,
22.04,
]
pkg_mgr : [
apt,
conda,
]

name: Installing Dependencies, Building Cymetric and Running Tests
steps:
- name: default environment
run: |
echo "tag-latest-on-default=false" >> "$GITHUB_ENV"
- name: condition on trigger parameters
if: ${{ github.repository_owner == 'cyclus' && github.ref == 'refs/heads/main' }}
run: |
echo "tag-latest-on-default=true" >> "$GITHUB_ENV"
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout repository
uses: actions/checkout@v3

- name: Multi-Stage Build Action
uses: firehed/multistage-docker-build-action@v1
with:
repository: ghcr.io/${{ github.repository_owner }}/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}
stages: cymetric
server-stage: cymetric-pytest
quiet: false
parallel: true
tag-latest-on-default: ${{ env.tag-latest-on-default }}
dockerfile: docker/Dockerfile
build-args: pkg_mgr=${{ matrix.pkg_mgr }}, ubuntu_version=${{ matrix.ubuntu_versions }}
37 changes: 37 additions & 0 deletions .github/workflows/changelog_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Changelog check

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

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

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

name: Is Changelog up-to-date ?
steps:
- name: Install latest git
run: |
apk add --no-cache bash git openssh
git --version
- name: Checkout repository
uses: actions/checkout@v3

- run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
cd $GITHUB_WORKSPACE
git remote add cymetric https://github.com/cyclus/cymetric.git
git fetch cymetric
change=`git diff cymetric/main -- CHANGELOG.rst | wc -l`
git remote remove cymetric
if [ $change -eq 0 ]; then
echo "CHANGELOG.rst has not been updated"
exit 1
fi
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ cymetric Change Log
===================

.. current developments
**Added:**
* GitHub workflows for CI (#188)

**Changed**
* Converted test suite from nose to pytest (#188)

v1.5.5
====================

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ Then build and install to the same location Cyclus is installed:
.. code-block:: bash
$ cd cymetric
$ python setup.py install --prefix $(cyclus --install-path)
$ python -m pip install --target $(python -m site --user-site)
Next, run the tests to ensure everything is working properly:

.. code-block:: bash
$ nosetests -w tests/
$ python -m pytest tests/
Installation via Binary
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
117 changes: 0 additions & 117 deletions circle.yml

This file was deleted.

2 changes: 1 addition & 1 deletion cymetric/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import sys
import uuid
from collections import MutableMapping, Sized
from collections.abc import MutableMapping, Sized
if sys.version_info[0] > 2:
str_types = (str, bytes)
else:
Expand Down
6 changes: 3 additions & 3 deletions cymetric/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def activity(mats):
'TimeCreated', 'NucId'),
'Mass')
act = []
for (simid, qual, res, obj, time, nuc), m in mass.iteritems():
for (simid, qual, res, obj, time, nuc), m in mass.items():
val = (1000 * data.N_A * m * data.decay_const(nuc)
/ data.atomic_mass(nuc))
act.append(val)
Expand Down Expand Up @@ -192,7 +192,7 @@ def decay_heat(acts):
'TimeCreated', 'NucId'),
'Activity')
dh = []
for (simid, qual, res, obj, time, nuc), a in act.iteritems():
for (simid, qual, res, obj, time, nuc), a in act.items():
val = (data.MeV_per_MJ * a * data.q_val(nuc))
dh.append(val)
dh = pd.Series(dh, index=act.index)
Expand Down Expand Up @@ -530,7 +530,7 @@ def timelist(info):
"""
info = tools.raw_to_series(info, ('SimId',), 'Duration')
tl = []
for sim, dur in info.iteritems():
for sim, dur in info.items():
for i in range(dur):
tl.append((sim, i))
tl = pd.DataFrame(tl, columns=['SimId', 'TimeStep'])
Expand Down
2 changes: 1 addition & 1 deletion cymetric/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
from __future__ import print_function, unicode_literals
import sys
from collections import MutableSequence, Iterable
from collections.abc import MutableSequence, Iterable
if sys.version_info[0] > 2:
str_types = (str, bytes)
else:
Expand Down
4 changes: 2 additions & 2 deletions cymetric/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def add_missing_time_step(df, ref_time):
ref_time.rename(index=str, columns={'TimeStep': 'Time'}, inplace=True)

if 'SimId' in ref_time.columns.values:
ref_time.drop('SimId', 1, inplace=True)
ref_time.drop('SimId', axis=1, inplace=True)
df = pd.merge(ref_time, df, how="outer")
df.fillna(0, inplace=True)
return df
Expand All @@ -129,7 +129,7 @@ def merge(df, base_col, add_df, add_col):
add_col: columns to be added
"""
df = pd.merge(add_df[add_col], df, on=base_col)
df.drop(base_col[1], 1)
df.drop(base_col[1], axis=1)
return df


Expand Down
18 changes: 18 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG pkg_mgr=apt
ARG ubuntu_version=22.04

FROM ghcr.io/cyclus/cycamore_${ubuntu_version}_${pkg_mgr}/cycamore as cycamore

FROM cycamore as apt-deps
RUN apt update --fix-missing && apt install -y python3-pip python3-pytest

FROM cycamore as conda-deps
RUN mamba install -y pip pytest

FROM ${pkg_mgr}-deps as cymetric
COPY . /cymetric
WORKDIR /cymetric
RUN python -m pip install --target $(python -m site --user-site) .

FROM cymetric as cymetric-pytest
RUN cd tests && python -m pytest
Loading

0 comments on commit 77fcf6c

Please sign in to comment.