Files
2026-07-13 11:40:16 +02:00

77 lines
2.5 KiB
YAML

name: Setup deps
description: Setup Node.js and install dependencies
inputs:
react-version:
description: React version to install (e.g., ^19.2.0)
required: false
react-native-version:
description: React Native version to install (e.g., 0.83.1)
required: false
test-renderer-version:
description: Test renderer version to install (e.g., 1.1.0)
required: false
runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .nvmrc
- name: Cache deps
id: yarn-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
./node_modules
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-yarn-
- name: Install deps
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
shell: bash
- name: Switch to React and React Native versions
if: inputs.react-version != '' && inputs.react-native-version != ''
run: |
RN_VERSION='${{ inputs.react-native-version }}'
RN_VERSION_CLEAN="$RN_VERSION"
case "$RN_VERSION_CLEAN" in
'~'*) RN_VERSION_CLEAN="${RN_VERSION_CLEAN#\~}" ;;
'^'*) RN_VERSION_CLEAN="${RN_VERSION_CLEAN#^}" ;;
esac
RN_MINOR="${RN_VERSION_CLEAN#0.}"
RN_MINOR="${RN_MINOR%%.*}"
deps=(
"react@${{ inputs.react-version }}"
"@types/react@${{ inputs.react-version }}"
"react-native@${RN_VERSION}"
"@react-native/babel-preset@${RN_VERSION}"
)
if (( RN_MINOR >= 85 )); then
deps+=("@react-native/jest-preset@${RN_VERSION}")
else
# RN 0.84 and older ship the Jest preset inside the `react-native`
# package, so drop the standalone package and point the config at it.
yarn remove @react-native/jest-preset
sed -i "s|preset: '@react-native/jest-preset'|preset: 'react-native'|" jest.config.js
fi
yarn add -D "${deps[@]}"
shell: bash
- name: Switch to test-renderer version
if: inputs.test-renderer-version != ''
run: yarn add -D test-renderer@${{ inputs.test-renderer-version }}
shell: bash