diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index ad5083f6f..8ba384af6 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -22,7 +22,6 @@ jobs: permissions: contents: read packages: write - pull-requests: write strategy: fail-fast: false @@ -61,9 +60,9 @@ jobs: uses: docker/build-push-action@v5 with: file: docker/Dockerfile - cache-from: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache - cache-to: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max - tags: ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-image-cache + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max + tags: ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-image-cache push: true build-args: | pkg_mgr=${{ matrix.pkg_mgr }} @@ -85,25 +84,53 @@ jobs: with: context: ${{ github.workspace }}/cymetric file: ${{ github.workspace }}/cymetric/docker/Dockerfile - cache-from: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache - cache-to: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache,mode=max - tags: ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-image-cache - push: true + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache,mode=max build-args: | pkg_mgr=${{ matrix.pkg_mgr }} ubuntu_version=${{ matrix.ubuntu_versions }} - cycamore_tag=ci-image-cache@${{ steps.build-cycamore.outputs.digest }} + cycamore_tag=ci-image-cache + build-contexts: | + ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-image-cache=docker-image://ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-image-cache@${{ steps.build-cycamore.outputs.digest }} + + - name: Export Environment Variables + if: github.event_name == 'pull_request' + run: | + echo "CYCAMORE_BUILD_STATUS=${{steps.build-cycamore.outcome == 'success' && '**Success** :white_check_mark:' || + steps.build-cycamore.outcome == 'failure' && '**Failure** :x:' || + '**Skipped due to upstream failure** :warning:'}}" >> "$GITHUB_ENV" + + echo "CYMETRIC_BUILD_STATUS=${{steps.build-cymetric.outcome == 'success' && '**Success** :white_check_mark:' || + steps.build-cymetric.outcome == 'failure' && '**Failure** :x:' || + '**Skipped due to upstream failure** :warning:'}}" >> "$GITHUB_ENV" + + echo "ARTIFACT_NAME=${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}_${{ matrix.cyclus_tag }}" >> "$GITHUB_ENV" - - name: PR Comment - if: ${{ github.event_name == 'pull_request' }} - uses: thollander/actions-comment-pull-request@v2 + - name: Construct Artifact + if: github.event_name == 'pull_request' + run: | + echo " + ##### Build \`FROM cyclus_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cyclus:${{ matrix.cyclus_tag }}\` + - Cycamore: ${{ env.CYCAMORE_BUILD_STATUS }} + - Cymetric: ${{ env.CYMETRIC_BUILD_STATUS }}" > ${{ env.ARTIFACT_NAME }}.txt + + - name: Upload Artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_NAME }}.txt + + upload-pr-number: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - name: Save PR number to file + run: | + echo "${{ github.event.number }}" > pr_number + + - name: Upload artifact + uses: actions/upload-artifact@v4 with: - comment_tag: ${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}_${{ matrix.cyclus_tag }} - message: | - ## Build statuses using cyclus_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}:${{ matrix.cyclus_tag }} - - Cycamore: ${{steps.build-cycamore.outcome == 'success' && '*Success* :white_check_mark:' || - steps.build-cycamore.outcome == 'failure' && '**Failure** :x:' || - '**Skipped due to upstream failure** :warning:'}} - - Cymetric: ${{steps.build-cymetric.outcome == 'success' && '*Success* :white_check_mark:' || - steps.build-cymetric.outcome == 'failure' && '**Failure** :x:' || - '**Skipped due to upstream failure** :warning:'}} + name: pr_number + path: pr_number \ No newline at end of file diff --git a/.github/workflows/pr_comment.yml b/.github/workflows/pr_comment.yml new file mode 100644 index 000000000..a2632a915 --- /dev/null +++ b/.github/workflows/pr_comment.yml @@ -0,0 +1,32 @@ +name: Comment on PR + +on: + workflow_run: + workflows: ["Build/Test for PR and collaborator push"] + types: + - completed + +jobs: + pr-comment: + runs-on: ubuntu-latest + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + merge-multiple: true + + - name: Merge artifacts and get PR number + run: | + echo "### Build Status Report" > artifacts_merged.md + cat ./*.txt >> artifacts_merged.md + echo "PR_NUMBER=$(cat pr_number)" >> "$GITHUB_ENV" + + - name: PR Comment + uses: thollander/actions-comment-pull-request@v2 + with: + pr_number: ${{ env.PR_NUMBER }} + comment_tag: build_status_report + filePath: artifacts_merged.md \ No newline at end of file diff --git a/.github/workflows/publish_latest.yml b/.github/workflows/publish_latest.yml index 44c3e6d67..5512371fe 100644 --- a/.github/workflows/publish_latest.yml +++ b/.github/workflows/publish_latest.yml @@ -56,11 +56,11 @@ jobs: id: build-cycamore uses: docker/build-push-action@v5 with: - cache-from: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache - cache-to: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max file: docker/Dockerfile push: true - tags: ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.tag }} + tags: ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.tag }} build-args: | pkg_mgr=${{ matrix.pkg_mgr }} ubuntu_version=${{ matrix.ubuntu_versions }} @@ -78,9 +78,9 @@ jobs: with: context: ${{ github.workspace }}/cymetric file: ${{ github.workspace }}/cymetric/docker/Dockerfile - cache-from: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache - cache-to: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache,mode=max - tags: ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:${{ env.tag }} + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache,mode=max + tags: ghcr.io/${{ github.repository_owner }}/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:${{ env.tag }} push: true build-args: | pkg_mgr=${{ matrix.pkg_mgr }} diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index efc3c65ca..2987e3456 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -52,13 +52,13 @@ jobs: - name: Build, Test, and Push Cycamore uses: docker/build-push-action@v5 with: - cache-from: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache - cache-to: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max file: docker/Dockerfile push: true tags: | - ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.version_tag }} - ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.stable_tag }} + ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.version_tag }} + ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.stable_tag }} build-args: | pkg_mgr=${{ matrix.pkg_mgr }} ubuntu_version=${{ matrix.ubuntu_versions }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d1d626c0a..8f64868cf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,8 +5,9 @@ cycamore Change Log .. current developments **Added:** -* GitHub workflow for publishing images on release (#573, #580) -* GitHub workflows for building/testing on a PR and push to `main` (#549, #564, #573) +* Downstream testing in CI workflows (#573, #580, #582) +* GitHub workflow for publishing images on release (#573, #582) +* GitHub workflows for building/testing on a PR and push to `main` (#549, #564, #573, #582) * Add functionality for random behavior on the size (#550) and frequency (#565) of a sink * GitHub workflow to check that the CHANGELOG has been updated (#562) * Added inventory policies to Storage through the material buy policy (#574)