-
Notifications
You must be signed in to change notification settings - Fork 25
Add build-devcontainers.yaml and build-devcontainer.yaml workflows
#530
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
Open
trxcllnt
wants to merge
8
commits into
main
Choose a base branch
from
fea/build-devcontainer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+225
−0
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
50325ed
add build-devcontainer.yaml workflow
trxcllnt a39d518
Merge branch 'main' of github.com:rapidsai/shared-workflows into fea/…
trxcllnt 9dbca3f
fix lint
trxcllnt 1a94b5e
update shared-actions/build-devcontainer commit hash
trxcllnt 936f3c2
use main
trxcllnt 38623e2
remove unused outputs
trxcllnt 67ee030
clean up and apply suggestions from code review
trxcllnt f37c85d
Merge branch 'main' of github.com:rapidsai/shared-workflows into fea/…
trxcllnt 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,132 @@ | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| push: | ||
| type: string | ||
| default: true | ||
| description: "Whether to push the image." | ||
| repo: | ||
| type: string | ||
| required: true | ||
| description: "Devcontainer image repository." | ||
| tag: | ||
| type: string | ||
| required: true | ||
| description: "Devcontainer image tag." | ||
| workspace-dir: | ||
| type: string | ||
| default: '.' | ||
| description: "Devcontainer workspace directory." | ||
| devcontainer-json: | ||
| type: string | ||
| required: true | ||
| description: "Path to the devcontainer.json file." | ||
| timeout-minutes: | ||
| type: number | ||
| default: 360 | ||
| description: "Maximum time (in minutes) allowed for a run of this workflow." | ||
| retries: | ||
| type: string | ||
| default: '3' | ||
| description: "Number of times to retry the image build" | ||
| runs-on: | ||
| type: string | ||
| default: "ubuntu-latest" | ||
| description: "GHA runner label." | ||
| outputs: | ||
| version: | ||
| value: ${{ jobs.build.outputs.version }} | ||
|
|
||
|
|
||
| permissions: | ||
| actions: none | ||
| checks: none | ||
| contents: none | ||
| deployments: none | ||
| discussions: none | ||
| issues: none | ||
| packages: write | ||
| pages: none | ||
| pull-requests: none | ||
| repository-projects: none | ||
| security-events: none | ||
| statuses: none | ||
|
|
||
| jobs: | ||
| build: | ||
| timeout-minutes: ${{ inputs.timeout-minutes }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [amd64, arm64] | ||
| runs-on: ${{ fromJSON(github.actor != 'rapidsai' && '"ubuntu-latest"' || format('"${{ inputs.runs-on }}"', matrix.arch)) }} | ||
| name: "${{ inputs.tag }} (${{ matrix.arch }})" | ||
| outputs: | ||
| hash_amd64: ${{ steps.build.outputs.hash_amd64 }} | ||
| hash_arm64: ${{ steps.build.outputs.hash_arm64 }} | ||
| name: ${{ steps.build.outputs.name }} | ||
| repo: ${{ steps.build.outputs.repo }} | ||
| tag: ${{ steps.build.outputs.tag }} | ||
| version: ${{ steps.setup.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - id: setup | ||
| name: Setup versions | ||
| run: | | ||
| cat <<EOF | tee -a "$GITHUB_OUTPUT" | ||
| version=$(git describe --abbrev=0 --tags | sed 's/[a-zA-Z]//g' | cut -d '.' -f -2) | ||
| EOF | ||
|
|
||
| - name: Login to ghcr.io | ||
| if: inputs.push == 'true' | ||
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4 | ||
| with: | ||
| registry: "ghcr.io" | ||
| username: "${{ github.actor }}" | ||
| password: "${{ github.token }}" | ||
|
|
||
| - id: build | ||
| name: Build devcontainer (${{ matrix.arch }}) | ||
| uses: rapidsai/shared-actions/build-devcontainer@main | ||
| with: | ||
| arch: "${{ matrix.arch }}" | ||
| repo: "ghcr.io/${{ inputs.repo }}" | ||
| push: "${{ inputs.push }}" | ||
| retries: "${{ inputs.retries }}" | ||
| tag: "${{ inputs.tag }}" | ||
| version: "${{ steps.setup.outputs.version }}" | ||
| workspace-dir: "${{ inputs.workspace-dir }}" | ||
| devcontainer-json: "${{ inputs.devcontainer-json }}" | ||
|
|
||
| push: | ||
| if: inputs.push == 'true' | ||
| name: Push to ghcr.io | ||
| needs: [build] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Login to ghcr.io | ||
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4 | ||
| with: | ||
| registry: "ghcr.io" | ||
| username: "${{ github.actor }}" | ||
| password: "${{ github.token }}" | ||
|
|
||
| - id: push | ||
| name: Push manifest to ghcr.io | ||
| shell: bash --noprofile --norc -x -eo pipefail {0} | ||
| env: | ||
| hash_amd64: "${{ needs.build.outputs.hash_amd64 }}" | ||
| hash_arm64: "${{ needs.build.outputs.hash_arm64 }}" | ||
| name: "${{ needs.build.outputs.name }}" | ||
| name_latest: "${{ needs.build.outputs.name_latest }}" | ||
| ref_name: "${{ github.ref_name }}" | ||
| run: | | ||
| # Create the multiarch manifest | ||
| docker buildx imagetools create --tag "${name}" "${hash_amd64}" "${hash_arm64}"; | ||
| if [[ "${ref_name}" == main ]]; then | ||
| docker buildx imagetools create --tag "${name_latest}" "${hash_amd64}" "${hash_arm64}"; | ||
| fi |
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,94 @@ | ||
| name: Build devcontainers | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| cuda: | ||
| description: | | ||
| Stringified JSON array of CUDA versions to run this workflow for. | ||
| This is used to select .devcontainer/ directories local to wherever this workflow is invoked from. | ||
| For example, if a repository has directories '.devcontainer/cuda12.9-pip/' and '.devcontainer/cuda13.1-pip/', | ||
| '["12.9", "13.1"]' could be passed here to build both of those devcontainers in CI. | ||
| type: string | ||
| default: '["12.9", "13.1"]' | ||
| python_package_manager: | ||
| description: | | ||
| Stringified JSON array of Python package managers to run devcontainer builds for. | ||
| One of: '["conda"]', '["pip"]', '["conda", "pip"]'. | ||
| type: string | ||
| default: '["conda", "pip"]' | ||
| retries: | ||
| type: string | ||
| default: '3' | ||
| description: "Number of times to retry the image build" | ||
| push: | ||
| type: string | ||
| default: true | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: ./.github/workflows/build-devcontainer.yaml | ||
| permissions: | ||
| packages: write | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| cuda: ${{ fromJSON(inputs.cuda) }} | ||
| python_package_manager: ${{ fromJSON(inputs.python_package_manager) }} | ||
| with: | ||
| runs-on: 'linux-{0}-cpu4' | ||
| push: "${{ inputs.push }}" | ||
| retries: "${{ inputs.retries }}" | ||
| repo: "${{ github.repository }}/devcontainer" | ||
| tag: "cuda${{ matrix.cuda }}-${{ matrix.python_package_manager }}" | ||
| devcontainer-json: ".devcontainer/cuda${{ matrix.cuda }}-${{ matrix.python_package_manager }}/devcontainer.json" | ||
|
|
||
| cleanup: | ||
| if: inputs.push == 'true' | ||
| needs: [build] | ||
| name: Clean up untagged images | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - id: vars | ||
| name: Get image name, tags, and digests | ||
| env: | ||
| CUDA: "${{ inputs.cuda }}" | ||
| NAME_PREFIX: "ghcr.io/${{ github.actor }}" | ||
| NAME: "ghcr.io/${{ github.repository }}/devcontainer" | ||
| PYTHON_PACKAGE_MANAGER: "${{ inputs.python_package_manager }}" | ||
| VERSIONS: '["latest", "${{ needs.build.outputs.version }}"]' | ||
| run: | | ||
| set -xeuo pipefail | ||
|
|
||
| declare -a TAGS="($(jq -cnr \ | ||
| --argjson vers "${VERSIONS}" \ | ||
| --argjson cuda "${CUDA}" \ | ||
| --argjson pkgr "${PYTHON_PACKAGE_MANAGER}" \ | ||
| '[[$vers, $cuda, $pkgr] | combinations | [.[0], "cuda" + .[1], .[2]] | join("-")] | join(" ")'))" | ||
|
|
||
| declare -a DIGESTS=() | ||
| for TAG in "${TAGS[@]}"; do | ||
| mapfile -O "${#DIGESTS[@]}" -t DIGESTS < <( | ||
| docker buildx imagetools inspect --raw "${NAME}:${TAG}" | jq -r '.manifests.[] | .digest' | ||
| ) | ||
| done | ||
|
|
||
| NAME="${NAME#${NAME_PREFIX}/}" | ||
|
|
||
| # Set values to control ghcr.io cleanup below | ||
| cat <<EOF >> "$GITHUB_OUTPUT" | ||
| digests=${DIGESTS[*]} | ||
| name=${NAME} | ||
| tags=${TAGS[*]} | ||
| EOF | ||
|
|
||
| - name: Clean up untagged images | ||
| uses: snok/container-retention-policy@3b0972b2276b171b212f8c4efbca59ebba26eceb | ||
|
trxcllnt marked this conversation as resolved.
Outdated
|
||
| with: | ||
| cut-off: 1hr | ||
| tag-selection: untagged | ||
| token: "${{ github.token }}" | ||
| image-tags: "${{ steps.vars.outputs.tags }}" | ||
| image-names: "${{ steps.vars.outputs.name }}" | ||
| skip-shas: "${{ steps.vars.outputs.digests }}" | ||
| account: "${{ github.actor == github.triggering_actor && 'user' || github.actor }}" | ||
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.