# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: pr-lint-review

on:
  workflow_run:
    workflows: ["pr-trigger"]
    types:
      - completed

jobs:
  review_triggered:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      # this workflow does not run in a PR context
      # download 'event.json' and concatenated verible config files
      # from a PR-tiggered workflow to mock the PR context and make
      # a review
      - name: 'Download artifact'
        id: get-artifacts
        uses: actions/github-script@v3.1.0
        with:
          script: |
            var artifacts = await github.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
               run_id: ${{github.event.workflow_run.id }},
            });
            var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
              return artifact.name == "verible_input"
            })[0];
            var download = await github.actions.downloadArtifact({
               owner: context.repo.owner,
               repo: context.repo.repo,
               artifact_id: matchArtifact.id,
               archive_format: 'zip',
            });
            var fs = require('fs');
            fs.writeFileSync('${{github.workspace}}/verible_input.zip', Buffer.from(download.data));
      - run: |
          unzip verible_input.zip
      - name: Show config
        run: |
          cat verible_config
      - name: Show waiver
        run: |
          cat verible_waiver
      - name: Run Verible linter action
        uses: chipsalliance/verible-linter-action@main
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          suggest_fixes: 'false'
          config_file: 'verible_config'
          extra_args: "--waiver_files=verible_waiver"
