Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Skip build and test for doc updates #2122

Draft
wants to merge 60 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d5c34c7
test
jmcgrathTT Feb 6, 2025
d272c0d
test
jmcgrathTT Feb 6, 2025
8cecf4f
test
jmcgrathTT Feb 6, 2025
7a9233a
test
jmcgrathTT Feb 6, 2025
7a7e40c
test
jmcgrathTT Feb 6, 2025
3187c37
test
jmcgrathTT Feb 6, 2025
457fae8
test
jmcgrathTT Feb 6, 2025
71f4bca
test
jmcgrathTT Feb 6, 2025
e16b7f0
test
jmcgrathTT Feb 6, 2025
90a8bd7
test
jmcgrathTT Feb 6, 2025
5f28df8
test
jmcgrathTT Feb 6, 2025
45946fe
test
jmcgrathTT Feb 6, 2025
7db1a21
test
jmcgrathTT Feb 6, 2025
41a80d4
test
jmcgrathTT Feb 6, 2025
3045b68
test
jmcgrathTT Feb 6, 2025
286e988
test
jmcgrathTT Feb 6, 2025
8cac90a
test
jmcgrathTT Feb 6, 2025
a9a6f3f
test
jmcgrathTT Feb 6, 2025
baf3836
test
jmcgrathTT Feb 6, 2025
740f679
test
jmcgrathTT Feb 6, 2025
4d9dde8
test
jmcgrathTT Feb 6, 2025
cdce5f2
test
jmcgrathTT Feb 6, 2025
0c0f901
test
jmcgrathTT Feb 6, 2025
5116afe
test
jmcgrathTT Feb 6, 2025
22c3684
test
jmcgrathTT Feb 6, 2025
62af1ea
test
jmcgrathTT Feb 6, 2025
eccb5ab
test
jmcgrathTT Feb 6, 2025
d4c1ccc
test
jmcgrathTT Feb 6, 2025
0d120dd
test
jmcgrathTT Feb 7, 2025
e5a605b
test
jmcgrathTT Feb 7, 2025
33824cc
test
jmcgrathTT Feb 7, 2025
ccca12b
test
jmcgrathTT Feb 7, 2025
0b3d371
test
jmcgrathTT Feb 7, 2025
2546041
test
jmcgrathTT Feb 7, 2025
1427457
test
jmcgrathTT Feb 7, 2025
b595e5c
test
jmcgrathTT Feb 7, 2025
08000bc
test
jmcgrathTT Feb 7, 2025
001ed9d
test
jmcgrathTT Feb 7, 2025
150356b
test
jmcgrathTT Feb 7, 2025
ceb3128
test
jmcgrathTT Feb 7, 2025
a4d7c86
test
jmcgrathTT Feb 7, 2025
5e5d5c4
test
jmcgrathTT Feb 7, 2025
1d9a2b4
test
jmcgrathTT Feb 7, 2025
09f97a0
test
jmcgrathTT Feb 7, 2025
951f971
test
jmcgrathTT Feb 7, 2025
44f25d7
test
jmcgrathTT Feb 7, 2025
2b63705
test
jmcgrathTT Feb 7, 2025
ce54af9
test
jmcgrathTT Feb 7, 2025
c2d8872
test
jmcgrathTT Feb 7, 2025
54a7c0e
test
jmcgrathTT Feb 7, 2025
5bed99c
test
jmcgrathTT Feb 7, 2025
aba4fb8
test
jmcgrathTT Feb 7, 2025
5fe90bf
test
jmcgrathTT Feb 7, 2025
6d19fcc
test
jmcgrathTT Feb 7, 2025
52d8b22
test
jmcgrathTT Feb 7, 2025
fd983d9
test
jmcgrathTT Feb 7, 2025
ee7b662
test
jmcgrathTT Feb 7, 2025
4b2d19e
test
jmcgrathTT Feb 7, 2025
305afdf
test
jmcgrathTT Feb 7, 2025
3815082
test
jmcgrathTT Feb 7, 2025
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
9 changes: 9 additions & 0 deletions .github/scripts/pr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[{
"job_name": "test",
"skip": {
"draft_pr": "true",
"files_regex": [
"docs/.*"
]
}
}]
81 changes: 81 additions & 0 deletions .github/scripts/pr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0

import os
import json
import re
from pathlib import Path

os.environ["pull_request"] = '{"draft": "false"}'
os.environ["changed_files"] = '{ "all_changed_and_modified_files": ".github/scripts/pr.py docs/src/build.md" }'
os.environ["job_name"] = 'pr-check'


#os.environ["pull_request"] = '{"draft": "true"}'
#os.environ["changed_files"] = '{ "all_changed_and_modified_files": ".github/scripts/pr.py docs/src/build.md" }'
#
#os.environ["pull_request"] = '{"draft": "false"}'
#os.environ["changed_files"] = '{ "all_changed_and_modified_files": "docs/src/build.md" }'

pull_request: dict = json.loads(os.environ.get('pull_request', '{}'))
changed_files: dict = json.loads(os.environ.get('changed_files', '{}'))

