Skip to content

Commit eeb795e

Browse files
committed
[no-relnotes] Use reusable workflows for CI
Signed-off-by: Evan Lezar <[email protected]>
1 parent bd98999 commit eeb795e

File tree

9 files changed

+247
-159
lines changed

9 files changed

+247
-159
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "basic checks"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
golang_version:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
code-scanning:
12+
uses: ./.github/workflows/code_scanning.yaml
13+
with:
14+
golang_version: ${{ needs.variables.outputs.golang_version }}
15+
16+
golang:
17+
uses: ./.github/workflows/golang.yaml
18+
with:
19+
golang_version: ${{ needs.variables.outputs.golang_version }}
20+
21+
helm:
22+
uses: ./.github/workflows/helm.yaml
23+
with:
24+
golang_version: ${{ needs.variables.outputs.golang_version }}
25+

.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+
variables:
26+
uses: ./.github/workflows/variables.yaml
27+
28+
checks:
29+
needs:
30+
- variables
31+
uses: ./.github/workflows/basic-checks.yaml
32+
with:
33+
golang_version: ${{ needs.variables.outputs.golang_version }}
34+
35+
image:
36+
uses: ./.github/workflows/image.yaml
37+
needs:
38+
- variables
39+
- checks
40+
secrets: inherit
41+
with:
42+
version: ${{ needs.variables.outputs.version }}
43+
build_multi_arch_images: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }}
44+
45+
e2e-test:
46+
needs:
47+
- image
48+
- variables
49+
secrets: inherit
50+
uses: ./.github/workflows/e2e.yaml
51+
with:
52+
version: ${{ needs.variables.outputs.version }}
53+
golang_version: ${{ needs.variables.outputs.golang_version }}

.github/workflows/code_scanning.yaml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@
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:
19+
inputs:
20+
golang_version:
21+
required: true
22+
type: string
2923

3024
jobs:
3125
analyze:
@@ -38,15 +32,10 @@ jobs:
3832
steps:
3933
- name: Checkout repository
4034
uses: actions/checkout@v4
41-
- name: Get Golang version
42-
id: vars
43-
run: |
44-
GOLANG_VERSION=$(./hack/golang-version.sh)
45-
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV
4635
- name: Install Go
4736
uses: actions/setup-go@v5
4837
with:
49-
go-version: ${{ env.GOLANG_VERSION }}
38+
go-version: ${{ inputs.golang_version }}
5039
- name: Initialize CodeQL
5140
uses: github/codeql-action/init@v3
5241
with:

.github/workflows/e2e.yaml

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 NVIDIA CORPORATION
1+
# Copyright 2025 NVIDIA CORPORATION
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -15,70 +15,73 @@
1515
name: End-to-end Tests
1616

1717
on:
18-
workflow_run:
19-
workflows: [Image]
20-
types:
21-
- completed
22-
branches:
23-
- "pull-request/[0-9]+"
24-
- main
25-
- release-*
18+
workflow_call:
19+
inputs:
20+
version:
21+
required: true
22+
type: string
23+
golang_version:
24+
required: true
25+
type: string
26+
secrets:
27+
AWS_ACCESS_KEY_ID:
28+
required: true
29+
AWS_SECRET_ACCESS_KEY:
30+
required: true
31+
AWS_SSH_KEY:
32+
required: true
33+
SLACK_BOT_TOKEN:
34+
required: true
35+
SLACK_CHANNEL_ID:
36+
required: true
2637

2738
jobs:
2839
e2e-tests:
2940
runs-on: linux-amd64-cpu4
30-
if: ${{ github.event.workflow_run.conclusion == 'success' }} && ${{ github.event.workflow_run.event == 'push' }}
3141
steps:
32-
- name: Check out code
33-
uses: actions/checkout@v4
42+
- name: Check out code
43+
uses: actions/checkout@v4
3444

35-
- name: Calculate build vars
36-
id: vars
37-
run: |
38-
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
39-
GOLANG_VERSION=$(./hack/golang-version.sh)
40-
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV
45+
- name: Install Go
46+
uses: actions/setup-go@v5
47+
with:
48+
go-version: ${{ inputs.golang_version }}
4149

42-
- name: Install Go
43-
uses: actions/setup-go@v5
44-
with:
45-
go-version: ${{ env.GOLANG_VERSION }}
50+
- name: Set up Holodeck
51+
uses: NVIDIA/[email protected]
52+
with:
53+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
54+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
55+
aws_ssh_key: ${{ secrets.AWS_SSH_KEY }}
56+
holodeck_config: "tests/e2e/infra/aws.yaml"
4657

