Repo sync #771
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Index general search in Elasticsearch on PR | |
| # Test general search indexing against local Elasticsearch and validate popular pages JSON | |
| # before merge. | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| paths: | |
| - 'src/search/**' | |
| - 'package*.json' | |
| # Debugging changes to this workflow need the same PR index test. | |
| - .github/workflows/index-general-search-pr.yml | |
| # Setup changes can break the local Elasticsearch path this workflow tests. | |
| - .github/actions/setup-elasticsearch/action.yml | |
| permissions: | |
| contents: read | |
| # Cancel older runs for the same ref to save runner time. | |
| concurrency: | |
| group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
| cancel-in-progress: true | |
| env: | |
| ELASTICSEARCH_URL: http://localhost:9200 | |
| # Empty Hydro credentials keep production-mode test runs from sending analytics. | |
| HYDRO_ENDPOINT: '' | |
| HYDRO_SECRET: '' | |
| jobs: | |
| dryRunElasticsearchIndexes: | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'github/docs-internal' | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Clone docs-internal-data | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| repository: github/docs-internal-data | |
| # docs-bot can read the private github/docs-internal-data repository. | |
| token: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| path: docs-internal-data | |
| - uses: ./.github/actions/setup-elasticsearch | |
| - uses: ./.github/actions/node-npm-setup | |
| - uses: ./.github/actions/cache-nextjs | |
| - name: Build | |
| run: npm run build | |
| - name: Start the server in the background | |
| env: | |
| ENABLE_DEV_LOGGING: false | |
| run: | | |
| npm run general-search-scrape-server > /tmp/stdout.log 2> /tmp/stderr.log & | |
| sleep 6 | |
| curl --retry-connrefused --retry 6 -I http://localhost:4002/ | |
| - if: ${{ failure() }} | |
| name: Debug server outputs on errors | |
| run: | | |
| echo "____STDOUT____" | |
| cat /tmp/stdout.log | |
| echo "____STDERR____" | |
| cat /tmp/stderr.log | |
| - name: Scrape records into a temp directory | |
| env: | |
| # Deleting a reusable or data/* entry can leave translations pointing at missing | |
| # site.data keys and trigger RenderError. Accept empty strings until the next | |
| # translation pipeline removes those references. | |
| THROW_ON_EMPTY: false | |
| DOCS_INTERNAL_DATA: docs-internal-data | |
| run: | | |
| mkdir /tmp/records | |
| npm run general-search-scrape -- /tmp/records \ | |
| --language en \ | |
| --version fpt | |
| ls -lh /tmp/records | |
| - name: Check that Elasticsearch is accessible | |
| run: | | |
| curl --fail --retry-connrefused --retry 5 -I ${{ env.ELASTICSEARCH_URL }} | |
| - name: Index into Elasticsearch | |
| run: | | |
| npm run index-general-search -- /tmp/records \ | |
| --language en \ | |
| --version fpt | |
| - name: Check created indexes and aliases | |
| run: | | |
| curl --fail --retry-connrefused --retry 5 ${{ env.ELASTICSEARCH_URL }}/_cat/indices?v | |
| curl --fail --retry-connrefused --retry 5 ${{ env.ELASTICSEARCH_URL }}/_cat/indices?v |