-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[GitHub][CI] Factor out duplicate container building code into composite actions #166663
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
14 commits
Select commit
Hold shift + click to select a range
82372d7
[GitHub][CI] Factor out duplicate container building code into compos…
tstellar 001b8c4
Fix copy paste error
tstellar dd4893b
Fix string in build-ci-container
tstellar e2fe1fb
Fix container name
tstellar 54b8192
Fix container name again
tstellar 2478397
Fix printf
tstellar b8394d8
Fix test command
tstellar 448f7fd
Undo test
tstellar d06a65b
Fix names
tstellar b23fa77
Merge remote-tracking branch 'origin/main' into HEAD
tstellar ebb3902
Add arch to container name display
tstellar c16bb9f
Fix name string
tstellar 29033ba
Fix name string
tstellar 3526602
Fix name string
tstellar 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
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,95 @@ | ||
| name: Build Container | ||
| description: >- | ||
| Build and test a container using the standard llvm naming scheme for containers. | ||
| inputs: | ||
| tag: | ||
| description: >- | ||
| The tag to use for this container. | ||
| required: false | ||
| container-name: | ||
| description: >- | ||
| The name for the container. | ||
| required: true | ||
| dockerfile: | ||
| description: >- | ||
| Path to docker file. | ||
| required: false | ||
| target: | ||
| description: >- | ||
| The container target to build 'passed to podman via ---target option' | ||
| required: false | ||
| context: | ||
| description: >- | ||
| Path to context for the container build. | ||
| required: false | ||
| test-command: | ||
| description: >- | ||
| Test command to run to ensure the container is working correctly. | ||
| required: false | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| # podman is not installed by default on the ARM64 images. | ||
| - name: Install Podman | ||
| if: runner.arch == 'ARM64' | ||
| shell: bash | ||
| run: | | ||
| sudo apt-get install podman | ||
| - name: Build Container | ||
| shell: bash | ||
| env: | ||
| INPUT_TAG: ${{inputs.tag }} | ||
| INPUT_CONTAINER_NAME: ${{ inputs.container-name }} | ||
| INPUT_TARGET: ${{ inputs.target }} | ||
| INPUT_DOCKERFILE: ${{ inputs.dockerfile }} | ||
| INPUT_CONTEXT: ${{ inputs.context }} | ||
| id: build | ||
| run: | | ||
| env | ||
| tag="${INPUT_TAG:-$(git rev-parse --short=12 HEAD)}" | ||
| case "$RUNNER_ARCH" in | ||
| ARM64) | ||
| container_arch="arm64v8" | ||
| ;; | ||
| *) | ||
| container_arch="amd64" | ||
| ;; | ||
| esac | ||
| container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/$container_arch/$INPUT_CONTAINER_NAME:$tag" | ||
| container_filename="$(echo $container_name | sed -e 's/\//-/g' -e 's/:/-/g').tar" | ||
| if [ -n "$INPUT_TARGET" ]; then | ||
| podman_options="$podman_options --target $INPUT_TARGET" | ||
| fi | ||
| if [ -n "$INPUT_DOCKERFILE" ]; then | ||
| podman_options="$podman_options -f $INPUT_DOCKERFILE" | ||
| fi | ||
| podman_options="$podman_options ${INPUT_CONTEXT:-.}" | ||
| echo "Podman Options: $podman_options" | ||
| podman build -t $container_name $podman_options | ||
| podman save $container_name > $container_filename | ||
| echo "container-full-name=$container_name" >> $GITHUB_OUTPUT | ||
| - name: Create container artifact | ||
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||
| with: | ||
| name: ${{ inputs.container-name }}-${{ runner.arch }} | ||
| path: "*.tar" | ||
| retention-days: 14 | ||
|
|
||
| - name: Test container | ||
| shell: bash | ||
| if: inputs.test-command | ||
| env: | ||
| INPUT_TEST_COMMAND: ${{ inputs.test-command }} | ||
| CONTAINER_FULL_NAME: ${{ steps.build.outputs.container-full-name }} | ||
| run: | | ||
| podman run --pull=never --rm -it $CONTAINER_FULL_NAME /usr/bin/bash -x -c "$INPUT_TEST_COMMAND" | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it is possible, but could we give custom names for each
includein matrix?The resulting container names in UI are a bit odd because they include
test-command:build-ci-container-tooling (code-lint, cd $HOME && clang-tidy --version | grep version && clang-tidy...)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be possible by setting the
namekey explicitly for the job.