Skip to content

Commit 1440638

Browse files
[no-relnote] COnfigure all GitHub actions as reusable workflow
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent fa1379c commit 1440638

File tree

5 files changed

+81
-49
lines changed

5 files changed

+81
-49
lines changed

.github/workflows/ci.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: CI Pipeline
16+
17+
on:
18+
push:
19+
branches:
20+
- "pull-request/[0-9]+"
21+
- main
22+
- release-*
23+
24+
jobs:
25+
code-scanning:
26+
uses: ./.github/workflows/code_scanning.yaml
27+
28+
prepare-variables:
29+
runs-on: ubuntu-latest
30+
outputs:
31+
version: ${{ steps.version.outputs.version }}
32+
steps:
33+
- name: Generate Commit Short SHA
34+
id: version
35+
run: echo "version=$(echo $GITHUB_SHA | cut -c1-8)" >> "$GITHUB_OUTPUT"
36+
37+
golang:
38+
uses: ./.github/workflows/golang.yaml
39+
40+
image:
41+
uses: ./.github/workflows/image.yaml
42+
needs: [prepare-variables, golang, code-scanning]
43+
secrets: inherit
44+
with:
45+
version: ${{ needs.prepare-variables.outputs.version }}
46+
build_multi_arch_images: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }}
47+
48+
e2e-test:
49+
needs: image
50+
secrets: inherit
51+
uses: ./.github/workflows/e2e.yaml
52+
with:
53+
version: ${{ needs.prepare-variables.outputs.version }}

.github/workflows/code_scanning.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,7 @@
1515
name: "CodeQL"
1616

1717
on:
18-
pull_request:
19-
types:
20-
- opened
21-
- synchronize
22-
branches:
23-
- main
24-
- release-*
25-
push:
26-
branches:
27-
- main
28-
- release-*
18+
workflow_call:
2919

3020
jobs:
3121
analyze:

.github/workflows/e2e.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ name: End-to-end Tests
1616

1717
on:
1818
workflow_call:
19-
inputs: {}
19+
inputs:
20+
version:
21+
required: true
22+
type: string
2023
secrets:
2124
AWS_ACCESS_KEY_ID:
2225
required: true
@@ -67,8 +70,8 @@ jobs:
6770

6871
- name: Run e2e tests
6972
env:
70-
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit
71-
VERSION: ${COMMIT_SHORT_SHA}
73+
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
74+
VERSION: ${{ steps.vars.outputs.version }}
7275
SSH_KEY: ${{ secrets.AWS_SSH_KEY }}
7376
E2E_SSH_USER: ${{ secrets.E2E_SSH_USER }}
7477
E2E_SSH_HOST: ${{ steps.holodeck_public_dns_name.outputs.result }}

.github/workflows/golang.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,7 @@
1515
name: Golang
1616

1717
on:
18-
pull_request:
19-
types:
20-
- opened
21-
- synchronize
22-
branches:
23-
- main
24-
- release-*
25-
push:
26-
branches:
27-
- main
28-
- release-*
18+
workflow_call:
2919

3020
jobs:
3121
check:

.github/workflows/image.yaml

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
name: image
1717

1818
on:
19-
push:
20-
branches:
21-
- "pull-request/[0-9]+"
22-
- main
23-
- release-*
19+
workflow_call:
20+
inputs:
21+
version:
22+
required: true
23+
type: string
24+
build_multi_arch_images:
25+
required: true
26+
type: string
2427

2528
jobs:
2629
packages:
@@ -46,20 +49,25 @@ jobs:
4649
- ispr: true
4750
target: centos8-ppc64le
4851
fail-fast: false
52+
4953
steps:
5054
- uses: actions/checkout@v4
5155
name: Check out code
56+
5257
- name: Set up QEMU
5358
uses: docker/setup-qemu-action@v3
5459
with:
5560
image: tonistiigi/binfmt:master
61+
5662
- name: Set up Docker Buildx
5763
uses: docker/setup-buildx-action@v3
64+
5865
- name: build ${{ matrix.target }} packages
5966
run: |
6067
sudo apt-get install -y coreutils build-essential sed git bash make
6168
echo "Building packages"
6269
./scripts/build-packages.sh ${{ matrix.target }}
70+
6371
- name: 'Upload Artifacts'
6472
uses: actions/upload-artifact@v4
6573
with:
@@ -84,24 +92,15 @@ jobs:
8492
steps:
8593
- uses: actions/checkout@v4
8694
name: Check out code
87-
- name: Calculate build vars
88-
id: vars
89-
run: |
90-
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
91-
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
9295

93-
BUILD_MULTI_ARCH_IMAGES="true"
94-
if [[ "${{ matrix.ispr }}" == "true" ]]; then
95-
BUILD_MULTI_ARCH_IMAGES="false"
96-
fi
97-
echo "PUSH_ON_BUILD=true" >> $GITHUB_ENV
98-
echo "BUILD_MULTI_ARCH_IMAGES=${BUILD_MULTI_ARCH_IMAGES}" >> $GITHUB_ENV
9996
- name: Set up QEMU
10097
uses: docker/setup-qemu-action@v3
10198
with:
10299
image: tonistiigi/binfmt:master
100+
103101
- name: Set up Docker Buildx
104102
uses: docker/setup-buildx-action@v3
103+
105104
- name: Get built packages
106105
uses: actions/download-artifact@v4
107106
with:
@@ -115,16 +114,13 @@ jobs:
115114
registry: ghcr.io
116115
username: ${{ github.actor }}
117116
password: ${{ secrets.GITHUB_TOKEN }}
117+
118118
- name: Build image
119119
env:
120-
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit
121-
VERSION: ${COMMIT_SHORT_SHA}
120+
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
121+
VERSION: "true"
122+
PUSH_ON_BUILD: ${{ inputs.push_on_build }}
123+
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
122124
run: |
123125
echo "${VERSION}"
124126
make -f deployments/container/Makefile build-${{ matrix.dist }}
125-
126-
test:
127-
name: End-to-end Tests
128-
uses: ./.github/workflows/e2e.yaml
129-
secrets: inherit
130-
needs: image

0 commit comments

Comments
 (0)