diff --git a/.github/workflows/docs_preview.yaml b/.github/workflows/docs_preview.yaml new file mode 100644 index 000000000..8828fea7f --- /dev/null +++ b/.github/workflows/docs_preview.yaml @@ -0,0 +1,82 @@ +name: Docs preview + +# Uploads the docs that the Linux CUDA x86 workflow built for a PR to +# docs-preview.pytorch.org. The upload needs AWS credentials from GitHub OIDC, +# which a pull_request run from a fork can't get. A workflow_run job runs from +# main in this repo, so it can, for fork and same-repo PRs alike. +on: + workflow_run: + workflows: [Linux CUDA x86] + types: [completed] + +permissions: {} + +jobs: + doc-preview: + # workflow_run.event is the event that triggered the Linux CUDA x86 run. + if: github.repository == 'meta-pytorch/torchcodec' && github.event.workflow_run.event == 'pull_request' + runs-on: mt-l-x86iavx512-8-64 + container: + image: docker.io/python:3.11-slim + permissions: + actions: read + pull-requests: read + id-token: write + steps: + # The artifact comes from PR code, so we only upload it and never run it. + - name: Find the docs artifact and the PR + id: pr + uses: actions/github-script@v8 + with: + script: | + const run = context.payload.workflow_run; + // A failed or cancelled run may not have built the docs. + const { data: { total_count } } = await github.rest.actions.listWorkflowRunArtifacts({ + ...context.repo, + run_id: run.id, + name: 'Built-Docs', + }); + if (total_count === 0) { + core.notice(`Run ${run.id} has no Built-Docs artifact`); + return; + } + // workflow_run.pull_requests is empty for fork PRs, so look the PR up from its head. + const { data: pulls } = await github.rest.pulls.list({ + ...context.repo, + head: `${run.head_repository.owner.login}:${run.head_branch}`, + }); + const pr = pulls.find((p) => p.head.sha === run.head_sha); + if (!pr) throw new Error(`No PR has head ${run.head_sha}`); + core.setOutput('number', pr.number); + + # Uploaded by build-docs in linux_cuda_wheel.yaml. + - uses: actions/download-artifact@v4 + if: steps.pr.outputs.number + with: + name: Built-Docs + path: docs + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + # Update HTML to add the no-index tag so that search engines do not index these ephemeral docs + - name: Add no-index tag + if: steps.pr.outputs.number + run: | + find docs -name "*.html" -print0 | xargs -0 sed -i '/
/a \ \ '; + + - name: Configure AWS credentials + if: steps.pr.outputs.number + uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4 + with: + role-to-assume: arn:aws:iam::308535385114:role/arc + aws-region: us-east-1 + + - name: Upload docs preview + if: steps.pr.outputs.number + uses: seemethere/upload-artifact-s3@v5 + with: + retention-days: 14 + s3-bucket: doc-previews + if-no-files-found: error + path: docs + s3-prefix: meta-pytorch/torchcodec/${{ steps.pr.outputs.number }} diff --git a/.github/workflows/linux_cuda_wheel.yaml b/.github/workflows/linux_cuda_wheel.yaml index bc6677813..cb6088d2c 100644 --- a/.github/workflows/linux_cuda_wheel.yaml +++ b/.github/workflows/linux_cuda_wheel.yaml @@ -36,6 +36,7 @@ jobs: os: linux test-infra-repository: pytorch/test-infra test-infra-ref: main + runner-fleet: osdc with-cpu: disable with-xpu: disable with-rocm: disable @@ -68,7 +69,7 @@ jobs: build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 ENABLE_CUDA=1 python -m build --wheel -vvv --no-isolation" install-and-test: - runs-on: linux.g5.4xlarge.nvidia.gpu + runs-on: mt-l-x86aavx2-11-41-a10g strategy: fail-fast: false matrix: @@ -324,7 +325,7 @@ jobs: FAIL_WITHOUT_IMAGE_CODECS=1 python packaging/assert_gil_disabled.py --override-ini="addopts=-v" --tb=short build-docs: - runs-on: linux.g5.4xlarge.nvidia.gpu + runs-on: mt-l-x86aavx2-11-41-a10g env: PYTHON_VERSION: '3.11' CUDA_VERSION: '13.2' @@ -389,30 +390,6 @@ jobs: name: Built-Docs path: docs/build/html/ - doc-preview: - runs-on: [self-hosted, linux.2xlarge] - needs: build-docs - if: github.repository == 'meta-pytorch/torchcodec' && github.event_name == 'pull_request' - steps: - - uses: actions/download-artifact@v4 - with: - name: Built-Docs - path: docs - - # Update HTML to add the no-index tag so that search engines do not index these ephemeral docs - - name: Add no-index tag - run: | - find docs -name "*.html" -print0 | xargs -0 sed -i '//a \ \ '; - - - name: Upload docs preview - uses: seemethere/upload-artifact-s3@v5 - with: - retention-days: 14 - s3-bucket: doc-previews - if-no-files-found: error - path: docs - s3-prefix: meta-pytorch/torchcodec/${{ github.event.pull_request.number }} - upload-docs: # This job uploads built docs: # - to the `main` folder of the gh-pages branch (https://meta-pytorch.org/torchcodec/main) on every commit to the `main` branch