diff --git a/.github/actions/download-artifact/action.yml b/.github/actions/download-artifact/action.yml new file mode 100644 index 000000000000..0edcd020fa67 --- /dev/null +++ b/.github/actions/download-artifact/action.yml @@ -0,0 +1,59 @@ +name: Download artifact with retries +description: Downloads an artifact, retrying transient failures up to two times + +inputs: + name: + description: Artifact name + required: true + path: + description: Destination path + required: true + +outputs: + download-path: + description: Absolute path where the artifact was downloaded + value: ${{ steps.download-3.outputs.download-path || steps.download-2.outputs.download-path || steps.download-1.outputs.download-path }} + +runs: + using: composite + steps: + - name: Download artifact (attempt 1 of 3) + id: download-1 + if: ${{ always() }} + continue-on-error: true + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 + with: + name: ${{ inputs.name }} + path: ${{ inputs.path }} + + - name: Wait before attempt 2 + if: ${{ always() && steps.download-1.outcome == 'failure' }} + shell: bash + run: | + echo "::warning::Artifact download failed; retrying in 10 seconds" + sleep 10 + + - name: Download artifact (attempt 2 of 3) + id: download-2 + if: ${{ always() && steps.download-1.outcome == 'failure' }} + continue-on-error: true + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 + with: + name: ${{ inputs.name }} + path: ${{ inputs.path }} + + - name: Wait before attempt 3 + if: ${{ always() && steps.download-2.outcome == 'failure' }} + shell: bash + run: | + echo "::warning::Artifact download failed again; retrying in 20 seconds" + sleep 20 + + - name: Download artifact (attempt 3 of 3) + id: download-3 + if: ${{ always() && steps.download-2.outcome == 'failure' }} + # Deliberately do not continue on error: the last failure must fail the caller. + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 + with: + name: ${{ inputs.name }} + path: ${{ inputs.path }} diff --git a/.github/workflows/e2e-ios-templateapp.yml b/.github/workflows/e2e-ios-templateapp.yml index dbaaaa2b5666..e8d7ba011c08 100644 --- a/.github/workflows/e2e-ios-templateapp.yml +++ b/.github/workflows/e2e-ios-templateapp.yml @@ -33,14 +33,14 @@ jobs: with: ruby-version: 2.6.10 - name: Download React Native Package - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: react-native-package path: /tmp/react-native-tmp - name: Print /tmp folder run: ls -lR /tmp/react-native-tmp - name: Download ReactNativeDependencies - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz path: /tmp/third-party @@ -48,7 +48,7 @@ jobs: shell: bash run: ls -lR /tmp/third-party - name: Download React Native Prebuilds - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: ReactCore${{ matrix.flavor }}.xcframework.tar.gz path: /tmp/ReactCore @@ -114,7 +114,7 @@ jobs: - name: Run yarn uses: ./.github/actions/yarn-install - name: Download app - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: RNTestProject-${{ matrix.flavor }} path: /tmp/RNTestProjectBuild/RNTestProject.app @@ -122,7 +122,7 @@ jobs: run: ls -l /tmp/RNTestProjectBuild/RNTestProject.app - name: Download React Native Package if: ${{ matrix.flavor == 'Debug' }} - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: react-native-package path: /tmp/react-native-tmp diff --git a/.github/workflows/test-ios-spm-newapp.yml b/.github/workflows/test-ios-spm-newapp.yml index 3fcceeb4c117..62e66395bae1 100644 --- a/.github/workflows/test-ios-spm-newapp.yml +++ b/.github/workflows/test-ios-spm-newapp.yml @@ -40,27 +40,27 @@ jobs: # release/ artifact slots together (and `--download skip` refuses an # incomplete slot). Please don't "optimise" this down to one flavor. - name: Download ReactCore (Debug) - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: ReactCoreDebug.xcframework.tar.gz path: /tmp/rc-debug - name: Download ReactCore (Release) - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: ReactCoreRelease.xcframework.tar.gz path: /tmp/rc-release - name: Download ReactNativeDependencies (Debug) - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: ReactNativeDependenciesDebug.xcframework.tar.gz path: /tmp/deps-debug - name: Download ReactNativeDependencies (Release) - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: ReactNativeDependenciesRelease.xcframework.tar.gz path: /tmp/deps-release - name: Download React Native package - uses: actions/download-artifact@v7 + uses: ./.github/actions/download-artifact with: name: react-native-package path: /tmp/react-native-tmp