Skip to content

Commit 40f1138

Browse files
authored
Merge pull request #46238 from github/repo-sync
Repo sync
2 parents ca64eb3 + 62ea212 commit 40f1138

38 files changed

Lines changed: 587 additions & 350 deletions

‎.github/actions/cache-nextjs/action.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ runs:
1313
with:
1414
path: ${{ github.workspace }}/.next/cache
1515
# Packages and source files both invalidate the cache.
16-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.ts', '**/*.tsx') }}
16+
# Use narrow globs: `**` walks node_modules and translations and takes about 35s per hash.
17+
key: ${{ runner.os }}-nextjs-${{ hashFiles('package-lock.json') }}-${{ hashFiles('src/**/*.ts', 'src/**/*.tsx', '*.ts') }}
1718
# With matching restore-key prefixes, source-only changes restore the same-package cache.
1819
restore-keys: |
19-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
20+
${{ runner.os }}-nextjs-${{ hashFiles('package-lock.json') }}-

‎.github/actions/clone-translations/action.yml‎

Lines changed: 38 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,58 +10,41 @@ inputs:
1010
runs:
1111
using: 'composite'
1212
steps:
13-
- name: Clone Spanish
14-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
15-
with:
16-
repository: github/docs-internal.es-es
17-
token: ${{ inputs.token }}
18-
path: translations/es-es
19-
20-
- name: Clone Japanese
21-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
22-
with:
23-
repository: github/docs-internal.ja-jp
24-
token: ${{ inputs.token }}
25-
path: translations/ja-jp
26-
27-
- name: Clone Portuguese
28-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
29-
with:
30-
repository: github/docs-internal.pt-br
31-
token: ${{ inputs.token }}
32-
path: translations/pt-br
33-
34-
- name: Clone Simplified Chinese
35-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
36-
with:
37-
repository: github/docs-internal.zh-cn
38-
token: ${{ inputs.token }}
39-
path: translations/zh-cn
40-
41-
- name: Clone Russian
42-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
43-
with:
44-
repository: github/docs-internal.ru-ru
45-
token: ${{ inputs.token }}
46-
path: translations/ru-ru
47-
48-
- name: Clone French
49-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
50-
with:
51-
repository: github/docs-internal.fr-fr
52-
token: ${{ inputs.token }}
53-
path: translations/fr-fr
54-
55-
- name: Clone Korean
56-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
57-
with:
58-
repository: github/docs-internal.ko-kr
59-
token: ${{ inputs.token }}
60-
path: translations/ko-kr
61-
62-
- name: Clone German
63-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
64-
with:
65-
repository: github/docs-internal.de-de
66-
token: ${{ inputs.token }}
67-
path: translations/de-de
13+
# Clone in parallel; sequential actions/checkout steps took about 30s.
14+
- name: Clone all translations
15+
shell: bash
16+
working-directory: ${{ github.workspace }}
17+
env:
18+
TOKEN: ${{ inputs.token }}
19+
run: |
20+
auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 | tr -d '\n')
21+
echo "::add-mask::$auth"
22+
# Pass auth through the environment so the token stays out of process
23+
# arguments and out of the clones' git config.
24+
export GIT_CONFIG_COUNT=1
25+
export GIT_CONFIG_KEY_0=http.https://github.com/.extraheader
26+
export GIT_CONFIG_VALUE_0="AUTHORIZATION: basic $auth"
27+
28+
clone() {
29+
local lang=$1
30+
for attempt in 1 2 3; do
31+
rm -rf "translations/$lang"
32+
git clone --quiet --depth 1 "https://github.com/github/docs-internal.$lang.git" "translations/$lang" \
33+
&& return 0
34+
echo "Clone of $lang failed on attempt $attempt"
35+
sleep $((attempt * 5))
36+
done
37+
return 1
38+
}
39+
40+
pids=()
41+
for lang in es-es ja-jp pt-br zh-cn ru-ru fr-fr ko-kr de-de; do
42+
clone "$lang" &
43+
pids+=($!)
44+
done
45+
46+
status=0
47+
for pid in "${pids[@]}"; do
48+
wait "$pid" || status=1
49+
done
50+
exit $status

