findutils 0.8.0

Rust implementation of GNU findutils
Documentation
on:
  workflow_run:
    workflows: [External-testsuites]
    types: [completed]

name: Comment Test results on the PR

permissions: {}
jobs:
  upload-pr-comment:
    if: ${{ github.event.workflow_run.event == 'pull_request' }}
    
    name: Upload PR comment
    runs-on: ubuntu-latest
    permissions:
      actions: read
      pull-requests: write

    steps:
      - name: List Annotations
        uses: actions/github-script@v7
        with:
          script: |
            let artifacts = await github.rest.actions.listWorkflowRunArtifacts({
              owner: context.repo.owner,
              repo: context.repo.repo,
              run_id: ${{ github.event.workflow_run.id }},
            });

            // List all artifacts
            let matchArtifact = artifacts.data.artifacts.filter((artifact) => {
              return artifact.name == "comment"
            })[0];

            // Download the artifact to github.workspace
            let download = await github.rest.actions.downloadArtifact({
              owner: context.repo.owner,
              repo: context.repo.repo,
              artifact_id: matchArtifact.id,
              archive_format: 'zip',
            });

            let fs = require('fs');
            fs.writeFileSync('${{ github.workspace }}/comment.zip', Buffer.from(download.data));

      - run: unzip comment.zip

      - name: Comment on PR
        uses: actions/github-script@v7
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            let fs = require('fs');
            let annotations = JSON.parse(fs.readFileSync('./annotations.json', 'utf8'));

            let annotationContent = annotations
              .data
              .map(annotation => `${annotation.run}: ${annotation.annotation.message}`)
              .join('\n');

            // check if no changes
            let gnuTestReport = annotationContent.includes('Run GNU findutils tests: Gnu tests No changes');
            let bfsTestReport = annotationContent.includes('Run BFS tests: BFS tests No changes');

            if (gnuTestReport && bfsTestReport) {
              console.log('No changes');
              return;
            }

            // Comment on the PR
            github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: annotations.pull_request_number,
              body: 'Commit ${{ github.event.workflow_run.head_sha }} has GNU testsuite comparison:\n```\n' + annotationContent + '\n```\n'
            });