def to_github_output(outputs: dict):
parent_job_name = os.environ['job_name']
print_builder = 'Here are your available outputs:\n'
for x, z in outputs.items():
print_builder += f'---- job: {x} ----\n'
for y, t in z.items():
print_builder += f'action: {y}\n'
print_builder += f'conditional: fromJson(needs.{parent_job_name}.outputs.results).{x}.{y}\n'
print_builder += f'value: {t}\n\n'

print(print_builder)
# TODO: add test flag
github_output = os.environ['GITHUB_OUTPUT']
payload =json.dumps(outputs)
with open(github_output, "a") as myfile:
myfile.write(f"results={payload}")



def files_regex(action: str, manifest: dict) -> dict:
if not manifest:
return False
# Avaible actions
# https://github.com/tj-actions/changed-files?tab=readme-ov-file#outputs-
changed_files_list: list = changed_files.get(action).split(' ')
changed_files_regex = re.compile('|'.join(manifest))
return all([changed_files_regex.match(x) for x in changed_files_list])

def draft_pr(manifest: str):
is_draft = pull_request.get("draft")
if manifest == 'true' and is_draft == 'true':
return True
return False

def skip(manifest: dict) -> bool:
skip_manifest = manifest.get('skip')
if not skip_manifest:
return "false"
if draft_pr(skip_manifest.get('draft_pr')):
return "true"
if files_regex('all_changed_and_modified_files', skip_manifest.get('files_regex')):
return "true"
return "false"

def main():
json_config: Path = Path.joinpath(Path(__file__).resolve().parent, 'pr.json')
manifests: dict = json.loads(json_config.read_text())

outputs = {}

for manifest in manifests:
job_name = manifest['job_name']
outputs[job_name] = {}
outputs[job_name]['skip']= skip(manifest)
to_github_output(outputs)

main()
12 changes: 12 additions & 0 deletions .github/scripts/test_pr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import pytest
from typing import Dict
from pr import main
import os

#@pytest.fixture(scope="session", autouse=True)
def test_build_test_skip():
os.environ["pull_request"] = {"draft": "false"}
os.environ["changed_files"] = { "all_changed_and_modified_files": ".github/scripts/pr.py docs/src/build.md" }
main()

test_build_test_skip()
68 changes: 27 additions & 41 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,36 @@ concurrency:
cancel-in-progress: true

jobs:
pre-commit:
uses: ./.github/workflows/pre-commit.yml
secrets: inherit
spdx:
uses: ./.github/workflows/spdx.yml
secrets: inherit
build-and-test:
if: github.event.pull_request.draft == false
uses: ./.github/workflows/build-and-test.yml
secrets: inherit

# When a PR runs on the uplift branch trigger the downstream checks
downstream-checks:
pr-check:
runs-on: ubuntu-latest
needs: build-and-test
if: github.event.pull_request.head.ref == 'uplift'
strategy:
matrix:
target-repo: ['tenstorrent/tt-forge-fe', 'tenstorrent/tt-torch', 'tenstorrent/tt-xla']
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
TARGET_REPO: ${{ matrix.target-repo }}
WORKFLOW_NAME: 'on-pr.yml'
name: pr-check
outputs:
results: ${{ steps.script.outputs.results }}
steps:
- name: Trigger ${{ env.TARGET_REPO }} tests
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: tj-actions/changed-files@v45
id: changed-files
- name: check and conditional outputs
shell: bash
env:
changed_files: ${{ toJson(steps.changed-files.outputs) }}
pull_request: ${{ toJson(github.event.pull_request) }}
job_name: ${{ github.job }}
id: script
run: |
gh workflow run ${{ env.WORKFLOW_NAME }} \
--repo ${{ env.TARGET_REPO }} --ref main \
--field mlir_override=${{ github.event.pull_request.head.sha }}
gh run list --workflow=${{ env.WORKFLOW_NAME }} --repo ${{ env.TARGET_REPO }} --limit 1
echo "Triggered ${{ env.TARGET_REPO }} with tt-mlir ${{ github.event.pull_request.head.sha }}"
echo "### Triggered [${{ env.TARGET_REPO }}](https://github.com/${{ env.TARGET_REPO }}/actions/workflows/${{ env.WORKFLOW_NAME }}) with tt-mlir ${{ github.event.pull_request.head.sha }} :rocket:" >> $GITHUB_STEP_SUMMARY
python .github/scripts/pr.py

check-all-green:
if: always()
needs:
- pre-commit
- spdx
- build-and-test
runs-on: Ubuntu-latest
test:
runs-on: ubuntu-latest
needs:
- pr-check
name: Test
if: ${{ fromJson(needs.pr-check.outputs.results).test.skip == false }}
steps:
- name: Check if the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
allowed-skips: build-and-test
jobs: ${{ toJSON(needs) }}
- name: check
shell: bash
run: |
echo ${{ fromJson(needs.pr-check.outputs.results).test.skip }}

2 changes: 1 addition & 1 deletion docs/src/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ error: process exited with status -1 (attach failed (Not allowed to attach to pr
he attach permission will likely have logged an informative message about why it was denied.))
```

For preinstalled macOS binaries you must manually codesign with debug entitlements.
Tgr prnsted macOS binaries you st maualy n with bug entitlements.

Create file `debuggee-entitlement.xml`:
```xml
Expand Down