‎.github/actions/node-npm-setup/action.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ runs:
1515
path: node_modules
1616
key: ${{ runner.os }}-node_modules-${{ hashFiles('package*.json') }}-${{ hashFiles('.github/actions/node-npm-setup/action.yml') }}
1717

18+
# The npm download cache only helps npm ci, so skip its 153 MB restore when node_modules hits.
1819
- name: Setup Node.js
1920
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
2021
with:
2122
node-version-file: 'package.json'
22-
cache: npm
23+
package-manager-cache: false
24+
cache: ${{ steps.cache-node_modules.outputs.cache-hit != 'true' && 'npm' || '' }}
2325

2426
- name: Install dependencies
2527
if: ${{ steps.cache-node_modules.outputs.cache-hit != 'true' }}

‎.github/actions/setup-elasticsearch/action.yml‎

Lines changed: 31 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,82 +10,49 @@ inputs:
1010
elasticsearch_version:
1111
description: Version of Elasticsearch to install
1212
required: true
13-
# Version must match production and be published on Docker Hub.
13+
# Version must match production and be published on docker.elastic.co.
1414
default: '8.12.0'
15+
mode:
16+
description: >-
17+
'both' starts Elasticsearch and waits until it is ready.
18+
'start' starts it in the background and returns right away.
19+
'wait' waits for a background start from an earlier 'start' step, then for readiness.
20+
required: false
21+
default: 'both'
1522

1623
runs:
1724
using: 'composite'
1825
steps:
19-
# Cache the Elasticsearch image to prevent Docker Hub rate limits.
20-
- name: Cache Docker layers
21-
id: cache-docker-layers
22-
uses: actions/cache@v4
23-
with:
24-
path: /tmp/docker-cache
25-
key: ${{ runner.os }}-elasticsearch-${{ inputs.elasticsearch_version }}
26-
restore-keys: |
27-
${{ runner.os }}-elasticsearch-
28-
29-
- name: Load cached Docker image
30-
shell: bash
31-
if: steps.cache-docker-layers.outputs.cache-hit == 'true'
32-
run: docker load -i /tmp/docker-cache/elasticsearch.tar || echo "No cache found for elasticsearch, pulling image"
33-
34-
- name: Pull Docker image
26+
- name: Start Elasticsearch
27+
if: ${{ inputs.mode == 'both' }}
3528
shell: bash
36-
if: steps.cache-docker-layers.outputs.cache-hit != 'true'
3729
env:
3830
ES_VERSION: ${{ inputs.elasticsearch_version }}
39-
run: docker pull elasticsearch:${ES_VERSION}
31+
run: bash "$GITHUB_ACTION_PATH/start.sh"
4032

