<commit_before>name: CI

on:
  push:
    branches:
      - master
  pull_request:

env:
  HOMEBREW_DEVELOPER: 1
  HOMEBREW_GITHUB_ACTIONS: 1
  HOMEBREW_NO_AUTO_UPDATE: 1
  HOMEBREW_CHANGE_ARCH_TO_ARM: 1

concurrency:
  group: "tests-${{ github.ref }}"
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  tap_syntax:
    if: github.repository == 'Homebrew/homebrew-core'
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/homebrew/ubuntu16.04:master
    env:
      HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
    outputs:
      testing_formulae: ${{ steps.formulae-detect.outputs.testing_formulae }}
      added_formulae: ${{ steps.formulae-detect.outputs.added_formulae }}
      deleted_formulae: ${{ steps.formulae-detect.outputs.deleted_formulae }}
      long_pr_count: ${{ steps.count_long_timeout_prs.outputs.count }}
    steps:
      - name: Set up Homebrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master

      - run: brew test-bot --only-tap-syntax

      - run: brew test-bot --only-formulae-detect
        if: github.event_name == 'pull_request'
        id: formulae-detect

  setup_tests:
    if: github.event_name == 'pull_request' && github.repository == 'Homebrew/homebrew-core'
    runs-on: ubuntu-latest
    needs: tap_syntax
    outputs:
      syntax-only: ${{ steps.check-labels.outputs.syntax-only }}
      linux-runner: ${{ steps.check-labels.outputs.linux-runner }}
      fail-fast: ${{ steps.check-labels.outputs.fail-fast }}
      test-dependents: ${{ steps.check-labels.outputs.test-dependents }}
      timeout-minutes: ${{ steps.check-labels.outputs.timeout-minutes }}
      container: ${{ steps.check-labels.outputs.container }}
      test-bot-formulae-args: ${{ steps.check-labels.outputs.test-bot-formulae-args }}
      test-bot-dependents-args: ${{ steps.check-labels.outputs.test-bot-dependents-args }}
    steps:
      - name: Show GraphQL Query Response Headers
        if: ${{ github.event_name == 'pull_request' }}
        run: |
          QUERY='query{ repository(owner:\"Homebrew\", name:\"homebrew-core\") { pullRequests(last: 100, states: OPEN, labels: [\"CI-long-timeout\"]) { totalCount } } }'
          curl \
            --include \
            --header 'Content-Type: application/json' \
            --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
            --request POST \
            --data "{ \"query\": \"$QUERY\" }" \
            https://api.github.com/graphql

      - name: Check for CI labels
        id: check-labels
        uses: actions/github-script@v3
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            const { data: { labels: labels } } = await github.pulls.get({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: context.issue.number
            })
            const label_names = labels.map(label => label.name)

            if (label_names.includes('CI-syntax-only')) {
              console.log('CI-syntax-only label found. Skipping tests job.')
              core.setOutput('syntax-only', 'true')
            } else {
              console.log('No CI-syntax-only label found. Running tests job.')
              core.setOutput('syntax-only', 'false')
            }

            if (label_names.includes('CI-linux-self-hosted')) {
              core.setOutput('linux-runner', 'linux-self-hosted-1')
            } else {
              core.setOutput('linux-runner', 'ubuntu-latest')
            }

            if (label_names.includes('CI-no-fail-fast')) {
              console.log('CI-no-fail-fast label found. Continuing tests despite failing matrix builds.')
              core.setOutput('fail-fast', 'false')
            } else {
              console.log('No CI-no-fail-fast label found. Stopping tests on first failing matrix build.')
              core.setOutput('fail-fast', 'true')
            }

            if (label_names.includes('CI-skip-dependents')) {
              console.log('CI-skip-dependents label found. Skipping brew test-bot --only-formulae-dependents.')
              core.setOutput('test-dependents', 'false')
            } else {
              console.log('No CI-skip-dependents label found. Running brew test-bot --only-formulae-dependents.')
              core.setOutput('test-dependents', 'true')
            }

            if (label_names.includes('CI-long-timeout')) {
              const labelCountQuery = `query($owner:String!, $name:String!, $label:String!) {
                repository(owner:$owner, name:$name) {
                  pullRequests(last: 100, states: OPEN, labels: [$label]) {
                    totalCount
                  }
                }
              }`;
              var long_pr_count;
              try {
                const response = await github.graphql(
                  labelCountQuery, {
                    owner: context.repo.owner,
                    name: context.repo.repo,
                    label: 'CI-long-timeout'
                  }
                )
                long_pr_count = response.data.repository.pullRequests.totalCount
              } catch (error) {
                // The GitHub API query errored, so fail open and assume 0 long PRs.
                long_pr_count = 0
                core.warning('CI-long-timeout label count query failed. Assuming no long PRs.')
              }
              const maximum_long_pr_count = 2
              if (long_pr_count > maximum_long_pr_count) {<commit_msg>workflows/tests: fix GraphQL query errors (#93472)<commit_after>name: CI

on:
  push:
    branches:
      - master
  pull_request:

env:
  HOMEBREW_DEVELOPER: 1
  HOMEBREW_GITHUB_ACTIONS: 1
  HOMEBREW_NO_AUTO_UPDATE: 1
  HOMEBREW_CHANGE_ARCH_TO_ARM: 1

concurrency:
  group: "tests-${{ github.ref }}"
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  tap_syntax:
    if: github.repository == 'Homebrew/homebrew-core'
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/homebrew/ubuntu16.04:master
    env:
      HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
    outputs:
      testing_formulae: ${{ steps.formulae-detect.outputs.testing_formulae }}
      added_formulae: ${{ steps.formulae-detect.outputs.added_formulae }}
      deleted_formulae: ${{ steps.formulae-detect.outputs.deleted_formulae }}
    steps:
      - name: Set up Homebrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master

      - run: brew test-bot --only-tap-syntax

      - run: brew test-bot --only-formulae-detect
        if: github.event_name == 'pull_request'
        id: formulae-detect

  setup_tests:
    if: github.event_name == 'pull_request' && github.repository == 'Homebrew/homebrew-core'
    runs-on: ubuntu-latest
    needs: tap_syntax
    outputs:
      syntax-only: ${{ steps.check-labels.outputs.syntax-only }}
      linux-runner: ${{ steps.check-labels.outputs.linux-runner }}
      fail-fast: ${{ steps.check-labels.outputs.fail-fast }}
      test-dependents: ${{ steps.check-labels.outputs.test-dependents }}
      timeout-minutes: ${{ steps.check-labels.outputs.timeout-minutes }}
      container: ${{ steps.check-labels.outputs.container }}
      test-bot-formulae-args: ${{ steps.check-labels.outputs.test-bot-formulae-args }}
      test-bot-dependents-args: ${{ steps.check-labels.outputs.test-bot-dependents-args }}
    steps:
      - name: Check for CI labels
        id: check-labels
        uses: actions/github-script@v3
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            const { data: { labels: labels } } = await github.pulls.get({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: context.issue.number
            })
            const label_names = labels.map(label => label.name)

            if (label_names.includes('CI-syntax-only')) {
              console.log('CI-syntax-only label found. Skipping tests job.')
              core.setOutput('syntax-only', 'true')
            } else {
              console.log('No CI-syntax-only label found. Running tests job.')
              core.setOutput('syntax-only', 'false')
            }

            if (label_names.includes('CI-linux-self-hosted')) {
              core.setOutput('linux-runner', 'linux-self-hosted-1')
            } else {
              core.setOutput('linux-runner', 'ubuntu-latest')
            }

            if (label_names.includes('CI-no-fail-fast')) {
              console.log('CI-no-fail-fast label found. Continuing tests despite failing matrix builds.')
              core.setOutput('fail-fast', 'false')
            } else {
              console.log('No CI-no-fail-fast label found. Stopping tests on first failing matrix build.')
              core.setOutput('fail-fast', 'true')
            }

            if (label_names.includes('CI-skip-dependents')) {
              console.log('CI-skip-dependents label found. Skipping brew test-bot --only-formulae-dependents.')
              core.setOutput('test-dependents', 'false')
            } else {
              console.log('No CI-skip-dependents label found. Running brew test-bot --only-formulae-dependents.')
              core.setOutput('test-dependents', 'true')
            }

            if (label_names.includes('CI-long-timeout')) {
              const labelCountQuery = `query($owner:String!, $name:String!, $label:String!) {
                repository(owner:$owner, name:$name) {
                  pullRequests(last: 100, states: OPEN, labels: [$label]) {
                    totalCount
                  }
                }
              }`;
              var long_pr_count;
              try {
                const response = await github.graphql(
                  labelCountQuery, {
                    owner: context.repo.owner,
                    name: context.repo.repo,
                    label: 'CI-long-timeout'
                  }
                )
                long_pr_count = response.repository.pullRequests.totalCount
              } catch (error) {
                // The GitHub API query errored, so fail open and assume 0 long PRs.
                long_pr_count = 0
                core.warning('CI-long-timeout label count query failed. Assuming no long PRs.')
              }
              const maximum_long_pr_count = 2
              if (long_pr_count > maximum_long_pr_count) {
{'fraction_non_alphanumeric': 0.12501196515746146, 'fraction_numerical': 0.004020292907054657, 'mean_word_length': 1.9564233163554046, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4523750', 'n_tokens_mistral': 3217, 'n_tokens_neox': 3006, 'n_words': 566}