diff --git a/.github/workflows/nightly-tests-macos-cpu.yml b/.github/workflows/nightly-tests-macos-cpu.yml index 6eedadb..4814460 100644 --- a/.github/workflows/nightly-tests-macos-cpu.yml +++ b/.github/workflows/nightly-tests-macos-cpu.yml @@ -27,7 +27,24 @@ on: - cron: "50 23 * * *" jobs: + enable_nightly_build: + runs-on: ubuntu-latest + outputs: + enabled: ${{ steps.set-enabled.outputs.enabled }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set enabled + id: set-enabled + run: | + enabled=$(python scripts/github_actions/run-nightly-build.py) + echo "enabled: $enabled" + echo "::set-output name=enabled::${enabled}" + generate_build_matrix: + needs: enable_nightly_build + if: needs.enable_nightly_build.outputs.enabled == 'true' # see https://github.com/pytorch/pytorch/pull/50633 runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/nightly-tests-ubuntu-conda-cpu.yml b/.github/workflows/nightly-tests-ubuntu-conda-cpu.yml index d5e7689..317901a 100644 --- a/.github/workflows/nightly-tests-ubuntu-conda-cpu.yml +++ b/.github/workflows/nightly-tests-ubuntu-conda-cpu.yml @@ -27,7 +27,24 @@ on: - cron: "50 23 * * *" jobs: + enable_nightly_build: + runs-on: ubuntu-latest + outputs: + enabled: ${{ steps.set-enabled.outputs.enabled }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set enabled + id: set-enabled + run: | + enabled=$(python scripts/github_actions/run-nightly-build.py) + echo "enabled: $enabled" + echo "::set-output name=enabled::${enabled}" + generate_build_matrix: + needs: enable_nightly_build + if: needs.enable_nightly_build.outputs.enabled == 'true' # see https://github.com/pytorch/pytorch/pull/50633 runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/nightly-tests-ubuntu-conda-cuda.yml b/.github/workflows/nightly-tests-ubuntu-conda-cuda.yml index eb5fda0..9ede567 100644 --- a/.github/workflows/nightly-tests-ubuntu-conda-cuda.yml +++ b/.github/workflows/nightly-tests-ubuntu-conda-cuda.yml @@ -27,7 +27,24 @@ on: - cron: "50 23 * * *" jobs: + enable_nightly_build: + runs-on: ubuntu-latest + outputs: + enabled: ${{ steps.set-enabled.outputs.enabled }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set enabled + id: set-enabled + run: | + enabled=$(python scripts/github_actions/run-nightly-build.py) + echo "enabled: $enabled" + echo "::set-output name=enabled::${enabled}" + generate_build_matrix: + needs: enable_nightly_build + if: needs.enable_nightly_build.outputs.enabled == 'true' # see https://github.com/pytorch/pytorch/pull/50633 runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/nightly-tests-ubuntu-pip-cpu.yml b/.github/workflows/nightly-tests-ubuntu-pip-cpu.yml index 5433e2e..e0284c0 100644 --- a/.github/workflows/nightly-tests-ubuntu-pip-cpu.yml +++ b/.github/workflows/nightly-tests-ubuntu-pip-cpu.yml @@ -27,7 +27,24 @@ on: - cron: "50 23 * * *" jobs: + enable_nightly_build: + runs-on: ubuntu-latest + outputs: + enabled: ${{ steps.set-enabled.outputs.enabled }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set enabled + id: set-enabled + run: | + enabled=$(python scripts/github_actions/run-nightly-build.py) + echo "enabled: $enabled" + echo "::set-output name=enabled::${enabled}" + generate_build_matrix: + needs: enable_nightly_build + if: needs.enable_nightly_build.outputs.enabled == 'true' # see https://github.com/pytorch/pytorch/pull/50633 runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/nightly-tests-ubuntu-pip-cuda.yml b/.github/workflows/nightly-tests-ubuntu-pip-cuda.yml index b39b9d6..be85563 100644 --- a/.github/workflows/nightly-tests-ubuntu-pip-cuda.yml +++ b/.github/workflows/nightly-tests-ubuntu-pip-cuda.yml @@ -27,7 +27,24 @@ on: - cron: "50 23 * * *" jobs: + enable_nightly_build: + runs-on: ubuntu-latest + outputs: + enabled: ${{ steps.set-enabled.outputs.enabled }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set enabled + id: set-enabled + run: | + enabled=$(python scripts/github_actions/run-nightly-build.py) + echo "enabled: $enabled" + echo "::set-output name=enabled::${enabled}" + generate_build_matrix: + needs: enable_nightly_build + if: needs.enable_nightly_build.outputs.enabled == 'true' # see https://github.com/pytorch/pytorch/pull/50633 runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/nightly-tests-windows-pip-cpu.yml b/.github/workflows/nightly-tests-windows-pip-cpu.yml index 815d62d..44cc23f 100644 --- a/.github/workflows/nightly-tests-windows-pip-cpu.yml +++ b/.github/workflows/nightly-tests-windows-pip-cpu.yml @@ -27,7 +27,24 @@ on: - cron: "50 23 * * *" jobs: + enable_nightly_build: + runs-on: ubuntu-latest + outputs: + enabled: ${{ steps.set-enabled.outputs.enabled }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set enabled + id: set-enabled + run: | + enabled=$(python scripts/github_actions/run-nightly-build.py) + echo "enabled: $enabled" + echo "::set-output name=enabled::${enabled}" + generate_build_matrix: + needs: enable_nightly_build + if: needs.enable_nightly_build.outputs.enabled == 'true' # see https://github.com/pytorch/pytorch/pull/50633 runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/nightly-tests-windows-pip-cuda.yml b/.github/workflows/nightly-tests-windows-pip-cuda.yml index 10ca353..29bb230 100644 --- a/.github/workflows/nightly-tests-windows-pip-cuda.yml +++ b/.github/workflows/nightly-tests-windows-pip-cuda.yml @@ -27,7 +27,24 @@ on: - cron: "50 23 * * *" jobs: + enable_nightly_build: + runs-on: ubuntu-latest + outputs: + enabled: ${{ steps.set-enabled.outputs.enabled }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set enabled + id: set-enabled + run: | + enabled=$(python scripts/github_actions/run-nightly-build.py) + echo "enabled: $enabled" + echo "::set-output name=enabled::${enabled}" + generate_build_matrix: + needs: enable_nightly_build + if: needs.enable_nightly_build.outputs.enabled == 'true' # see https://github.com/pytorch/pytorch/pull/50633 runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/run-tests-macos-cpu.yml b/.github/workflows/run-tests-macos-cpu.yml index 99a81e5..6707c7e 100644 --- a/.github/workflows/run-tests-macos-cpu.yml +++ b/.github/workflows/run-tests-macos-cpu.yml @@ -39,8 +39,8 @@ jobs: id: set-matrix run: | # outputting for debugging purposes - python scripts/github_actions/generate_build_matrix.py - MATRIX=$(python scripts/github_actions/generate_build_matrix.py) + python scripts/github_actions/generate_build_matrix.py --test-only-latest-torch + MATRIX=$(python scripts/github_actions/generate_build_matrix.py --test-only-latest-torch) echo "::set-output name=matrix::${MATRIX}" run_tests_macos_cpu: diff --git a/.github/workflows/run-tests-ubuntu-cpu.yml b/.github/workflows/run-tests-ubuntu-cpu.yml index 7c2e45f..4337cce 100644 --- a/.github/workflows/run-tests-ubuntu-cpu.yml +++ b/.github/workflows/run-tests-ubuntu-cpu.yml @@ -39,8 +39,8 @@ jobs: id: set-matrix run: | # outputting for debugging purposes - python scripts/github_actions/generate_build_matrix.py - MATRIX=$(python scripts/github_actions/generate_build_matrix.py) + python scripts/github_actions/generate_build_matrix.py --test-only-latest-torch + MATRIX=$(python scripts/github_actions/generate_build_matrix.py --test-only-latest-torch) echo "::set-output name=matrix::${MATRIX}" run_tests_ubuntu_cpu: diff --git a/.github/workflows/run-tests-windows-cpu.yml b/.github/workflows/run-tests-windows-cpu.yml index cf4f547..f735ac3 100644 --- a/.github/workflows/run-tests-windows-cpu.yml +++ b/.github/workflows/run-tests-windows-cpu.yml @@ -39,8 +39,8 @@ jobs: id: set-matrix run: | # outputting for debugging purposes - python scripts/github_actions/generate_build_matrix.py - MATRIX=$(python scripts/github_actions/generate_build_matrix.py) + python scripts/github_actions/generate_build_matrix.py --test-only-latest-torch + MATRIX=$(python scripts/github_actions/generate_build_matrix.py --test-only-latest-torch) echo "::set-output name=matrix::${MATRIX}" run_tests_windows_cpu: diff --git a/scripts/github_actions/run-nightly-build.py b/scripts/github_actions/run-nightly-build.py new file mode 100755 index 0000000..1e002fb --- /dev/null +++ b/scripts/github_actions/run-nightly-build.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# Copyright 2022 Xiaomi Corp. (authors: Fangjun Kuang) + +import subprocess +from datetime import datetime, timedelta + + +def get_last_commit_date() -> datetime: + date = ( + subprocess.check_output( + [ + "git", + "log", + "-1", + "--format=%ad", + "--date=unix", + ] + ) + .decode("ascii") + .strip() + ) + return datetime.utcfromtimestamp(int(date)) + + +def main(): + last_commit_date_utc = get_last_commit_date() + now_utc = datetime.utcnow() + if last_commit_date_utc + timedelta(days=1) > now_utc: + print("true") + else: + print("false") + + +if __name__ == "__main__": + main()