47-
- name: Set up Holodeck
48-
uses: NVIDIA/[email protected]
49-
with:
50-
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
51-
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
52-
aws_ssh_key: ${{ secrets.AWS_SSH_KEY }}
53-
holodeck_config: "tests/e2e/infra/aws.yaml"
58+
- name: Run e2e tests
59+
env:
60+
KUBECONFIG: ${{ github.workspace }}/kubeconfig
61+
E2E_IMAGE_REPO: ghcr.io/nvidia/k8s-device-plugin
62+
E2E_IMAGE_TAG: ${{ inputs.version }} -ubi9
63+
LOG_ARTIFACTS: ${{ github.workspace }}/e2e_logs
64+
run: |
65+
make test-e2e
5466
55-
- name: Run e2e tests
56-
env:
57-
KUBECONFIG: ${{ github.workspace }}/kubeconfig
58-
E2E_IMAGE_REPO: ghcr.io/nvidia/k8s-device-plugin
59-
E2E_IMAGE_TAG: ${COMMIT_SHORT_SHA}-ubi9
60-
LOG_ARTIFACTS: ${{ github.workspace }}/e2e_logs
61-
run: |
62-
make test-e2e
67+
- name: Archive test logs
68+
if: ${{ failure() }}
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: e2e-test-logs
72+
path: ./e2e_logs/
73+
retention-days: 15
6374

64-
- name: Archive test logs
65-
if: ${{ failure() }}
66-
uses: actions/upload-artifact@v4
67-
with:
68-
name: e2e-test-logs
69-
path: ./e2e_logs/
70-
retention-days: 15
75+
- name: Send Slack alert notification
76+
id: slack
77+
if: ${{ failure() }}
78+
uses: slackapi/[email protected]
79+
env:
80+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
81+
SUMMARY_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
82+
with:
83+
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
84+
slack-message: |
85+
:x: On repository ${{ github.repository }} the Workflow *${{ github.workflow }}* has failed.
7186
72-
- name: Send Slack alert notification
73-
id: slack
74-
if: ${{ failure() }}
75-
uses: slackapi/[email protected]
76-
env:
77-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
78-
SUMMARY_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
79-
with:
80-
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
81-
slack-message: |
82-
:x: On repository ${{ github.repository }} the Workflow *${{ github.workflow }}* has failed.
83-
84-
Details: ${{ env.SUMMARY_URL }}
87+
Details: ${{ env.SUMMARY_URL }}

.github/workflows/golang.yaml

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,22 @@
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:
19+
inputs:
20+
golang_version:
21+
required: true
22+
type: string
2923

3024
jobs:
3125
check:
3226
runs-on: ubuntu-latest
3327
steps:
3428
- uses: actions/checkout@v4
3529
name: Checkout code
36-
- name: Get Golang version
37-
id: vars
38-
run: |
39-
GOLANG_VERSION=$(./hack/golang-version.sh)
40-
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV
4130
- name: Install Go
4231
uses: actions/setup-go@v5
4332
with:
44-
go-version: ${{ env.GOLANG_VERSION }}
33+
go-version: ${{ inputs.golang_versions }}
4534
- name: Lint
4635
uses: golangci/golangci-lint-action@v6
4736
with:
@@ -56,31 +45,21 @@ jobs:
5645
name: Unit test
5746
runs-on: ubuntu-latest
5847
steps:
59-
- name: Checkout code
60-
uses: actions/checkout@v4
61-
- name: Get Golang version
62-
id: vars
63-
run: |
64-
GOLANG_VERSION=$(./hack/golang-version.sh)
65-
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
66-
- name: Install Go
67-
uses: actions/setup-go@v5
68-
with:
69-
go-version: ${{ env.GOLANG_VERSION }}
70-
- run: make test
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
- name: Install Go
51+
uses: actions/setup-go@v5
52+
with:
53+
go-version: ${{ inputs.golang_version }}
54+
- run: make test
7155
build:
7256
name: Build
7357
runs-on: ubuntu-latest
7458
steps:
75-
- name: Checkout code
76-
uses: actions/checkout@v4
77-
- name: Get Golang version
78-
id: vars
79-
run: |
80-
GOLANG_VERSION=$(./hack/golang-version.sh)
81-
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
82-
- name: Install Go
83-
uses: actions/setup-go@v5
84-
with:
85-
go-version: ${{ env.GOLANG_VERSION }}
86-
- run: make build
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
- name: Install Go
62+
uses: actions/setup-go@v5
63+
with:
64+
go-version: ${{ inputs.golang_version }}
65+
- run: make build

.github/workflows/helm.yaml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@
1515
name: Helm
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:
19+
inputs:
20+
golang_version:
21+
required: true
22+
type: string
2923

3024
jobs:
3125
test:
@@ -34,13 +28,8 @@ jobs:
3428
steps:
3529
- name: Checkout code
3630
uses: actions/checkout@v4
37-
- name: Get Golang version
38-
id: vars
39-
run: |
40-
GOLANG_VERSION=$(./hack/golang-version.sh)
41-
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
4231
- name: Install Go
4332
uses: actions/setup-go@v5
4433
with:
45-
go-version: ${{ env.GOLANG_VERSION }}
34+
go-version: ${{ inputs.golang_version }}
4635
- run: make test-helm

0 commit comments

Comments
 (0)