Skip to content

Commit

Permalink
Merge branch 'develop' into install_multi_runners
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnaf-tahmid-chowdhury authored Feb 16, 2024
2 parents c2317b6 + f89234c commit 0bbefc5
Show file tree
Hide file tree
Showing 32 changed files with 2,232 additions and 1,820 deletions.
44 changes: 44 additions & 0 deletions .github/actions/build-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: BuildTest
description: Builds and tests an installation of PyNE in a single docker image. This action is used for bootstrap testing when building the docker images as well as testing of each PR using those docker images.
inputs:
stage:
description: The docker stage that will be used as the docker image for testing.
required: true
default: ''
hdf5:
description: Information about which version of HDF5 will be used for testing.
required: true
default: ''
runs:
using: "composite"
steps:
- name: setup
shell: bash -l {0}
run: |
export ADD_FLAG=" "
if [[ "${{ inputs.stage }}" == "moab" || "${{ inputs.stage }}" == "dagmc" ]]; then
export ADD_FLAG="${ADD_FLAG} --moab /root/opt/moab"
fi
if [[ "${{ inputs.stage }}" == "dagmc" ]]; then
export ADD_FLAG="${ADD_FLAG} --dagmc /root/opt/dagmc"
fi
if [[ "${{ inputs.hdf5 }}" == "_hdf5" ]]; then
export ADD_FLAG="${ADD_FLAG} --hdf5 /root/opt/hdf5/hdf5-1_12_0"
fi
export ADD_FLAG="${ADD_FLAG} "
echo "ADD_FLAG=${ADD_FLAG}" >> $GITHUB_ENV
- name: Building PyNE
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE
python setup.py install --user --clean ${{ env.ADD_FLAG}}
export PATH="$PATH:/github/home/.local/bin"
cd ../
nuc_data_make
- name: Testing PyNE
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE/tests
./ci-run-tests.sh python3
73 changes: 28 additions & 45 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ on:
workflow_dispatch:
pull_request:
paths-ignore:
- '.github/workflows/docker_publish.yml'
- '.github/workflows/changelog_test.yml'
- 'docker/**'
- 'CHANGELOG.rst'
- 'docs/*'
- 'examples/*'
- 'img/*'
- 'news/*'
- 'tutorial/*'
- './*.rst'
- 'license.txt'
- 'PULL_REQUEST_TEMPLATE.md'
push:
branches:
- develop
paths-ignore:
- '.github/workflows/docker_publish.yml'
- '.github/workflows/changelog_test.yml'
- 'docker/**'
- 'CHANGELOG.rst'

- 'docs/*'
- 'examples/*'
- 'img/*'
- 'news/*'
- 'tutorial/*'
- './*.rst'
- 'license.txt'
- 'PULL_REQUEST_TEMPLATE.md'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -26,49 +31,27 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
pkg_mgr: ['apt', 'conda']
stage: [base_python, moab, dagmc, openmc]
hdf5: ['']
include:
- stage: dagmc
- pkg_mgr: 'apt'
stage: dagmc
hdf5: _hdf5
- pkg_mgr: 'conda'
stage: dagmc
hdf5: _hdf5
fail-fast: false

container:
image: ghcr.io/pyne/pyne_ubuntu_20.04_py3${{ matrix.hdf5 }}/${{ matrix.stage }}:stable
image: ghcr.io/pyne/pyne_ubuntu_22.04_py3_${{ matrix.pkg_mgr }}${{ matrix.hdf5 }}/${{ matrix.stage }}:stable

steps:
- name: setup
shell: bash -l {0}
run: |
export ADD_FLAG=" "
if [[ "${{ matrix.stage }}" == "moab" || "${{ matrix.stage }}" == "dagmc" ]]; then
export ADD_FLAG="${ADD_FLAG} --moab /root/opt/moab"
fi
if [[ "${{ matrix.stage }}" == "dagmc" ]]; then
export ADD_FLAG="${ADD_FLAG} --dagmc /root/opt/dagmc"
fi
if [[ "${{ matrix.hdf5 }}" == "_hdf5" ]]; then
export ADD_FLAG="${ADD_FLAG} --hdf5 /root/opt/hdf5/hdf5-1_12_0"
fi
export ADD_FLAG="${ADD_FLAG} "
echo "ADD_FLAG=${ADD_FLAG}" >> $GITHUB_ENV
pip install pytest
- name: Checkout repository
uses: actions/checkout@v3

- name: Building PyNE
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE
python setup.py install --user --clean ${{ env.ADD_FLAG}}
export PATH="$PATH:/github/home/.local/bin"
export PYTHONPATH="$PYTHONPATH:/github/home/.local/lib/python3.8/site-packages/"
cd ../
nuc_data_make

