Skip to content

Commit

Permalink
apply changes suggested by gonuke in Slack
Browse files Browse the repository at this point in the history
  • Loading branch information
bquan0 committed Aug 23, 2023
1 parent 64dae49 commit ca4c58c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 110 deletions.
189 changes: 82 additions & 107 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ on:

env:
DOCKER_IMAGE_BASENAME: ghcr.io/${{ github.repository_owner }}/pyne_ubuntu_22.04_py3
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.
Expand All @@ -27,16 +27,6 @@ jobs:
outputs:
image_tag: ${{ steps.output_tag.outputs.image_tag }}

strategy:
matrix:
pyne_test_base: [base_python, moab, dagmc, openmc]
hdf5: ['']
hdf5_build_arg: ['']
include:
- stage: dagmc
hdf5: _hdf5
hdf5_build_arg: hdf5-1_12_0
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -48,115 +38,100 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: modify DOCKER_IMAGE_BASENAME if _hdf5 will be built
if: matrix.hdf5 != ''
run: echo "DOCKER_IMAGE_BASENAME=${env.DOCKER_IMAGE_BASENAME}${matrix.hdf5}" >> $GITHUB_ENV
- 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: multistage_build_and_test
id: build_all_stages
with:
repository: ${{ env.DOCKER_IMAGE_BASENAME }}
stages: ${{ matrix.pyne_test_base }}
testenv-stage: ${{ matrix.pyne_test_base }}
server-stage: pyne
stages: 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-args: build_hdf5=${{ matrix.hdf5_build_arg }}, pyne_test_base=${{ env.pyne_test_base }}

- name: Push Image to stable img
if: github.repository_owner == 'pyne'
uses: akhilerm/tag-push-action@v2.1.0
# build HDF5 using multistage docker build action
- uses: firehed/multistage-docker-build-action@v1
id: build_dagmc_with_hdf5
with:
src: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}${{ steps.multistage_build_and_test.outputs.testenv-tag }}
dst: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}:stable


# # build HDF5 using multistage docker build action
# - uses: firehed/multistage-docker-build-action@v1
# id: build_dagmc_with_hdf5
# 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

# - name: Check event for DOCKER_IMAGE_TAG change
# if: github.event_name == 'pull_request'
# run: echo "DOCKER_IMAGE_TAG=:refs_heads_${GITHUB_HEAD_REF}-bk0" >> $GITHUB_ENV

# - id: output_tag
# run: |
# echo "image_tag=$DOCKER_IMAGE_TAG" >> $GITHUB_OUTPUT

# # 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]
# hdf5: ['']
# include:
# - stage: dagmc
# hdf5: _hdf5
# fail-fast: false
repository: ${{ env.DOCKER_IMAGE_BASENAME }}_hdf5
stages: base_python, moab
server-stage: dagmc
quiet: false
parallel: true
tag-latest-on-default: ${{ env.USE_LATEST_TAG }}
dockerfile: docker/ubuntu_22.04-dev.dockerfile
build-args: build_hdf5=hdf5-1_12_0

# 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: Checkout repository
# uses: actions/checkout@v3
# 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:
pyne_test_base: [base_python, moab, dagmc, openmc]
hdf5: ['']
hdf5_build_arg: ['']
include:
- stage: dagmc
hdf5: _hdf5
hdf5_build_arg: hdf5-1_12_0
fail-fast: false

# - name: use BuildTest composite action
# uses: ./.github/actions/build-test
# with:
# stage: ${{ matrix.stage }}
# hdf5: ${{ matrix.hdf5 }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- 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

# # 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' }}
# needs: [BuildTest]
# runs-on: ubuntu-latest
# strategy:
# matrix:
# stage: [base_python, moab, dagmc, openmc]
# hdf5: ['']
# include:
# - stage: dagmc
# hdf5: _hdf5
# 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.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: build_hdf5=${{ matrix.hdf5_build_arg }}, pyne_test_base=${{ env.pyne_test_base }}

# name: "ghcr.io/${{ github.repository_owner }}/pyne_ubuntu_22.04_py3${{ matrix.hdf5 }}/${{ matrix.stage }}: latest -> stable"
# 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' }}
needs: [BuildTest]
runs-on: ubuntu-latest
strategy:
matrix:
stage: [base_python, moab, dagmc, openmc]
hdf5: ['']
include:
- stage: dagmc
hdf5: _hdf5

# steps:
# - 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: Check event for DOCKER_IMAGE_TAG change
# if: github.event_name == 'pull_request'
# run: echo "DOCKER_IMAGE_TAG=:refs_heads_${GITHUB_HEAD_REF}-bk0" >> $GITHUB_ENV
name: "ghcr.io/${{ github.repository_owner }}/pyne_ubuntu_22.04_py3${{ matrix.hdf5 }}/${{ matrix.stage }}: latest -> stable"

# - name: Push Image to stable img
# uses: akhilerm/tag-push-action@v2.1.0
# with:
# src: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}${{ env.DOCKER_IMAGE_TAG }}
# dst: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}:stable
steps:
- 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: Push Image to latest img
# uses: akhilerm/tag-push-action@v2.1.0
# with:
# src: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}${{ env.DOCKER_IMAGE_TAG }}
# dst: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}:latest
- name: Push Image to stable img
uses: akhilerm/tag-push-action@v2.1.0
with:
src: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}:latest
dst: ${{ env.DOCKER_IMAGE_BASENAME }}${{ matrix.hdf5 }}/${{ matrix.stage }}:stable
5 changes: 2 additions & 3 deletions docker/ubuntu_22.04-dev.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ARG build_hdf5="NO"
ARG build_pyne="NO"
ARG pyne_test_base=openmc
ENV pyne_base=${pyne_test_base}
ARG ubuntu_version=22.04

FROM ubuntu:${ubuntu_version} AS base_python
Expand Down Expand Up @@ -135,7 +134,7 @@ RUN if [ "$build_hdf5" != "NO" ]; then \
&& pip install .

# Build/Install PyNE from develop branch
FROM ${pyne_base} AS pyne-dev
FROM ${pyne_test_base} AS pyne-dev
ARG build_hdf5
ARG build_pyne

Expand All @@ -159,7 +158,7 @@ RUN if [ "$build_pyne" = "YES" ]; then \
&& ./ci-run-tests.sh python3

# Build/Install PyNE from release branch
FROM ${pyne_base} AS pyne
FROM ${pyne_test_base} AS pyne
ARG build_hdf5
ARG build_pyne

Expand Down

0 comments on commit ca4c58c

Please sign in to comment.