Skip to content
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

[no-relnote] Configure all GitHub actions as reusable workflow #915

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

ArangoGutierrez
Copy link
Collaborator

No description provided.

@ArangoGutierrez
Copy link
Collaborator Author

image

@ArangoGutierrez ArangoGutierrez self-assigned this Feb 10, 2025
Comment on lines 18 to 24
pull_request:
types:
- opened
- synchronize
branches:
- main
- release-*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to not use the "standard" triggers for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is a good first step to run the code scan before performing any extra steps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wasn't my question. Does it make sense to also run this on PRs?

@@ -67,8 +73,8 @@ jobs:

- name: Run e2e tests
env:
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit
VERSION: ${COMMIT_SHORT_SHA}
IMAGE_NAME: ghcr.io/${{ inputs.lowercase_repo_owner }}/container-toolkit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Isn't this always nvidia?

.github/workflows/ci.yaml Outdated Show resolved Hide resolved
@@ -84,18 +93,6 @@ jobs:
steps:
- uses: actions/checkout@v4
name: Check out code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version is checked out here? Should we align this with the short sha?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would make sense in a follow-up PR. The defaults are ok, but moving forward when writing more reusable workflows, it will make more sense

https://github.com/actions/checkout?tab=readme-ov-file#usage

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shure. Could you please clarify which verison is checked out by default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    # The branch, tag or SHA to checkout. When checking out the repository that
    # triggered a workflow, this defaults to the reference or SHA for that event.
    # Otherwise, uses the default branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is, if this is triggered by a workflow call, is the SHA that is checked out the current version in the PR, or the SHA of the default branch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the SHA of the commit that triggered the action, unregarding of the branch (that's why copy-pr-bot works)

.github/workflows/ci.yaml Outdated Show resolved Hide resolved
if [[ "${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release-') }}" == "true" ]]; then
echo "build_multi_arch_images=false" >> $GITHUB_OUTPUT
else
echo "build_multi_arch_images=true" >> $GITHUB_OUTPUT
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be clearer to invert the conditional:

Suggested change
if [[ "${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release-') }}" == "true" ]]; then
echo "build_multi_arch_images=false" >> $GITHUB_OUTPUT
else
echo "build_multi_arch_images=true" >> $GITHUB_OUTPUT
fi
if [[ "${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }}" == "true" ]]; then
echo "build_multi_arch_images=true" >> $GITHUB_OUTPUT
else
echo "build_multi_arch_images=false" >> $GITHUB_OUTPUT
fi

Actually, could we simplify this further to:

Suggested change
if [[ "${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release-') }}" == "true" ]]; then
echo "build_multi_arch_images=false" >> $GITHUB_OUTPUT
else
echo "build_multi_arch_images=true" >> $GITHUB_OUTPUT
fi
multi_arch_required="${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }}"
echo "build_multi_arch_images=${{ multi_arch_required }}" >> $GITHUB_OUTPUT

@ArangoGutierrez ArangoGutierrez force-pushed the e2e_tests02 branch 2 times, most recently from 87be0dd to d45f14d Compare February 11, 2025 09:45
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
build_multi_arch_images: ${{ steps.build_multi_arch_images.outputs.value }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this just be:

Suggested change
build_multi_arch_images: ${{ steps.build_multi_arch_images.outputs.value }}
build_multi_arch_images: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }}

and then we don't need the scripts below?

@@ -84,18 +93,6 @@ jobs:
steps:
- uses: actions/checkout@v4
name: Check out code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shure. Could you please clarify which verison is checked out by default.

VERSION: ${COMMIT_SHORT_SHA}
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
VERSION: ${{ inputs.version }}
PUSH_ON_BUILD: ${{ inputs.push_on_build }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about?

Suggested change
PUSH_ON_BUILD: ${{ inputs.push_on_build }}
PUSH_ON_BUILD: true

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going for reusability of the workflow file, but default to true is ok

Copy link
Member

@elezar elezar Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we need to, we can add push_on_build to the inputs and set a default value.

.github/workflows/image.yaml Outdated Show resolved Hide resolved
echo "build_multi_arch_images=$multi_arch_required" >> $GITHUB_OUTPUT

golang:
needs: code-scanning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the risk in running the golang tests and the code-scanning in parallel?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none. let me re-arrange

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now we run the basic checks in parallel

prepare-variables:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the following work?

Suggested change
version: ${{ steps.version.outputs.version }}
version: ${{ github.sha.substring(0,8) }}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it doesn't

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a matter of interest, what error does it give? Do we have a reference of which functions are available to us? We do use startsWith, for example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code-scanning:
uses: ./.github/workflows/code_scanning.yaml

prepare-variables:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to just call this variables?

IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit
VERSION: ${COMMIT_SHORT_SHA}
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
VERSION: ${{ steps.vars.outputs.version }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VERSION: ${{ steps.vars.outputs.version }}
VERSION: ${{ inputs.version }}

@@ -67,8 +70,8 @@ jobs:

- name: Run e2e tests
env:
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit
VERSION: ${COMMIT_SHORT_SHA}
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do move e2e.yaml to a central repo, we would have to have this as an input.

(Out of scope for this PR).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

@elezar
Copy link
Member

elezar commented Feb 12, 2025

If I recall correctly, the action results are tracked by SHA and I was wondering whether it makes sense to trigger the CodeQL and Golang checks on PRs as well? The motivation being that these would provide early feedback to contributors without requireing an /ok-to-test to trigger the PR copy.

Update: One place where this is required is for dependabot PRs. These do not "automatically" create a PR branch.

branches:
- main
- release-*
workflow_call:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we want these to run on PRs so that they trigger for dependabot we may want to update this to:

Suggested change
workflow_call:
workflow_call: {}
pull_request:
types:
- opened
- synchronize
branches:
- main
- release-*

branches:
- main
- release-*
workflow_call:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we want these to run on PRs so that they trigger for dependabot we may want to update this to:

Suggested change
workflow_call:
workflow_call: {}
pull_request:
types:
- opened
- synchronize
branches:
- main
- release-*

Copy link
Member

@elezar elezar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ArangoGutierrez

Looks good.

@ArangoGutierrez ArangoGutierrez merged commit 5db5ddb into NVIDIA:main Feb 12, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants