|
| 1 | +name: common_quickstart |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + # Re-usable workflows do not automatically inherit the caller's secrets. |
| 9 | + # |
| 10 | + # This workflow decrypts encrypted files, so the calling workflow needs to |
| 11 | + # pass the secret to the re-usable workflow. |
| 12 | + # |
| 13 | + # Example: |
| 14 | + # |
| 15 | + # quickstart: |
| 16 | + # uses: ./.github/workflows/common_quickstart.yml |
| 17 | + # with: |
| 18 | + # # ... |
| 19 | + # secrets: |
| 20 | + # plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }} |
| 21 | + # |
| 22 | + secrets: |
| 23 | + plist_secret: |
| 24 | + required: true |
| 25 | + |
| 26 | + inputs: |
| 27 | + # The product to test be tested (e.g. `ABTesting`). |
| 28 | + product: |
| 29 | + type: string |
| 30 | + required: true |
| 31 | + |
| 32 | + # Whether to test the legacy version of the quickstart. |
| 33 | + is_legacy: |
| 34 | + type: boolean |
| 35 | + required: true |
| 36 | + |
| 37 | + # The path to the encrypted `GoogleService-Info.plist` file. |
| 38 | + plist_src_path: |
| 39 | + type: string |
| 40 | + required: true |
| 41 | + |
| 42 | + # The destination path for the decrypted `GoogleService-Info.plist` file. |
| 43 | + plist_dst_path: |
| 44 | + type: string |
| 45 | + required: true |
| 46 | + |
| 47 | + # The type of quickstart to test. |
| 48 | + # |
| 49 | + # Options: [swift, objc] |
| 50 | + quickstart_type: |
| 51 | + type: string |
| 52 | + required: false |
| 53 | + default: objc |
| 54 | + |
| 55 | + # Whether to run tests or just build. Defaults to true. |
| 56 | + run_tests: |
| 57 | + type: boolean |
| 58 | + required: false |
| 59 | + default: true |
| 60 | + |
| 61 | + # A command to execute before testing. |
| 62 | + # |
| 63 | + # Example: `scripts/setup_quickstart.sh functions` |
| 64 | + setup_command: |
| 65 | + type: string |
| 66 | + required: false |
| 67 | + default: "" |
| 68 | + |
| 69 | +jobs: |
| 70 | + quickstart: |
| 71 | + # Run on the main repo's scheduled jobs or pull requests and manual workflow invocations. |
| 72 | + if: (github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') || contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name) |
| 73 | + env: |
| 74 | + plist_secret: ${{ secrets.plist_secret }} |
| 75 | + LEGACY: ${{ inputs.is_legacy && true || '' }} |
| 76 | + runs-on: macos-15 |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1 |
| 80 | + - name: Xcode |
| 81 | + run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer |
| 82 | + - name: Run setup command. |
| 83 | + run: ${{ inputs.setup_command }} |
| 84 | + - name: Install Secret GoogleService-Info.plist |
| 85 | + run: | |
| 86 | + scripts/decrypt_gha_secret.sh \ |
| 87 | + ${{ inputs.plist_src_path }} \ |
| 88 | + ${{ inputs.plist_dst_path }} \ |
| 89 | + "$plist_secret" |
| 90 | + - name: Build ${{ inputs.product }} Quickstart (${{ inputs.quickstart_type }} / ${{ inputs.is_legacy && 'Legacy' || 'Non-Legacy' }}) |
| 91 | + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3 |
| 92 | + with: |
| 93 | + timeout_minutes: 15 |
| 94 | + max_attempts: 3 |
| 95 | + retry_wait_seconds: 120 |
| 96 | + command: | |
| 97 | + scripts/test_quickstart.sh \ |
| 98 | + ${{ inputs.product }} \ |
| 99 | + ${{ inputs.run_tests }} \ |
| 100 | + ${{ inputs.quickstart_type }} |
| 101 | + # Failure sequence to upload artifact. |
| 102 | + - id: lowercase_product |
| 103 | + if: ${{ failure() }} |
| 104 | + run: | |
| 105 | + lowercase_product=$(echo "${{ inputs.product }}" | tr '[:upper:]' '[:lower:]') |
| 106 | + echo "lowercase_product=$lowercase_product" >> $GITHUB_OUTPUT |
| 107 | + - name: Remove data before upload. |
| 108 | + if: ${{ failure() }} |
| 109 | + run: scripts/remove_data.sh ${{ steps.lowercase_product.outputs.lowercase_product }} |
| 110 | + - uses: actions/upload-artifact@v4 |
| 111 | + if: ${{ failure() }} |
| 112 | + with: |
| 113 | + name: quickstart_artifacts_${{ steps.lowercase_product.outputs.lowercase_product }} |
| 114 | + path: quickstart-ios/ |
0 commit comments