name: Setup CI Environment description: Sets up Node, Yarn (with cache), optional Java, Playwright browsers, zstd, and xvfb-run shim for both github.com and self-hosted runners. inputs: node-version: description: Node.js version to install required: false default: '24.22.1' cache: description: Package manager cache mode ('yarn' or '') required: false default: 'yarn' install-deps: description: Whether to run yarn install ('true' or 'false') required: false default: 'false' java-version: description: Optional Java version to install (e.g. '22') required: false default: '' browser: description: Optional Playwright browser to install ('chromium' or 'firefox') required: false default: '' zstd: description: Whether to ensure zstd is installed ('true' or 'false') required: false default: 'false' runs: using: composite steps: - name: Set up Node uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # ratchet:actions/setup-node@v7 with: node-version: ${{ inputs.node-version }} cache: ${{ github.server_url == 'https://github.com' && inputs.cache || '' }} - name: Ensure Yarn is installed if: ${{ github.server_url != 'https://github.com' }} shell: bash run: command -v yarn >/dev/null 2>&1 || npm install -g yarn@1.22.22 - name: Restore Yarn cache (self-hosted) if: ${{ github.server_url != 'https://github.com' && inputs.cache == 'yarn' }} uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # ratchet:actions/setup-node@v7 with: node-version: ${{ inputs.node-version }} cache: 'yarn' - name: Set up Java if: ${{ inputs.java-version != '' }} uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0 with: distribution: ${{ github.server_url == 'https://github.com' && 'temurin' || 'zulu' }} java-version: ${{ inputs.java-version }} - name: Ensure zstd is installed if: ${{ github.server_url != 'https://github.com' && inputs.zstd == 'true' && runner.os == 'Linux' }} shell: bash run: | if ! command -v zstd >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then sudo apt-get update -qq && sudo apt-get install -y -qq zstd else echo "::warning::zstd is not installed and apt-get is unavailable on this runner" fi fi - name: Ensure xvfb-run shim when missing if: ${{ github.server_url != 'https://github.com' && runner.os == 'Linux' }} shell: bash run: | if ! command -v xvfb-run >/dev/null 2>&1; then mkdir -p "${RUNNER_TEMP}/ci-bin" printf '#!/bin/sh\nexec "$@"\n' > "${RUNNER_TEMP}/ci-bin/xvfb-run" chmod +x "${RUNNER_TEMP}/ci-bin/xvfb-run" echo "${RUNNER_TEMP}/ci-bin" >> "${GITHUB_PATH}" fi - name: Install dependencies if: ${{ inputs.install-deps == 'true' }} shell: bash run: | if [ "${{ github.server_url }}" != "https://github.com" ]; then yarn install --frozen-lockfile --prefer-offline --network-concurrency 16 else yarn fi - name: Ensure Playwright browser is installed if: ${{ inputs.browser != '' }} shell: bash run: | if [ "${{ github.server_url }}" != "https://github.com" ]; then if [ "${{ runner.os }}" = "Linux" ]; then npx playwright install --with-deps chromium "${{ inputs.browser }}" else npx playwright install "${{ inputs.browser }}" fi elif [ "${{ inputs.browser }}" != "chromium" ]; then npx playwright install "${{ inputs.browser }}" fi