-
Notifications
You must be signed in to change notification settings - Fork 6
CI: Run different workflow if new image needs to be built. #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5f2df05
CI: Conditionally build the CI image.
riley-dixon 30b495b
Change matrix strategy to apply to entire workflow.
riley-dixon c91651a
Drop un-used CI variables.
riley-dixon d40934c
Add caching to PR-image only.
riley-dixon 69993d9
CI: Add post-merge workflow to update latest CI image.
riley-dixon 0a12166
Rename CI filenames to use dashes.
riley-dixon 07099ec
Try to make Check names more concise.
riley-dixon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: AIS_CI | ||
| run-name: Main CI workflow to coordinate jobs for a single platform. | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| platform: | ||
| required: true | ||
| type: string | ||
| permissions: | ||
| contents: read | ||
| packages: read | ||
| jobs: | ||
| AIS_CI_Pre-check: | ||
| outputs: | ||
| changed_dockerfile: ${{ steps.ci-flags.outputs.changed_dockerfile }} | ||
| runs-on: [ubuntu-24.04] | ||
| steps: | ||
| - name: Fetching code repository... | ||
| uses: actions/checkout@v5 | ||
| - name: Git fetch base ref | ||
| run: git fetch origin ${{ github.base_ref }} | ||
| - name: Set CI Flags | ||
| id: ci-flags | ||
| run: | | ||
| echo "changed_dockerfile=$(./util/files-changed.sh origin/${{ github.base_ref }} HEAD 'util/docker/DOCKERFILE.*')" >> ${GITHUB_OUTPUT} | ||
| build_AIS_CI_image: | ||
| if: ${{ needs.AIS_CI_Pre-check.outputs.changed_dockerfile == '1' }} | ||
| needs: AIS_CI_Pre-check | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| uses: ./.github/workflows/build-ais-ci-image.yml | ||
| with: | ||
| platform: ${{ inputs.platform }} | ||
| build_and_test: | ||
| # Run after build_AIS_CI_image but only if build_AIS_CI_image passed or was skipped. | ||
| # always() check needed otherwise success() implicitly added. | ||
| if: >- | ||
| ${{ | ||
| always() && | ||
| ( | ||
| needs.build_AIS_CI_image.result == 'skipped' || | ||
| ( | ||
| needs['AIS_CI_Pre-check'].outputs.changed_dockerfile == '1' && | ||
| needs.build_AIS_CI_image.result == 'success' | ||
| ) | ||
| ) | ||
| }} | ||
| needs: [AIS_CI_Pre-check, build_AIS_CI_image] | ||
| uses: ./.github/workflows/build-ais.yml | ||
| with: | ||
| # If Dockerfile changed, use the new CI image. Otherwise, use 'latest'. | ||
| ci_image: >- | ||
| ${{ | ||
| needs.AIS_CI_Pre-check.outputs.changed_dockerfile == '1' && | ||
| needs.build_AIS_CI_image.outputs.ci_image || | ||
| format('ghcr.io/rocm/hipfile/ais_ci_{0}:latest', inputs.platform) | ||
| }} | ||
| platform: ${{ inputs.platform }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: new_CI_image | ||
| run-name: Build the Docker image for AIS CI. | ||
| env: | ||
| AIS_DOCKER_REGISTRY: ghcr.io/rocm/hipfile | ||
| AIS_PR_BASE_URL: https://github.com/ROCm/hipFile/pull | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| platform: | ||
| required: true | ||
| type: string | ||
| outputs: | ||
| ci_image: | ||
| description: The full name & tag of the newly built image. | ||
| value: ${{ jobs.build_AIS_image.outputs.new_ci_image}} | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| jobs: | ||
| build_AIS_image: | ||
| env: | ||
| AIS_CI_IMAGE_NAME: ais_ci_${{ inputs.platform }} | ||
| runs-on: [ubuntu-24.04] | ||
| container: docker:28.5 | ||
| outputs: | ||
| new_ci_image: ${{ steps.ci-image.outputs.AIS_CI_IMAGE }} | ||
| image_tag: ${{ steps.ci-image.outputs.AIS_CI_IMAGE_TAG }} | ||
| # image_tag is a bit hacky. GitHub does not support separating outputs | ||
| # from a workflow run in a matrix. The last workflow to run will set the | ||
| # output value. `image_tag` is constant across matrix jobs so this is fine. | ||
| steps: | ||
| - name: Set CI environment variables | ||
| run: | | ||
| echo "AIS_CI_IMAGE_TAG=$(echo ${{ github.ref }} | sed 's|[^a-zA-Z0-9]|-|g')" >> "${GITHUB_ENV}" | ||
| echo "AIS_PR_NUMBER=$(echo ${{ github.ref }} | sed 's|[^0-9]||g')" >> "${GITHUB_ENV}" | ||
| - name: Set target AIS CI Image | ||
| id: ci-image | ||
| run: | | ||
| echo "AIS_CI_IMAGE=${{ env.AIS_DOCKER_REGISTRY }}/${{ env.AIS_CI_IMAGE_NAME}}:${AIS_CI_IMAGE_TAG}" \ | ||
| >> "${GITHUB_OUTPUT}" | ||
| - name: Fetching code repository... | ||
| uses: actions/checkout@v5 | ||
| - name: Authenticating to GitHub Container Registry. | ||
| uses: docker/login-action@v3.6.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Setup Docker Builder | ||
| uses: docker/setup-buildx-action@v3.11.1 | ||
| with: | ||
| name: ais-builder | ||
| driver: docker-container | ||
| cache-binary: false # True uses the GHA Cache Backend. | ||
| - name: Build base image for AIS CI | ||
| run: | | ||
| docker buildx build \ | ||
| -f ${GITHUB_WORKSPACE}/util/docker/DOCKERFILE.${{ env.AIS_CI_IMAGE_NAME }} \ | ||
| --label "org.opencontainers.image.description= \ | ||
| ${{ env.AIS_CI_IMAGE_NAME }} Development Image for AIS CI using branch \ | ||
| ${{ github.head_ref }} for PR #${AIS_PR_NUMBER}. \ | ||
| PR URL: ${{ env.AIS_PR_BASE_URL }}/${AIS_PR_NUMBER}" \ | ||
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | ||
| --cache-from=type=registry,ref=${{ steps.ci-image.outputs.AIS_CI_IMAGE }} \ | ||
| --push \ | ||
| -t ${{ steps.ci-image.outputs.AIS_CI_IMAGE }} \ | ||
| ${GITHUB_WORKSPACE} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: update_CI_image | ||
| run-name: Update latest CI image | ||
| on: | ||
| pull_request_target: # A.K.A. This is a privileged action. See `pull_request`. | ||
| types: | ||
| - closed # CAUTION: Includes un-merged PR's. | ||
| branches: | ||
| - develop | ||
| workflow_dispatch: | ||
| # Requires write access to trigger. | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| jobs: | ||
| update_AIS_CI_image: | ||
| env: | ||
| AIS_DOCKER_REGISTRY: ghcr.io/rocm/hipfile | ||
| AIS_CI_IMAGE_NAME: ais_ci_${{ matrix.supported_platforms }} | ||
| if: ${{ github.event.pull_request.merged == true }} | ||
| runs-on: [ubuntu-24.04] | ||
| container: docker:28.5 | ||
| strategy: | ||
| matrix: | ||
| supported_platforms: | ||
| - rocky | ||
| - suse | ||
| - ubuntu | ||
| steps: | ||
| - name: Fetching code repository... | ||
| uses: actions/checkout@v5 | ||
| - name: Authenticating to GitHub Container Registry. | ||
| uses: docker/login-action@v3.6.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Set target AIS CI Image | ||
| id: ci-image | ||
| run: | | ||
| echo "AIS_CI_IMAGE=${{ env.AIS_DOCKER_REGISTRY }}/${{ env.AIS_CI_IMAGE_NAME}}:latest" \ | ||
| >> "${GITHUB_OUTPUT}" | ||
| - name: Setup Docker Builder | ||
| uses: docker/setup-buildx-action@v3.11.1 | ||
| with: | ||
| name: ais-builder | ||
| driver: docker-container | ||
| cache-binary: false # True uses the GHA Cache Backend. | ||
| # We won't use the cache from the previous image. | ||
| # This lets us semi-regularly pull in package updates automatically. | ||
| - name: Build & Push latest image for AIS CI | ||
| run: | | ||
| docker buildx build \ | ||
| -f ${GITHUB_WORKSPACE}/util/docker/DOCKERFILE.${{ env.AIS_CI_IMAGE_NAME }} \ | ||
| --label "org.opencontainers.image.description= \ | ||
| Latest AIS CI Image for ${{ matrix.supported_platforms }}." \ | ||
| --push \ | ||
| -t ${{ steps.ci-image.outputs.AIS_CI_IMAGE }} \ | ||
| ${GITHUB_WORKSPACE} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.