Skip to content

Commit

Permalink
[no-relnote] COnfigure all GitHub actions as reusable workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
  • Loading branch information
ArangoGutierrez committed Feb 10, 2025
1 parent fa1379c commit 911ed71
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 50 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2025 NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: CI Pipeline

on:
push:
branches:
- "pull-request/[0-9]+"
- main
- release-*

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

prepare-variables:
needs: code-scanning
runs-on: ubuntu-latest
outputs:
commit_short_sha: ${{ steps.commit_short_sha.outputs.commit_short_sha }}
lowercase_repo_owner: ${{ steps.lowercase_repo_owner.outputs.value }}
build_multi_arch_images: ${{ steps.build_multi_arch_images.outputs.value }}
push_on_build: ${{ steps.docker_build_args.outputs.push_on_build }}
steps:
- name: Generate Commit Short SHA
id: commit_short_sha
run: echo "commit_short_sha=$(echo $GITHUB_SHA | cut -c1-8)" >> "$GITHUB_OUTPUT"

- name: Convert Repository Owner to Lowercase
id: lowercase_repo_owner
run: echo "lowercase_repo_owner=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT

- name: Determine Multi-Arch Build Setting
id: build_multi_arch_images
run: |
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
- name: Set Docker Build Arguments
id: docker_build_args
run: |
echo "push_on_build=true" >> $GITHUB_OUTPUT
golang:
needs: code-scanning
uses: ./.github/workflows/golang.yaml

image:
uses: ./.github/workflows/image.yaml
needs: prepare-variables
secrets: inherit
with:
commit_short_sha: ${{ needs.prepare-variables.outputs.commit_short_sha }}
lowercase_repo_owner: ${{ needs.prepare-variables.outputs.lowercase_repo_owner }}
build_multi_arch_images: ${{ needs.prepare-variables.outputs.build_multi_arch_images }}
push_on_build: ${{ needs.prepare-variables.outputs.push_on_build }}

e2e-test:
needs: image
secrets: inherit
uses: ./.github/workflows/e2e.yaml
with:
commit_short_sha: ${{ needs.prepare-variables.outputs.commit_short_sha }}
lowercase_repo_owner: ${{ needs.prepare-variables.outputs.lowercase_repo_owner }}
12 changes: 1 addition & 11 deletions .github/workflows/code_scanning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,7 @@
name: "CodeQL"

on:
pull_request:
types:
- opened
- synchronize
branches:
- main
- release-*
push:
branches:
- main
- release-*
workflow_call:

jobs:
analyze:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ name: End-to-end Tests

on:
workflow_call:
inputs: {}
inputs:
commit_short_sha:
required: true
type: string
lowercase_repo_owner:
required: true
type: string
secrets:
AWS_ACCESS_KEY_ID:
required: true
Expand Down Expand Up @@ -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
VERSION: ${{ steps.vars.outputs.commit_short_sha }}
SSH_KEY: ${{ secrets.AWS_SSH_KEY }}
E2E_SSH_USER: ${{ secrets.E2E_SSH_USER }}
E2E_SSH_HOST: ${{ steps.holodeck_public_dns_name.outputs.result }}
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,7 @@
name: Golang

on:
pull_request:
types:
- opened
- synchronize
branches:
- main
- release-*
push:
branches:
- main
- release-*
workflow_call:

jobs:
check:
Expand Down
43 changes: 18 additions & 25 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@
name: image

on:
push:
branches:
- "pull-request/[0-9]+"
- main
- release-*
workflow_call:
inputs:
commit_short_sha:
required: true
type: string
lowercase_repo_owner:
required: true
type: string
build_multi_arch_images:
required: true
type: string
push_on_build:
required: true
type: string

jobs:
packages:
Expand Down Expand Up @@ -84,18 +93,6 @@ jobs:
steps:
- uses: actions/checkout@v4
name: Check out code
- name: Calculate build vars
id: vars
run: |
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
BUILD_MULTI_ARCH_IMAGES="true"
if [[ "${{ matrix.ispr }}" == "true" ]]; then
BUILD_MULTI_ARCH_IMAGES="false"
fi
echo "PUSH_ON_BUILD=true" >> $GITHUB_ENV
echo "BUILD_MULTI_ARCH_IMAGES=${BUILD_MULTI_ARCH_IMAGES}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
Expand All @@ -117,14 +114,10 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
env:
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit
VERSION: ${COMMIT_SHORT_SHA}
IMAGE_NAME: ghcr.io/${{ inputs.lowercase_repo_owner }}/container-toolkit
VERSION: ${{ inputs.commit_short_sha }}
PUSH_ON_BUILD: ${{ inputs.push_on_build }}
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
run: |
echo "${VERSION}"
make -f deployments/container/Makefile build-${{ matrix.dist }}
test:
name: End-to-end Tests
uses: ./.github/workflows/e2e.yaml
secrets: inherit
needs: image

0 comments on commit 911ed71

Please sign in to comment.