pytorch/.github/workflows/build_linux_libtorch.yml
Rong Rong (AI Infra) 5bd49c3396 fix workflow id usage in GHA (#60376)
Summary:
This fixes: https://github.com/pytorch/pytorch/issues/60139

GHA workflow ID is set to `run_id` previously and it doesn't change across re-runs
see: https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables

Using GITHUB_RUN_NUMBER to report workflow ID instead.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/60376

Test Plan:
CI
see: [with rerun](https://github.com/pytorch/pytorch/actions/runs/952508536) and [without rerun](https://github.com/pytorch/pytorch/actions/runs/955665324 ) example --> they reported everything under the same run ID but in fact the first one ran twice as many test cases reported in scuba. This shouldn't occur after this PR.

Reviewed By: samestep

Differential Revision: D29267455

Pulled By: walterddr

fbshipit-source-id: 00fc6b75b84861e2f7d3e21698a5f840c3c21dcd
2021-06-21 14:54:49 -07:00

112 lines
4.4 KiB
YAML

name: Build Linux libtorch
on:
# TODO: These are only runnable from workflow_dispatch, we need to eventually add
# a cron
# TODO: Add an on_release trigger to build on tags
workflow_dispatch:
jobs:
generate-build-matrix:
if: ${{ github.repository_owner == 'pytorch' }}
runs-on: ubuntu-18.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
container:
image: python:3.9
steps:
- name: Clone pytorch/pytorch
uses: actions/checkout@v2
- name: Generating build matrix
id: set-matrix
run: |
# outputting for debugging purposes
MATRIX=$(python .github/scripts/generate_binary_build_matrix.py libtorch)
echo "${MATRIX}"
echo "::set-output name=matrix::${MATRIX}"
build-libtorch:
if: ${{ github.repository_owner == 'pytorch' }}
needs: generate-build-matrix
runs-on: linux.2xlarge
strategy:
matrix: ${{ fromJson(needs.generate-build-matrix.outputs.matrix) }}
fail-fast: false
container:
image: ${{ matrix.container_image }}
env:
# TODO: remove this var from the libtorch builder script(s)
DESIRED_PYTHON: '3.7'
# TODO: This is a legacy variable that we eventually want to get rid of in
# favor of GPU_ARCH_VERSION
DESIRED_CUDA: ${{ matrix.gpu_arch_version }}
GPU_ARCH_VERSION: ${{ matrix.GPU_ARCH_VERSION }}
GPU_ARCH_TYPE: ${{ matrix.gpu_arch_type }}
BUILD_PYTHONLESS: 1
LIBTORCH_VARIANT: ${{ matrix.libtorch_variant }}
# TODO: remove this and bake env var into the Docker image
DESIRED_DEVTOOLSET: ${{ matrix.devtoolset }}
PYTORCH_BUILD_NUMBER: 1
SKIP_ALL_TESTS: 1
steps:
- name: Clean runner workspace
run: rm -rf "$GITHUB_WORKSPACE"
- name: Clone pytorch/pytorch
uses: actions/checkout@v2
with:
path: pytorch
submodules: recursive
- name: Clone pytorch/builder
uses: actions/checkout@v2
with:
repository: pytorch/builder
path: builder
- name: Generate version string
working-directory: pytorch/
run: |
version=$(.github/scripts/generate_pytorch_version.py)
echo "Generated version: ${version}"
echo "PYTORCH_BUILD_VERSION=${version}" >> "$GITHUB_ENV"
- name: Set BUILD_SPLIT_CUDA
if: ${{ matrix.gpu_arch_type == 'cuda' && matrix.gpu_arch_version == '11.1' }}
run: |
echo "BUILD_SPLIT_CUDA=1" >> "$GITHUB_ENV"
# TODO: Remove this once we remove the need for the directories to be
# in specific locations
- name: Symlink repositories to root directory (for legacy scripts purposes)
run: |
ln -s "$PWD"/pytorch /pytorch
ln -s "$PWD"/builder /builder
# TODO: Bundle the correct build script in the base container image so
# that we don't have to do this type of specification
- name: Build PyTorch binary (CUDA specific)
if: ${{ matrix.gpu_arch_type == 'cuda' }}
run: |
/builder/manywheel/build.sh
- name: Build PyTorch binary (CPU specific)
if: ${{ matrix.gpu_arch_type == 'cpu' }}
run: |
/builder/manywheel/build_cpu.sh
- uses: actions/upload-artifact@v2
with:
name: pytorch-libtorch-${{ matrix.libtorch_variant }}-${{ matrix.devtoolset }}-${{matrix.gpu_arch_type}}-${{ matrix.gpu_arch_version }}
path: /remote/**/*.zip
- name: Display and upload binary build size statistics (Click Me)
# temporary hack: set CIRCLE_* vars, until we update
# tools/print_test_stats.py to natively support GitHub Actions
env:
SCRIBE_GRAPHQL_ACCESS_TOKEN: ${{ secrets.SCRIBE_GRAPHQL_ACCESS_TOKEN }}
CIRCLE_BRANCH: ${{ steps.parse-ref.outputs.branch }}
CIRCLE_PR_NUMBER: ${{ github.event.pull_request.number }}
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
run: |
export PYTHONPATH=$PWD
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
pip3 install requests
python3 .circleci/scripts/upload_binary_size_to_scuba.py || exit 0
concurrency:
group: build-linux-libtorch-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true