diff --git a/.github/actions/build-test/action.yml b/.github/actions/build-test/action.yml new file mode 100644 index 0000000000..e13d8cfad8 --- /dev/null +++ b/.github/actions/build-test/action.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 898133dce0..4302a7cdfc 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -34,41 +34,15 @@ jobs: 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.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 }} + diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml index a7a4af0306..23d3b0176a 100644 --- a/.github/workflows/docker_publish.yml +++ b/.github/workflows/docker_publish.yml @@ -7,6 +7,7 @@ on: 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 @@ -19,11 +20,6 @@ jobs: # 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 }} @@ -40,7 +36,7 @@ jobs: # 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 @@ -51,7 +47,7 @@ jobs: # build HDF5 using multistage docker build action - uses: firehed/multistage-docker-build-action@v1 - id: build2 + id: build_dagmc_with_hdf5 with: repository: ${{ env.DOCKER_IMAGE_BASENAME }}_hdf5 stages: base_python, moab @@ -61,11 +57,6 @@ jobs: 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 @@ -88,40 +79,14 @@ jobs: 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: use BuildTest composite action + uses: ./.github/actions/build-test + with: + stage: ${{ matrix.stage }} + hdf5: ${{ matrix.hdf5 }} # 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 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7782c4ebff..40b83ecdc2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,7 @@ Next Version * fixed compatibility issue with Python 3.10 in endf.py (#1472) * avoid use of deprecated numpy.int alias (#1479) * avoid use of deprecated numpy.bool alias (#1485) + * add composite action for BuildTest job in workflows (#1489) v0.7.7 ======