- name: Testing PyNE
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE/tests
./ci-run-tests.sh
- name: use BuildTest composite action
uses: ./.github/actions/build-test
with:
stage: ${{ matrix.stage }}
hdf5: ${{ matrix.hdf5 }}
155 changes: 74 additions & 81 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,40 @@ name: Build & Publish docker image for PyNE-CI
on:
# allows us to run workflows manually
workflow_dispatch:
pull_request:
paths:
- 'docker/*'
- '.github/workflows/docker_publish.yml'
- '.github/actions/build-test/action.yml'
push:
paths:
- 'docker/*'
- '.github/workflows/docker_publish.yml'
- '.github/actions/build-test/action.yml'

env:
DOCKER_IMAGE_BASENAME: ghcr.io/${{ github.repository_owner }}/pyne_ubuntu_22.04_py3
DOCKER_IMAGE_TAG: :refs_heads_${{ github.ref_name }}-bk0
USE_LATEST_TAG: false

jobs:

# builds and pushes docker images of various stages to ghcr.
# These docker images are also stored in ghcr and can be pulled
# to be built upon by the subsequent stage.
multistage_image_build:
runs-on: ubuntu-latest
strategy:
matrix:
ubuntu_versions : [
22.04,
]
outputs:
image_tag: ${{ steps.output_tag.outputs.image_tag }}
matrix:
pkg_mgr: ['apt', 'conda']
hdf5: ['']
hdf5_build_arg: ['NO']
include:
- pkg_mgr: 'apt'
hdf5: _hdf5
hdf5_build_arg: hdf5-1_12_0
- pkg_mgr: 'conda'
hdf5: _hdf5
hdf5_build_arg: hdf5-1_12_0
fail-fast: false

steps:
- name: Checkout repository
Expand All @@ -37,108 +48,96 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Tag images with latest if on the main repo's develop branch
if: github.repository_owner == 'pyne' && github.ref_name == 'develop'
run: echo "USE_LATEST_TAG=true" >> $GITHUB_ENV

# build base python, moab, dagmc, openmc using multistage docker build action
- uses: firehed/multistage-docker-build-action@v1
id: build1
id: build_all_stages
with:
repository: ${{ env.DOCKER_IMAGE_BASENAME }}
stages: base_python, moab, dagmc
repository: ${{ env.DOCKER_IMAGE_BASENAME }}_${{ matrix.pkg_mgr }}${{ matrix.hdf5 }}
stages: common_base, ${{ matrix.pkg_mgr }}_deps, base_python, moab, dagmc
server-stage: openmc
quiet: false
tag-latest-on-default: false
parallel: true
tag-latest-on-default: ${{ env.USE_LATEST_TAG }}
dockerfile: docker/ubuntu_22.04-dev.dockerfile

# build HDF5 using multistage docker build action
- uses: firehed/multistage-docker-build-action@v1
id: build2
with:
repository: ${{ env.DOCKER_IMAGE_BASENAME }}_hdf5
stages: base_python, moab
server-stage: dagmc
quiet: false
tag-latest-on-default: false
dockerfile: docker/ubuntu_22.04-dev.dockerfile
build-args: build_hdf5=hdf5-1_12_0

# print out server-tags
- run: |
echo ${{ steps.build1.outputs.server-tag }}
echo ${{ steps.build2.outputs.server-tag }}
- id: output_tag
run: |
echo "image_tag=$DOCKER_IMAGE_TAG" >> $GITHUB_OUTPUT
build-args: pkg_mgr = ${{ matrix.pkg_mgr }}, build_hdf5=${{ matrix.hdf5_build_arg }}, pyne_test_base=openmc

# Downloads the images uploaded to ghcr in previous stages and runs pyne
# tests to check that they work.
BuildTest:
needs: [multistage_image_build]
runs-on: ubuntu-latest

strategy:
matrix:
stage: [base_python, moab, dagmc, openmc]
matrix:
pkg_mgr: ['apt', 'conda']
pyne_test_base: [base_python, moab, dagmc, openmc]
hdf5: ['']
hdf5_build_arg: ['NO']
include:
- stage: dagmc
- pkg_mgr: 'apt'
pyne_test_base: dagmc
hdf5: _hdf5
hdf5_build_arg: hdf5-1_12_0
- pkg_mgr: 'conda'
pyne_test_base: dagmc
hdf5: _hdf5
hdf5_build_arg: hdf5-1_12_0
fail-fast: false