41-
- name: Save Docker image to cache
33+
# Later steps such as npm ci and the build run while the image pulls and Elasticsearch boots.
34+
- name: Start Elasticsearch in the background
35+
if: ${{ inputs.mode == 'start' }}
4236
shell: bash
43-
if: steps.cache-docker-layers.outputs.cache-hit != 'true'
4437
env:
4538
ES_VERSION: ${{ inputs.elasticsearch_version }}
39+
ES_STATUS_FILE: ${{ runner.temp }}/elasticsearch-start.status
40+
ES_LOG_FILE: ${{ runner.temp }}/elasticsearch-start.log
4641
run: |
47-
mkdir -p /tmp/docker-cache
48-
docker save -o /tmp/docker-cache/elasticsearch.tar elasticsearch:${ES_VERSION}
49-
50-
# Run a single-node container with settings copied from getong/elasticsearch-action.
51-
- name: Run Docker container
42+
rm -f "$ES_STATUS_FILE"
43+
(
44+
status=0
45+
bash "$GITHUB_ACTION_PATH/start.sh" || status=$?
46+
echo "$status" > "$ES_STATUS_FILE.tmp"
47+
mv "$ES_STATUS_FILE.tmp" "$ES_STATUS_FILE"
48+
) > "$ES_LOG_FILE" 2>&1 < /dev/null &
49+
echo "Starting Elasticsearch in the background. A mode: wait step prints the log."
50+
51+
- name: Wait for Elasticsearch
52+
if: ${{ inputs.mode != 'start' }}
5253
shell: bash
5354
env:
54-
INPUT_ELASTICSEARCH_VERSION: ${{ inputs.elasticsearch_version }}
55-
INPUT_HOST_PORT: 9200
56-
INPUT_CONTAINER_PORT: 9200
57-
INPUT_HOST_NODE_PORT: 9300
58-
INPUT_NODE_PORT: 9300
59-
INPUT_DISCOVERY_TYPE: 'single-node'
60-
run: |
61-
docker network create elastic
62-
63-
docker run --network elastic \
64-
-e 'node.name=es1' \
65-
-e 'cluster.name=docker-elasticsearch' \
66-
-e 'cluster.initial_master_nodes=es1' \
67-
-e 'discovery.seed_hosts=es1' \
68-
-e 'cluster.routing.allocation.disk.threshold_enabled=false' \
69-
-e 'bootstrap.memory_lock=true' \
70-
-e 'ES_JAVA_OPTS=-Xms1g -Xmx1g' \
71-
-e 'xpack.security.enabled=false' \
72-
-e 'xpack.license.self_generated.type=basic' \
73-
--ulimit nofile=65536:65536 \
74-
--ulimit memlock=-1:-1 \
75-
--name='es1' \
76-
-d \
77-
-p $INPUT_HOST_PORT:$INPUT_CONTAINER_PORT \
78-
-p $INPUT_HOST_NODE_PORT:$INPUT_NODE_PORT \
79-
-e discovery_type=$INPUT_DISCOVERY_TYPE \
80-
elasticsearch:$INPUT_ELASTICSEARCH_VERSION
81-
82-
for i in {1..120}; do
83-
if curl --silent --fail http://localhost:9200; then
84-
echo "Elasticsearch is up and running"
85-
exit 0
86-
fi
87-
echo "Waiting for Elasticsearch to be ready..."
88-
sleep 1
89-
done
90-
echo "Elasticsearch did not become ready in time"
91-
exit 1
55+
ES_BACKGROUND: ${{ inputs.mode == 'wait' }}
56+
ES_STATUS_FILE: ${{ runner.temp }}/elasticsearch-start.status
57+
ES_LOG_FILE: ${{ runner.temp }}/elasticsearch-start.log
58+
run: bash "$GITHUB_ACTION_PATH/wait.sh"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# Pull the Elasticsearch image and start the es1 container. wait.sh checks readiness.
4+
5+
set -euo pipefail
6+
7+
image="docker.elastic.co/elasticsearch/elasticsearch:$ES_VERSION"
8+
9+
# Pull from Elastic's registry to avoid Docker Hub rate limits.
10+
# A pull is faster than restoring and loading a cached image tarball.
11+
pulled=false
12+
for attempt in 1 2 3; do
13+
if docker pull "$image"; then
14+
pulled=true
15+
break
16+
fi
17+
echo "Pull attempt $attempt failed"
18+
sleep $((attempt * 10))
19+
done
20+
if [ "$pulled" != true ]; then
21+
echo "Could not pull $image"
22+
exit 1
23+
fi
24+
25+
# Run a single-node container with settings copied from getong/elasticsearch-action.
26+
docker network create elastic
27+
28+
docker run --network elastic \
29+
-e 'node.name=es1' \
30+
-e 'cluster.name=docker-elasticsearch' \
31+
-e 'cluster.initial_master_nodes=es1' \
32+
-e 'discovery.seed_hosts=es1' \
33+
-e 'cluster.routing.allocation.disk.threshold_enabled=false' \
34+
-e 'bootstrap.memory_lock=true' \
35+
-e 'ES_JAVA_OPTS=-Xms1g -Xmx1g' \
36+
-e 'xpack.security.enabled=false' \
37+
-e 'xpack.license.self_generated.type=basic' \
38+
--ulimit nofile=65536:65536 \
39+
--ulimit memlock=-1:-1 \
40+
--name='es1' \
41+
-d \
42+
-p 9200:9200 \
43+
-p 9300:9300 \
44+
-e discovery_type=single-node \
45+
"$image"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# Wait until Elasticsearch answers on localhost:9200.
4+
# With ES_BACKGROUND=true, first wait for the background start.sh to finish.
5+
6+
set -euo pipefail
7+
8+
if [ "${ES_BACKGROUND:-false}" = true ]; then
9+
for _ in {1..300}; do
10+
[ -f "$ES_STATUS_FILE" ] && break
11+
sleep 1
12+
done
13+
echo "::group::Background start log"
14+
cat "$ES_LOG_FILE" || true
15+
echo "::endgroup::"
16+
if [ ! -f "$ES_STATUS_FILE" ]; then
17+
echo "::error::Elasticsearch start did not finish in time. Did a mode: start step run first?"
18+
exit 1
19+
fi
20+
status=$(cat "$ES_STATUS_FILE")
21+
if [ "$status" != 0 ]; then
22+
echo "::error::Elasticsearch start failed with exit code $status"
23+
exit 1
24+
fi
25+
fi
26+
27+
for _ in {1..120}; do
28+
if curl --silent --fail http://localhost:9200; then
29+
echo
30+
echo "Elasticsearch is up and running"
31+
exit 0
32+
fi
33+
echo "Waiting for Elasticsearch to be ready..."
34+
sleep 1
35+
done
36+
echo "::error::Elasticsearch did not become ready in time"
37+
docker logs --tail 100 es1 || true
38+
exit 1

