Skip to content

Commit 52089b5

Browse files
yongwwwyzh119
andauthored
docker: add image tags with date-SHA suffix (#1839)
Previously, FlashInfer CI Docker images only maintained a 'latest' tag, making it difficult to rollback to older images when regressions occur. This PR add the tag with date-sha. ## 📌 Description <!-- What does this PR do? Briefly describe the changes and why they’re needed. --> ## 🔍 Related Issues <!-- Link any related issues here --> ## 🚀 Pull Request Checklist Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete. ### ✅ Pre-commit Checks - [x] I have installed `pre-commit` by running `pip install pre-commit` (or used your preferred method). - [x] I have installed the hooks with `pre-commit install`. - [x] I have run the hooks manually with `pre-commit run --all-files` and fixed any reported issues. > If you are unsure about how to set up `pre-commit`, see [the pre-commit documentation](https://pre-commit.com/). ## 🧪 Tests - [x] Tests have been added or updated as needed. - [ ] All tests are passing (`unittest`, etc.). ## Reviewer Notes <!-- Optional: anything you'd like reviewers to focus on, concerns, etc. --> --------- Co-authored-by: yzh119 <[email protected]> Co-authored-by: Zihao Ye <[email protected]>
1 parent 85445d5 commit 52089b5

File tree

2 files changed

+97
-9
lines changed

2 files changed

+97
-9
lines changed

.github/workflows/release-ci-docker.yml

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,43 @@ name: Release CI Docker
22

33
on:
44
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'docker/**'
10+
pull_request:
11+
branches:
12+
- main
13+
paths:
14+
- 'docker/**'
15+
- '.github/workflows/release-ci-docker.yml'
516

617
jobs:
18+
generate-tag:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
date_sha: ${{ steps.generate_tag.outputs.date_sha }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Generate version tag
26+
id: generate_tag
27+
run: |
28+
DATE_SHA=$(date +'%Y%m%d')-$(git rev-parse --short HEAD)
29+
echo "date_sha=${DATE_SHA}" >> $GITHUB_OUTPUT
30+
echo "Generated version tag: ${DATE_SHA}"
31+
732
build:
833
runs-on: ubuntu-latest
34+
needs: generate-tag
935
strategy:
1036
matrix:
1137
cuda: [cu126, cu128, cu129, cu130]
1238
arch: [amd64, arm64]
1339
steps:
40+
- uses: actions/checkout@v4
41+
1442
- name: Free Disk Space
1543
uses: jlumbroso/free-disk-space@main
1644
with:
@@ -22,15 +50,14 @@ jobs:
2250
docker-images: true
2351
swap-storage: true
2452

25-
- uses: actions/checkout@v4
26-
2753
- name: Set up QEMU
2854
uses: docker/setup-qemu-action@v3
2955

3056
- name: Set up Docker Buildx
3157
uses: docker/setup-buildx-action@v3
3258

3359
- name: Login to Docker Hub
60+
if: github.event_name != 'pull_request'
3461
uses: docker/login-action@v3
3562
with:
3663
username: flashinfer
@@ -42,17 +69,18 @@ jobs:
4269
context: docker
4370
file: docker/Dockerfile.${{ matrix.cuda }}
4471
platforms: linux/${{ matrix.arch }}
45-
push: true
72+
push: ${{ github.event_name != 'pull_request' }}
4673
tags: |
47-
flashinfer/flashinfer-ci-${{ matrix.cuda }}:${{ matrix.arch }}
74+
flashinfer/flashinfer-ci-${{ matrix.cuda }}:${{ matrix.arch }}-${{ needs.generate-tag.outputs.date_sha }}
4875
cache-from: type=registry,ref=flashinfer/flashinfer-ci-${{ matrix.cuda }}:buildcache-${{ matrix.arch }}
49-
cache-to: type=registry,ref=flashinfer/flashinfer-ci-${{ matrix.cuda }}:buildcache-${{ matrix.arch }},mode=max
76+
cache-to: ${{ github.event_name != 'pull_request' && format('type=registry,ref=flashinfer/flashinfer-ci-{0}:buildcache-{1},mode=max', matrix.cuda, matrix.arch) || '' }}
5077
provenance: false
5178
sbom: false
5279

5380
create-manifests:
81+
if: github.event_name != 'pull_request'
5482
runs-on: ubuntu-latest
55-
needs: build
83+
needs: [generate-tag, build]
5684
strategy:
5785
matrix:
5886
cuda: [cu126, cu128, cu129, cu130]
@@ -67,7 +95,11 @@ jobs:
6795
password: ${{ secrets.DOCKERHUB_TOKEN }}
6896

6997
- name: Create and push multi-arch manifest for ${{ matrix.cuda }}
98+
env:
99+
DATE_SHA: ${{ needs.generate-tag.outputs.date_sha }}
70100
run: |
71-
docker buildx imagetools create -t flashinfer/flashinfer-ci-${{ matrix.cuda }}:latest \
72-
flashinfer/flashinfer-ci-${{ matrix.cuda }}:amd64 \
73-
flashinfer/flashinfer-ci-${{ matrix.cuda }}:arm64
101+
docker buildx imagetools create \
102+
-t flashinfer/flashinfer-ci-${{ matrix.cuda }}:${DATE_SHA} \
103+
-t flashinfer/flashinfer-ci-${{ matrix.cuda }}:latest \
104+
flashinfer/flashinfer-ci-${{ matrix.cuda }}:amd64-${DATE_SHA} \
105+
flashinfer/flashinfer-ci-${{ matrix.cuda }}:arm64-${DATE_SHA}

Jenkinsfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,56 @@ def unpack_lib(name, libs) {
6565
"""
6666
}
6767

68+
def should_skip_build() {
69+
// Skip build if changes are only in documentation/config directories
70+
def skip_patterns = [
71+
'README.md',
72+
'.github/',
73+
'docs/',
74+
'docker/',
75+
'licenses/',
76+
'LICENSE',
77+
'NOTICE',
78+
'version.txt'
79+
]
80+
81+
if (env.CHANGE_ID) {
82+
// This is a PR build, check changed files
83+
def changedFiles = []
84+
try {
85+
changedFiles = sh(
86+
script: 'git diff --name-only origin/${CHANGE_TARGET}...HEAD',
87+
returnStdout: true
88+
).trim().split('\n')
89+
} catch (Exception e) {
90+
echo "Could not determine changed files: ${e.toString()}"
91+
return false
92+
}
93+
94+
if (changedFiles.size() == 0) {
95+
return false
96+
}
97+
98+
// Check if all changed files match skip patterns
99+
def allSkippable = changedFiles.every { file ->
100+
skip_patterns.any { pattern ->
101+
if (pattern.endsWith('/')) {
102+
file.startsWith(pattern)
103+
} else {
104+
file == pattern
105+
}
106+
}
107+
}
108+
109+
if (allSkippable) {
110+
echo "Skipping build - all changes are in documentation/config files: ${changedFiles}"
111+
return true
112+
}
113+
}
114+
115+
return false
116+
}
117+
68118
def cancel_previous_build() {
69119
// cancel previous build if it is not on main.
70120
if (env.BRANCH_NAME != 'main') {
@@ -243,6 +293,12 @@ def shard_run_unittest_GPU(node_type, shard_id, cuda_version) {
243293
}
244294

245295
stage('Unittest') {
296+
if (should_skip_build()) {
297+
echo "Skipping tests - only documentation/config files changed"
298+
Utils.markStageSkippedForConditional('Unittest')
299+
return
300+
}
301+
246302
cancel_previous_build()
247303
parallel(
248304
failFast: true,

0 commit comments

Comments
 (0)