Files
Nicola Corti 3e6b2bf8cc Retry artifact uploads in CI (#58620)
Summary:
Artifact uploads can fail on transient network errors such as the `ETIMEDOUT` in https://github.com/react/react-native/actions/runs/35598907154/job/106330670539.

This change:

- adds a local composite action backed by `actions/upload-artifact` v7.0.1
- retries failed uploads twice, waiting 10 seconds before attempt 2 and 20 seconds before attempt 3
- propagates the third failure to the caller
- preserves all v7 inputs and outputs
- migrates all 35 artifact upload call sites to the wrapper

## Changelog:

[INTERNAL] [FIXED] - Retry artifact uploads to reduce transient CI failures.

Pull Request resolved: https://github.com/react/react-native/pull/58620

Test Plan:
- `node_modules/.bin/prettier --check $(git diff --name-only HEAD^ -- '*.yml' '*.yaml')` — passed
- `npx --yes action-validator/cli@0.6.0 .github/actions/upload-artifact/action.yml` — passed
- `git diff HEAD^ --check` — passed
- Verified no `actions/upload-artifact@v6` references remain under `.github`

Reviewed By: andrewdacenko

Differential Revision: D121002745

Pulled By: cortinico

fbshipit-source-id: e63e30f3e86b0a2cb6c94aa549cdfe5e6dfbdc2b
2026-09-21 06:51:11 -07:00

83 lines
2.6 KiB
YAML

name: Format
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- '*-stable'
permissions:
contents: read
jobs:
format:
runs-on: macos-26
if: github.repository == 'react/react-native'
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup Xcode
uses: ./.github/actions/setup-xcode
with:
xcode-version: 26.6.0
- name: Setup Node.js
uses: ./.github/actions/setup-node
- name: Initialize report
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
PR_NUMBER: ${{ github.event.pull_request.number || '' }}
run: |
mkdir -p .format-results
node -e "const {EVENT_NAME, HEAD_SHA, PR_NUMBER} = process.env; require('fs').writeFileSync('.format-results/metadata.json', JSON.stringify({EVENT_NAME, HEAD_SHA, PR_NUMBER}))"
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
uses: ./.github/actions/yarn-install
- name: Check formatting
id: format
continue-on-error: true
shell: bash
run: |
set +e
{
status=0
for formatter in javascript cpp kotlin java python swift; do
yarn "format-$formatter" || status=1
done
exit "$status"
} 2>&1 | tee .format-results/output.txt
format_status=${PIPESTATUS[0]}
set -e
git diff --no-ext-diff --no-color --unified=3 -- . \
':(exclude)packages/react-native/package.json' \
':(exclude)yarn.lock' > .format-results/format.patch
if [[ $format_status -ne 0 || -s .format-results/format.patch ]]; then
exit 1
fi
- name: Upload formatting report
if: always() && github.event_name == 'pull_request'
uses: ./.github/actions/upload-artifact
with:
name: format-results
path: .format-results/
retention-days: 1
- name: Report formatting failure
if: steps.format.outcome == 'failure'
shell: bash
run: |
echo '::error::Formatting is invalid. Run `yarn format` and commit the result.'
exit 1