‎.github/workflows/index-general-search-pr.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
# Debugging changes to this workflow need the same PR index test.
1313
- .github/workflows/index-general-search-pr.yml
1414
# Setup changes can break the local Elasticsearch path this workflow tests.
15-
- .github/actions/setup-elasticsearch/action.yml
15+
- '.github/actions/setup-elasticsearch/**'
1616

1717
permissions:
1818
contents: read

‎.github/workflows/package-lock-lint.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: Package lock lint
22

33
# This workflow catches manual package.json edits that leave package-lock.json out of sync.
4+
# It also blocks Microsoft package feed URLs, which break installs outside GitHub.
45

56
on:
67
pull_request:
78
paths:
9+
- .npmrc
810
- package.json
911
- package-lock.json
1012
- .github/workflows/package-lock-lint.yml
@@ -25,6 +27,18 @@ jobs:
2527
- name: Check out repo
2628
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
2729

30+
- name: Check for package feed URLs
31+
run: |
32+
status=0
33+
grep -inE 'https?://[^/"]*(pkgs\.visualstudio\.com|pkgs\.dev\.azure\.com|packagefeedproxy\.microsoft\.io)' .npmrc package-lock.json || status=$?
34+
if [ "$status" -eq 0 ]; then
35+
echo "::error::Found Microsoft package feed URLs. Use https://registry.npmjs.org/ instead."
36+
exit 1
37+
elif [ "$status" -ne 1 ]; then
38+
echo "::error::Could not scan .npmrc and package-lock.json for package feed URLs."
39+
exit "$status"
40+
fi
41+
2842
- name: Setup Node.js
2943
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
3044
with:

0 commit comments

Comments
 (0)