container:
image: ghcr.io/${{ github.repository_owner }}/pyne_ubuntu_22.04_py3${{ matrix.hdf5 }}/${{ matrix.stage }}${{ needs.multistage_image_build.outputs.image_tag }}
steps:
- name: setup
shell: bash -l {0}
run: |
export ADD_FLAG=" "
if [[ "${{ matrix.stage }}" == "moab" || "${{ matrix.stage }}" == "dagmc" ]]; then
export ADD_FLAG="${ADD_FLAG} --moab /root/opt/moab"
fi
if [[ "${{ matrix.stage }}" == "dagmc" ]]; then
export ADD_FLAG="${ADD_FLAG} --dagmc /root/opt/dagmc"
fi
if [[ "${{ matrix.hdf5 }}" == "_hdf5" ]]; then
export ADD_FLAG="${ADD_FLAG} --hdf5 /root/opt/hdf5/hdf5-1_12_0"
fi
export ADD_FLAG="${ADD_FLAG} "
echo "ADD_FLAG=${ADD_FLAG}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3

- name: Building PyNE
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE
python setup.py install --user --clean ${{ env.ADD_FLAG}}
export PATH="$PATH:/github/home/.local/bin"
export PYTHONPATH="$PYTHONPATH:/github/home/.local/lib/python3.10/site-packages/"
cd ../
nuc_data_make

- name: Testing PyNE
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE/tests
./ci-run-tests.sh python3
- 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: Tag images with latest if on the main repo's develop branch
if: github.repository_owner == 'pyne' && github.ref_name == 'develop'
run: echo "USE_LATEST_TAG=true" >> $GITHUB_ENV

# build test stage and pyne-dev stage using multistage docker build action
- uses: firehed/multistage-docker-build-action@v1
id: multistage_build_and_test
with:
repository: ${{ env.DOCKER_IMAGE_BASENAME }}_${{ matrix.pkg_mgr }}${{ matrix.hdf5 }}
stages: ${{ matrix.pyne_test_base }}
server-stage: pyne-dev
quiet: false
parallel: true
tag-latest-on-default: ${{ env.USE_LATEST_TAG }}
dockerfile: docker/ubuntu_22.04-dev.dockerfile
build-args: pkg_mgr = ${{ matrix.pkg_mgr }}, build_hdf5=${{ matrix.hdf5_build_arg }}, pyne_test_base=${{ matrix.pyne_test_base }}

# if the previous step that tests the docker images passes then the images
# can be copied from the ghcr where they are saved using :ci_testing tags to
# :latest and :stable tags.
pushing_test_stable_img:
if: ${{ github.repository_owner == 'pyne' }}
if: github.repository_owner == 'pyne' && github.ref_name == 'develop'
needs: [BuildTest]
runs-on: ubuntu-latest
strategy:
matrix:
pkg_mgr: ['apt', 'conda']
stage: [base_python, moab, dagmc, openmc]
hdf5: ['']
include:
- stage: dagmc
- pkg_mgr: 'apt'
stage: dagmc
hdf5: _hdf5
- pkg_mgr: 'conda'
stage: dagmc
hdf5: _hdf5

name: "ghcr.io/${{ github.repository_owner }}/pyne_ubuntu_22.04_py3${{ matrix.hdf5 }}/${{ matrix.stage }}: latest -> stable"
name: "ghcr.io/${{ github.repository_owner }}/pyne_ubuntu_22.04_py3_${{ matrix.pkg_mgr }}${{ matrix.hdf5 }}/${{ matrix.stage }}: latest -> stable"

steps:
- name: Log in to the Container registry
Expand All @@ -151,11 +150,5 @@ jobs:
- name: Push Image to stable img
uses: akhilerm/[email protected]
with:
src: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}${{ env.DOCKER_IMAGE_TAG }}
dst: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}:stable

- name: Push Image to latest img
uses: akhilerm/[email protected]
with:
src: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}${{ env.DOCKER_IMAGE_TAG }}
dst: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}:latest
src: ${{ env.DOCKER_IMAGE_BASENAME }}_${{ matrix.pkg_mgr }}${{ matrix.hdf5 }}/${{ matrix.stage }}:latest
dst: ${{ env.DOCKER_IMAGE_BASENAME }}_${{ matrix.pkg_mgr }}${{ matrix.hdf5 }}/${{ matrix.stage }}:stable
18 changes: 11 additions & 7 deletions .github/workflows/install_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ on:
# allows us to run workflows manually
workflow_dispatch:
push:
paths:
- 'scripts/ubuntu.sh'
- '.github/workflows/install_script.yml'
branches:
- 'develop'
paths-ignore:
- 'docs/*'
- 'examples/*'
- 'img/*'
- 'news/*'
- 'tutorial/*'
- './*.rst'
- 'license.txt'
- 'PULL_REQUEST_TEMPLATE.md'

jobs:
run_install_script:
Expand All @@ -26,7 +34,3 @@ jobs:
cd $GITHUB_WORKSPACE/scripts
chmod +x ubuntu.sh
./ubuntu.sh ${{ matrix.branch }} ${{ matrix.build_hdf5 }}
# use matrix to have 2 jobs [develop, stable]
# ./ubuntu.sh stable

Loading

0 comments on commit 0bbefc5

Please sign in to comment.