+++ /dev/null
-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
--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
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
--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}"
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