Skip to content

Commit cc5259e

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

File tree

8 files changed

+243
-158
lines changed

8 files changed

+243
-158
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "basic checks"
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
version:
7+
description: "The short SHA to use as a version string"
8+
value: ${{ jobs.variables.outputs.version }}
9+
golang_version:
10+
description: "The golang version for this project"
11+
value: ${{ jobs.variables.outputs.golang_version }}
12+
pull_request:
13+
types:
14+
- opened
15+
- synchronize
16+
branches:
17+
- main
18+
- release-*
19+
20+
jobs:
21+
variables:
22+
uses: ./.github/workflows/variables.yaml
23+
24+
golang:
25+
needs:
26+
- variables
27+
uses: ./.github/workflows/golang.yaml
28+
with:
29+
golang_version: ${{ needs.variables.outputs.golang_version }}
30+
31+
helm:
32+
needs:
33+
- variables
34+
uses: ./.github/workflows/helm.yaml
35+
with:
36+
golang_version: ${{ needs.variables.outputs.golang_version }}
37+
38+
code-scanning:
39+
needs:
40+
- variables
41+
uses: ./.github/workflows/code_scanning.yaml
42+
with:
43+
golang_version: ${{ needs.variables.outputs.golang_version }}

.github/workflows/ci.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
basic:
26+
uses: ./.github/workflows/basic-checks.yaml
27+
28+
image:
29+
uses: ./.github/workflows/image.yaml
30+
needs:
31+
- basic
32+
secrets: inherit
33+
with:
34+
version: ${{ needs.basic.outputs.version }}
35+
build_multi_arch_images: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release-') }}
36+
37+
e2e-test:
38+
needs:
39+
- image
40+
- basic
41+
secrets: inherit
42+
uses: ./.github/workflows/e2e.yaml
43+
with:
44+
version: ${{ needs.basic.outputs.version }}
45+
golang_version: ${{ needs.basic.outputs.golang_version }}

.github/workflows/code_scanning.yaml

Lines changed: 10 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,23 +32,22 @@ 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
35+
4636
- name: Install Go
4737
uses: actions/setup-go@v5
4838
with:
49-
go-version: ${{ env.GOLANG_VERSION }}
39+
go-version: ${{ inputs.golang_version }}
40+
5041
- name: Initialize CodeQL
5142
uses: github/codeql-action/init@v3
5243
with:
5344
languages: go
5445
build-mode: manual
46+
5547
- shell: bash
5648
run: |
5749
make build
50+
5851
- name: Perform CodeQL Analysis
5952
uses: github/codeql-action/analyze@v3
6053
with:

.github/workflows/e2e.yaml

Lines changed: 60 additions & 56 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,69 +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: false
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-
if: ${{ failure() }}
74-
uses: slackapi/[email protected]
75-
with:
76-
method: chat.postMessage
77-
token: ${{ secrets.SLACK_BOT_TOKEN }}
78-
payload: |
79-
channel: ${{ secrets.SLACK_CHANNEL_ID }}
80-
text: |
81-
:x: On repository ${{ github.repository }}, the Workflow *${{ github.workflow }}* has failed.
82-
83-
Details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
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

0 commit comments

Comments
 (0)