Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/actions/clean-cache-if-labeled/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright 2025- FlagOS Contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: 'Clear Cache if Labeled'
description: 'Check if PR has specific backend ClearCache label and clear cache if present'

inputs:
github-token:
description: 'GitHub token for API access'
required: true
backend:
description: 'The backend name to check for (e.g., mthreads)'
required: true

runs:
using: 'composite'
steps:
- name: Check specific ClearCache label
id: check
uses: actions/github-script@v6
with:
github-token: ${{ inputs.github-token }}
script: |
const backend = '${{ inputs.backend }}';
const expectedLabel = `ClearCache:${backend}`;

if (context.eventName !== 'pull_request' && context.eventName !== 'pull_request_target') {
console.log('ℹ️ Not a PR event, skipping label check');
core.setOutput('has_clear_cache_label', 'false');
return;
}

if (!context.payload || !context.payload.pull_request) {
console.log('⚠️ No pull_request payload found, skipping label check');
core.setOutput('has_clear_cache_label', 'false');
return;
}

const prNumber = context.payload.pull_request.number;
try {
const { data: prData } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});

const labels = (prData.labels || []).map(label => label.name);
console.log(`Current PR labels:`, labels.join(', ') || '(no labels)');

const hasClearCache = labels.includes(expectedLabel);
console.log(`🔍 Has "${expectedLabel}" label:`, hasClearCache ? '✅ YES' : '❌ NO');

core.setOutput('has_clear_cache_label', hasClearCache ? 'true' : 'false');
} catch (err) {
console.log('❌ Error checking PR labels:', err.message || err);
core.setOutput('has_clear_cache_label', 'false');
}

- name: Clear cache if label present
id: cleanup
if: steps.check.outputs.has_clear_cache_label == 'true'
shell: bash
run: |
echo "========================================="
echo "🧹 Clearing cache for ${{ inputs.backend }} backend."
echo "========================================="

echo "-> Clearing cache..."
echo "-> Remove ~/.triton/cache"
rm -rf ~/.triton/cache || true
echo "-> Remove ~/.flaggems"
rm -rf ~/.flaggems || true
echo "-> Clear cache done"
11 changes: 11 additions & 0 deletions .github/workflows/mthreads3.6-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ on:
pull_request:
branches: [ "main", "triton_v3.6.x" ]

permissions:
contents: read
pull-requests: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -60,6 +64,13 @@ jobs:
export FLAGTREE_BACKEND=mthreads
MAX_JOBS=32 python3 -m pip install . --no-build-isolation

- name: Clean cache if CleanCache label present
id: clean_cache
uses: ./.github/actions/clean-cache-if-labeled
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
backend: 'mthreads'

- name: Unit Test
if: steps.check_backend.outputs.should_skip != 'true'
shell: bash
Expand Down
Loading