.github: Remove add_annotations workflow (#64449)
authorEli Uriegas <eliuriegas@fb.com>
Thu, 9 Sep 2021 19:20:43 +0000 (12:20 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 9 Sep 2021 19:22:12 +0000 (12:22 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64449

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
Test Plan: Imported from OSS

Reviewed By: suo, janeyx99

Differential Revision: D30738460

Pulled By: seemethere

fbshipit-source-id: f1259fcba2f0c14a9bcfbe811ec0a4bf61106619

.github/workflows/add_annotations.yml [deleted file]
.github/workflows/lint.yml

diff --git a/.github/workflows/add_annotations.yml b/.github/workflows/add_annotations.yml
deleted file mode 100644 (file)
index 76f7307..0000000
+++ /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
index 7b725e5..f33eda2 100644 (file)
@@ -316,11 +316,6 @@ jobs:
             --regex='^(?P<filename>.*?):(?P<lineNumber>\d+):(?P<columnNumber>\d+): (?P<errorCode>\w+\d+) (?P<errorDesc>.*)' \
             --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<filename>.*?):(?P<lineNumber>\d+):(?P<columnNumber>\d+): (?P<errorDesc>.*?) \[(?P<errorCode>.*)\]' \
             --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