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

Changes to workflows #1412

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/workflows/dashboard_perf_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- '--pre torch --index-url https://download.pytorch.org/whl/nightly/cu124'
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false

- name: Setup miniconda
uses: pytorch/test-infra/.github/actions/setup-miniconda@main
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/doc_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
steps:
- name: Check out repo
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
Expand Down Expand Up @@ -61,7 +63,9 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Download artifact
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -96,19 +100,29 @@ jobs:
name: Doc-Build
path: docs
- name: Add no-index tag
env:
REF_NAME: ${{ github.ref }}
run: |
REF_NAME=$(echo "${{ github.ref }}")
if ! [[ "$REF_NAME" =~ ^refs/(heads|tags)/[a-zA-Z0-9._-]+$ ]]; then
echo "Error: Invalid ref format"
exit 1
fi
echo "Ref name: ${REF_NAME}"
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
if [[ "$REF_NAME == 'refs/heads/main' ]]; then
find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
fi
- name: Move and commit changes
env:
GITHUB_REF: ${{ github.ref }}
run: |
if ! [[ "$REF_NAME" =~ ^refs/(heads|tags)/[a-zA-Z0-9._-]+$ ]]; then
echo "Error: Invalid ref format"
exit 1
fi
set -euo pipefail
# Get github.ref for the output doc folder. By default "main"
# If matches a tag like refs/tags/v1.12.0-rc3 or
# refs/tags/v1.12.0 convert to 1.12
GITHUB_REF=${{ github.ref }}

# Convert refs/tags/v1.12.0rc3 into 1.12.
# Adopted from https://github.com/pytorch/pytorch/blob/main/.github/workflows/_docs.yml#L150C11-L155C13
Expand Down
51 changes: 36 additions & 15 deletions .github/workflows/ruff_linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,67 @@ jobs:
permissions:
contents: write
pull-requests: write

strategy:
matrix:
python-version: ["3.9"]
steps:
- name: Extract PR info
if: github.event_name == 'workflow_dispatch'
env:
INPUT_PR_URL: ${{ github.event.inputs.pr_url }}
run: |
PR_URL=${{ github.event.inputs.pr_url }}
PR_NUMBER=$(echo $PR_URL | grep -oE '[0-9]+$')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV

- uses: actions/checkout@v3
if ! [[ "$INPUT_PR_URL" =~ ^https://github\.com/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+/pull/[0-9]+$ ]]; then
echo "Error: Invalid PR URL format"
exit 1
fi

PR_NUMBER=${INPUT_PR_URL##*/}

if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid PR number format"
exit 1
fi

{
echo "PR_NUMBER=$PR_NUMBER"
} >> "$GITHUB_ENV"

- uses: actions/checkout@v4
if: github.event_name == 'workflow_dispatch'
with:
fetch-depth: 0
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout PR branch
if: github.event_name == 'workflow_dispatch'
run: |
gh pr checkout ${{ env.PR_NUMBER }}
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "Error: Invalid PR number format"
exit 1
fi
gh pr checkout "$PR_NUMBER"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v3
PR_NUMBER: ${{ env.PR_NUMBER }}

- uses: actions/checkout@v4
if: github.event_name != 'workflow_dispatch'
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff==0.6.8

- name: Regular lint check
if: github.event_name != 'workflow_dispatch'
run: |
Expand All @@ -77,11 +98,11 @@ jobs:
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

# Apply fixes
ruff check --select F,I --fix
ruff format .

# Commit and push if there are changes
if [[ -n "$(git status --porcelain)" ]]; then
git add .
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/trymerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ jobs:
steps:
- name: Checkout repo
id: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
token: ${{ secrets.PYTORCH_MERGEBOT_TOKEN }}

- name: Setup Python
Expand Down
Loading