-
Notifications
You must be signed in to change notification settings - Fork 406
Expand file tree
/
Copy pathaction.yml
More file actions
60 lines (58 loc) · 2.63 KB
/
Copy pathaction.yml
File metadata and controls
60 lines (58 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Node.js Setup
description: Internal implementation; install Node.js and Bun. Use `./.github/actions/node` instead.
inputs:
version:
description: "Version identifier of the version to use."
required: false
default: 'latest'
runs:
using: composite
steps:
# Resolve the version from the input alias. Exact patch versions come from
# packages/dd-trace/test/plugins/versions/package.json, kept up-to-date by
# Dependabot. Falls back to the bare major when the file is absent
# (e.g. sparse checkouts that only include .github/).
- name: Resolve Node.js version
id: node-version
env:
VERSION: ${{ inputs.version }}
LATEST_VERSION: ${{ env.LATEST_VERSION }}
shell: bash
run: |
node_version() {
local file="packages/dd-trace/test/plugins/versions/package.json"
[ -f "$file" ] && node -p \
"require('./${file}').dependencies['node-${1}'].replace('npm:node@','')" \
|| echo "${1}"
}
case "$VERSION" in
eol) version=16 ;;
oldest) version=$(node_version 18) ;;
maintenance) version=$(node_version 20) ;;
active) version=$(node_version 24) ;;
latest) version=${LATEST_VERSION:-$(node_version 26)}
# When a custom/nightly version is requested via latest,
# force tracer init past the engines upper-bound guard.
[ -n "$LATEST_VERSION" ] && echo "DD_INJECT_FORCE=true" >> "$GITHUB_ENV" || true ;;
*) version=$VERSION ;;
esac
echo "version=$version" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ steps.node-version.outputs.version }}
registry-url: ${{ inputs.registry-url || 'https://registry.npmjs.org' }}
# Persist the resolved version so subsequent runs within this 60-minute window can reuse it.
- name: Save resolved version
if: steps.node-version-cache.outputs.cache-hit != 'true'
shell: bash
run: node -v | tr -d 'v' > "$RUNNER_TEMP/.node-resolved-version-${{ steps.node-version.outputs.version }}"
- name: Check Node.js version for Bun
id: bun-check
shell: bash
run: |
MAJOR=$(node -e "process.stdout.write(String(parseInt(process.versions.node)))")
echo "supported=$([ "$MAJOR" -ge 12 ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
- name: Install Bun
if: steps.bun-check.outputs.supported == 'true'
shell: bash
run: npm install -g bun@1.3.1 --prefer-offline --no-audit --no-fund