@@ -2,19 +2,9 @@ name: Tests
2
2
3
3
on :
4
4
push :
5
- branches : [main, develop]
6
- paths-ignore :
7
- - " website/**"
8
- - " docs/**"
9
- - " *.md"
10
- - " .gitignore"
5
+ branches : [main, develop, findhao/setup_ci, findhao/add_linter]
11
6
pull_request :
12
7
branches : [main]
13
- paths-ignore :
14
- - " website/**"
15
- - " docs/**"
16
- - " *.md"
17
- - " .gitignore"
18
8
workflow_dispatch :
19
9
inputs :
20
10
test-type :
33
23
type : boolean
34
24
35
25
jobs :
36
- test :
37
- runs-on : 4-core- ubuntu-gpu-t4
38
- timeout-minutes : 120
26
+ format-check :
27
+ runs-on : ubuntu-latest
28
+ timeout-minutes : 10
39
29
steps :
40
30
- uses : actions/checkout@v4
41
31
@@ -44,77 +34,37 @@ jobs:
44
34
with :
45
35
python-version : " 3.11"
46
36
47
- - name : Get daily cache timestamp
48
- id : daily-cache
49
- run : |
50
- # Calculate date (e.g., 2024-01-15) for daily cache expiration
51
- DATE_STAMP=$(date +"%Y-%m-%d")
52
- echo "date=$DATE_STAMP" >> $GITHUB_OUTPUT
53
- echo "Using daily cache stamp: $DATE_STAMP"
54
-
55
- - name : Get weekly cache timestamp
56
- id : weekly-cache
57
- run : |
58
- # Calculate year-week (e.g., 2024-03) for weekly cache expiration
59
- WEEK_STAMP=$(date +"%Y-%U")
60
- echo "week=$WEEK_STAMP" >> $GITHUB_OUTPUT
61
- echo "Using weekly cache stamp: $WEEK_STAMP"
62
-
63
37
- name : Cache pip dependencies
64
38
uses : actions/cache@v3
65
39
with :
66
40
path : ~/.cache/pip
67
- key : ${{ runner.os }}-pip-3.11 -${{ steps.daily-cache.outputs.date }}
41
+ key : ${{ runner.os }}-pip-format -${{ hashFiles('**/pyproject.toml') }}
68
42
restore-keys : |
69
- ${{ runner.os }}-pip-3.11 -
43
+ ${{ runner.os }}-pip-format -
70
44
71
- - name : Cache APT packages
72
- uses : actions/cache@v3
73
- with :
74
- path : |
75
- /var/cache/apt/archives
76
- /var/lib/apt/lists
77
- key : ${{ runner.os }}-apt-${{ hashFiles('.ci/setup.sh') }}-${{ steps.weekly-cache.outputs.week }}
78
- restore-keys : |
79
- ${{ runner.os }}-apt-${{ hashFiles('.ci/setup.sh') }}-
80
- ${{ runner.os }}-apt-
45
+ - name : Install development dependencies
46
+ run : |
47
+ make install-dev
81
48
82
- - name : Get Triton latest commit
83
- id : triton-commit
49
+ - name : Check code formatting
84
50
run : |
85
- # Check if jq is available
86
- if ! command -v jq &> /dev/null; then
87
- echo "jq not found, installing..."
88
- sudo apt-get update && sudo apt-get install -y jq
89
- fi
51
+ make format-check
90
52
91
- # Get commit with error handling
92
- echo "Fetching latest Triton commit..."
93
- COMMIT=$(curl -s --max-time 30 --retry 3 https://api.github.com/repos/triton-lang/triton/commits/main | jq -r .sha 2>/dev/null || echo "" )
53
+ - name : Check linting
54
+ run : |
55
+ make lint-check || (echo "❌ Linting failed. Please run 'make format' to fix formatting issues, then commit the changes." && exit 1 )
94
56
95
- if [ -n "$COMMIT" ] && [ "$COMMIT" != "null" ]; then
96
- echo "commit=$COMMIT" >> $GITHUB_OUTPUT
97
- echo "cache-key=$COMMIT" >> $GITHUB_OUTPUT
98
- echo "✅ Using Triton commit: $COMMIT"
99
- else
100
- echo "❌ Failed to get Triton commit, using 'main' as fallback"
101
- # Force cache miss by using timestamp when API fails
102
- TIMESTAMP=$(date +%Y%m%d%H%M%S)
103
- echo "commit=main" >> $GITHUB_OUTPUT
104
- echo "cache-key=main-fallback-$TIMESTAMP" >> $GITHUB_OUTPUT
105
- echo "⚠️ Using fallback cache key: main-fallback-$TIMESTAMP"
106
- fi
57
+ test :
58
+ runs-on : 4-core-ubuntu-gpu-t4
59
+ timeout-minutes : 120
60
+ needs : format-check
61
+ steps :
62
+ - uses : actions/checkout@v4
107
63
108
- - name : Cache Triton source and build
109
- uses : actions/cache@v3
64
+ - name : Set up Python 3.11
65
+ uses : actions/setup-python@v4
110
66
with :
111
- path : |
112
- /tmp/triton
113
- /tmp/triton-cache
114
- key : ${{ runner.os }}-triton-source-${{ hashFiles('.ci/install-triton.sh') }}-${{ steps.triton-commit.outputs.cache-key }}
115
- restore-keys : |
116
- ${{ runner.os }}-triton-source-${{ hashFiles('.ci/install-triton.sh') }}-
117
- ${{ runner.os }}-triton-source-
67
+ python-version : " 3.11"
118
68
119
69
- name : Setup environment
120
70
env :
127
77
- name : Install Triton from source
128
78
env :
129
79
CONDA_ENV : tritonparse
130
- TRITON_COMMIT : ${{ steps.triton-commit.outputs.commit }}
131
80
run : |
132
81
bash .ci/install-triton.sh
133
82
@@ -137,6 +86,14 @@ jobs:
137
86
run : |
138
87
bash .ci/install-project.sh
139
88
89
+ - name : Cache pip dependencies
90
+ uses : actions/cache@v3
91
+ with :
92
+ path : ~/.cache/pip
93
+ key : ${{ runner.os }}-pip-3.11-${{ hashFiles('**/pyproject.toml') }}
94
+ restore-keys : |
95
+ ${{ runner.os }}-pip-3.11-
96
+
140
97
- name : Run tests
141
98
env :
142
99
CONDA_ENV : tritonparse
0 commit comments