findutils 0.10.0

Rust implementation of GNU findutils
Documentation
on: [push, pull_request]

name: External-testsuites
env:
  CARGO_INCREMENTAL: "0"
  # Default branch, used to fetch the reference (baseline) test results.
  DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
jobs:
  gnu-tests:
    permissions:
      actions: read
      contents: write # Publish binaries instead of discarding

    name: Run GNU findutils tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout findutils
        uses: actions/checkout@v7
        with:
          path: findutils
      - name: Checkout GNU findutils
        uses: actions/checkout@v7
        with:
          repository: gnu-mirror-unofficial/findutils
          path: findutils.gnu
          ref: 5768a03ddfb5e18b1682e339d6cdd24ff721c510
          submodules: false

      - name: Override submodule URL and initialize submodules
        # Use github instead of upstream git server
        run: |
          git submodule sync --recursive
          git config submodule.gnulib.url https://github.com/coreutils/gnulib.git
          git submodule update --init --recursive --depth 1
        working-directory: findutils.gnu
      - name: Install dependencies
        shell: bash
        run: |
          # Enable sources & install dependencies
          sudo sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
          sudo apt-get update
          sudo apt-get build-dep findutils
      - name: Run GNU tests
        shell: bash
        run: |
          cd findutils
          bash util/build-gnu.sh ||:
          install --strip -Dm755 target/release/{find,locate,updatedb,xargs} -t findutils-x86_64-unknown-linux-gnu
          ZSTD_CLEVEL=19 tar --zstd -caf ../findutils-x86_64-unknown-linux-gnu.tar.zst findutils-x86_64-unknown-linux-gnu
      - name: Publish latest commit
        uses: softprops/action-gh-release@v3
        if: github.event_name == 'push' && github.ref == 'refs/heads/main'
        with:
          tag_name: latest-commit
          body: |
            commit: ${{ github.sha }}
          draft: false
          prerelease: true
          files: |
            findutils-x86_64-unknown-linux-gnu.tar.zst
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload gnu-test-report
        if: success() || failure()
        uses: actions/upload-artifact@v7
        with:
          name: gnu-test-report
          path: |
            findutils.gnu/find/testsuite/*.log
            findutils.gnu/xargs/testsuite/*.log
            findutils.gnu/tests/**/*.log
      # The per-test JSON summary doubles as the baseline: future runs on the
      # default branch download this artifact to diff against.
      - name: Upload gnu-full-result
        if: success() || failure()
        uses: actions/upload-artifact@v7
        with:
          name: gnu-full-result
          path: findutils-gnu-full-result.json
          if-no-files-found: warn

      - name: Retrieve reference results
        uses: dawidd6/action-download-artifact@v21
        continue-on-error: true
        with:
          workflow: compat.yml
          branch: ${{ env.DEFAULT_BRANCH }}
          workflow_conclusion: completed
          name: gnu-full-result
          path: reference-gnu
          if_no_artifact_found: warn

      - name: Compare against reference results
        shell: bash
        run: |
          mkdir -p comment
          echo "${{ github.event.number }}" > comment/NR
          REF="reference-gnu/findutils-gnu-full-result.json"
          CUR="findutils-gnu-full-result.json"
          : > comment/result-gnu.txt
          if test ! -f "${CUR}"; then
            echo "::error ::Missing current GNU results (${CUR}); failing early"
            exit 1
          fi
          if test -f "${REF}"; then
            python3 findutils/util/compare_test_results.py \
              --ignore-file findutils/.github/workflows/ignore-intermittent.txt \
              --output comment/result-gnu.txt \
              "${CUR}" "${REF}"
          else
            echo "::warning ::No GNU reference results available yet; skipping comparison."
          fi

      - name: Upload GNU comparison comment
        if: ${{ github.event_name == 'pull_request' && (success() || failure()) }}
        uses: actions/upload-artifact@v7
        with:
          name: comment-gnu
          path: comment/

  bfs-tests:
    name: Run BFS tests
    permissions:
      actions: read
      contents: read
    runs-on: ubuntu-latest
    steps:
      - name: Checkout findutils
        uses: actions/checkout@v7
        with:
          path: findutils
      - name: Checkout BFS
        uses: actions/checkout@v7
        with:
          repository: tavianator/bfs
          path: bfs
          ref: "4.0"
      - name: Install dependencies
        shell: bash
        run: |
          # Enable sources & install dependencies
          sudo sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
          sudo apt-get update
          sudo apt-get build-dep bfs
      - name: Run BFS tests
        shell: bash
        run: |
          cd findutils
          export CARGO_INCREMENTAL=0
          bash util/build-bfs.sh ||:
      - name: Upload bfs-test-report
        if: success() || failure()
        uses: actions/upload-artifact@v7
        with:
          name: bfs-test-report
          path: bfs/tests.log
      - name: Upload bfs-full-result
        if: success() || failure()
        uses: actions/upload-artifact@v7
        with:
          name: bfs-full-result
          path: bfs-full-result.json
          if-no-files-found: warn

      - name: Retrieve reference results
        uses: dawidd6/action-download-artifact@v21
        continue-on-error: true
        with:
          workflow: compat.yml
          branch: ${{ env.DEFAULT_BRANCH }}
          workflow_conclusion: completed
          name: bfs-full-result
          path: reference-bfs
          if_no_artifact_found: warn

      - name: Compare against reference results
        shell: bash
        run: |
          mkdir -p comment
          echo "${{ github.event.number }}" > comment/NR
          REF="reference-bfs/bfs-full-result.json"
          CUR="bfs-full-result.json"
          : > comment/result-bfs.txt
          if test ! -f "${CUR}"; then
            echo "::error ::Missing current bfs results (${CUR}); failing early"
            exit 1
          fi
          if test -f "${REF}"; then
            python3 findutils/util/compare_test_results.py \
              --ignore-file findutils/.github/workflows/ignore-intermittent.txt \
              --output comment/result-bfs.txt \
              "${CUR}" "${REF}"
          else
            echo "::warning ::No bfs reference results available yet; skipping comparison."
          fi

      - name: Upload BFS comparison comment
        if: ${{ github.event_name == 'pull_request' && (success() || failure()) }}
        uses: actions/upload-artifact@v7
        with:
          name: comment-bfs
          path: comment/