From 517033916c61aa5f55745ce0563922292878c208 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Thu, 9 Sep 2021 12:20:43 -0700 Subject: [PATCH] .github: Remove add_annotations workflow (#64449) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/64449 Signed-off-by: Eli Uriegas Test Plan: Imported from OSS Reviewed By: suo, janeyx99 Differential Revision: D30738460 Pulled By: seemethere fbshipit-source-id: f1259fcba2f0c14a9bcfbe811ec0a4bf61106619 --- .github/workflows/add_annotations.yml | 73 ----------------------------------- .github/workflows/lint.yml | 32 ++++++++++----- 2 files changed, 22 insertions(+), 83 deletions(-) delete mode 100644 .github/workflows/add_annotations.yml diff --git a/.github/workflows/add_annotations.yml b/.github/workflows/add_annotations.yml deleted file mode 100644 index 76f7307..0000000 --- a/.github/workflows/add_annotations.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Add annotations - -on: - workflow_run: - types: - - completed - workflows: - - Lint - - -concurrency: - group: add-annotations-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }} - cancel-in-progress: true - - -jobs: - annotate: - if: ${{ github.repository_owner == 'pytorch' }} - strategy: - fail-fast: false - matrix: - name: - - flake8-py3 - - clang-tidy - runs-on: ubuntu-18.04 - steps: - - name: Download artifact - uses: actions/github-script@v3 - env: - RUN_ID: ${{ github.event.workflow_run.id }} - LINT_NAME: ${{ matrix.name }} - with: - # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ - script: | - const artifacts = await github.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: process.env.RUN_ID, - }); - const filteredArtifacts = artifacts.data.artifacts.filter(artifact => { - return artifact.name == process.env.LINT_NAME; - }); - if (filteredArtifacts.length > 0) { - const matchArtifact = filteredArtifacts[0]; - const download = await github.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - const fs = require('fs'); - fs.writeFileSync( - `${process.env.GITHUB_WORKSPACE}/linter-output.zip`, - Buffer.from(download.data), - ); - } - - name: Unzip artifact - id: unzip - run: | - if unzip linter-output.zip annotations.json commit-sha.txt; then - echo ::set-output \ - name=sha::"$(grep -Em1 '^[[:xdigit:]]{40}$' commit-sha.txt)" - fi - - if: ${{ steps.unzip.outputs.sha }} - name: Add annotations - uses: pytorch/add-annotations-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - check_name: ${{ matrix.name }} - linter_output_path: annotations.json - commit_sha: ${{ steps.unzip.outputs.sha }} - mode: json diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7b725e5..f33eda2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -316,11 +316,6 @@ jobs: --regex='^(?P.*?):(?P\d+):(?P\d+): (?P\w+\d+) (?P.*)' \ --commit="$HEAD_SHA" \ > flake8-output/annotations.json - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: flake8-py3 - path: flake8-output/ - name: Fail if there were any warnings run: | set -eu @@ -330,6 +325,17 @@ jobs: echo 'Please fix the above Flake8 warnings.' false fi + - name: Add annotations + # Don't run on forked pull requests + if: ${{ failure() && github.event.pull_request.head.repo.full_name == github.repository }} + uses: pytorch/add-annotations-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + check_name: 'flake8-py3' + linter_output_path: flake8-output/annotations.json + commit_sha: ${{ github.event.pull_request.head.sha }} + mode: json clang-tidy: runs-on: linux.2xlarge @@ -400,11 +406,6 @@ jobs: --regex='^(?P.*?):(?P\d+):(?P\d+): (?P.*?) \[(?P.*)\]' \ --commit="$HEAD_SHA" \ > clang-tidy-output/annotations.json - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: clang-tidy - path: clang-tidy-output/ - name: Check for warnings run: | cd "${GITHUB_WORKSPACE}" @@ -414,6 +415,17 @@ jobs: echo 'Please fix the above clang-tidy warnings.' false fi + - name: Add annotations + # Don't run on forked pull requests + if: ${{ failure() && github.event.pull_request.head.repo.full_name == github.repository }} + uses: pytorch/add-annotations-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + check_name: 'clang-tidy' + linter_output_path: clang-tidy/annotations.json + commit_sha: ${{ github.event.pull_request.head.sha }} + mode: json cmakelint: runs-on: ubuntu-18.04 -- 2.7.4