feat(text): implement dynamic styled text and serialization #1935
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: UI Tests | |
| on: | |
| workflow_call: | |
| inputs: | |
| ref: | |
| required: true | |
| type: string | |
| platform: | |
| default: all | |
| type: string | |
| configuration: | |
| default: default | |
| type: string | |
| update_reference: | |
| default: false | |
| type: boolean | |
| only-testing: | |
| default: '' | |
| type: string | |
| outputs: | |
| verified-sha: | |
| description: Commit verified on both platforms | |
| value: ${{ jobs.ios_uitest.outputs.sha == jobs.macos_uitest.outputs.sha && jobs.ios_uitest.outputs.sha || '' }} | |
| workflow_dispatch: | |
| inputs: | |
| platform: | |
| description: Platform to test | |
| required: true | |
| default: all | |
| type: choice | |
| options: | |
| - all | |
| - ios | |
| - macos | |
| update_reference: | |
| description: Update reference images before running UI tests | |
| required: false | |
| default: false | |
| type: boolean | |
| only-testing: | |
| description: 'Optional test identifier (e.g. OpenSwiftUIUITests/TextUITests/dateFormatStyleExample())' | |
| required: false | |
| default: '' | |
| type: string | |
| configuration: | |
| description: UI test configuration set | |
| required: false | |
| default: default | |
| type: choice | |
| options: | |
| - default | |
| - all | |
| - swiftui-renderer-ag | |
| - swiftui-renderer-iag | |
| - openswiftui-renderer-ag | |
| - openswiftui-renderer-iag | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| contents: read | |
| issues: read | |
| pull-requests: read | |
| statuses: write | |
| jobs: | |
| prepare_uitests: | |
| uses: ./.github/workflows/prepare_snapshot_tests.yml | |
| with: | |
| command: /uitest | |
| status-context-prefix: UI Tests | |
| ref: ${{ inputs.ref || '' }} | |
| platform: ${{ inputs.platform || 'all' }} | |
| configuration: ${{ inputs.configuration || 'default' }} | |
| update_reference: ${{ inputs.update_reference || false }} | |
| only-testing: ${{ inputs.only-testing || '' }} | |
| ios_uitest: | |
| name: Execute UI tests on iOS (${{ matrix.configuration.id }}) | |
| outputs: | |
| sha: ${{ steps.run-tests.outputs.test-result == 'success' && needs.prepare_uitests.outputs.only-testing == '' && steps.checkout.outputs.commit || '' }} | |
| needs: prepare_uitests | |
| permissions: | |
| contents: read | |
| issues: read | |
| pull-requests: read | |
| statuses: write | |
| id-token: write | |
| if: >- | |
| needs.prepare_uitests.outputs.ios-requested == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| xcode-version: ["26.6"] | |
| release: [2024] | |
| ios-version: ["18.5"] | |
| configuration: ${{ fromJSON(needs.prepare_uitests.outputs.configuration-matrix) }} | |
| include: | |
| - ios-version: "18.5" | |
| ios-simulator-name: "iPhone 16 Pro" | |
| runs-on: | |
| - xcode-26.6 | |
| - ios-simulator-18.5 | |
| env: | |
| STATUS_CONTEXT: UI Tests / iOS / ${{ matrix.configuration.id }}${{ needs.prepare_uitests.outputs.only-testing != '' && ' / Selected' || '' }} | |
| STATUS_ENABLED: ${{ needs.prepare_uitests.outputs.status-enabled }} | |
| STATUS_SHA: ${{ needs.prepare_uitests.outputs.ref }} | |
| CONFIGURATION_NAME: ${{ matrix.configuration.id }} | |
| OPENSWIFTUI_WERROR: 0 # Disable it to avoid enable OAG's werror and hit conflicts | |
| OPENSWIFTUI_OPENATTRIBUTESHIMS_ATTRIBUTEGRAPH: ${{ matrix.configuration.attributegraph }} | |
| OPENSWIFTUI_OPENATTRIBUTESHIMS_COMPUTE: ${{ matrix.configuration.compute }} | |
| OPENSWIFTUI_COMPATIBILITY_TEST: 0 | |
| OPENSWIFTUI_SWIFT_LOG: 0 | |
| OPENSWIFTUI_SWIFT_CRYPTO: 0 | |
| OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }} | |
| OPENSWIFTUI_USE_LOCAL_DEPS: 1 | |
| OPENSWIFTUI_LINK_TESTING: 0 | |
| OPENSWIFTUI_SWIFTUI_RENDERER: ${{ matrix.configuration.swiftui_renderer }} | |
| GH_TOKEN: ${{ github.token }} | |
| steps: | |
| - name: Mark PR status running | |
| if: github.event_name == 'issue_comment' && env.STATUS_ENABLED == 'true' && env.STATUS_SHA != '' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| await github.rest.repos.createCommitStatus({ | |
| owner, | |
| repo, | |
| sha: process.env.STATUS_SHA, | |
| state: "pending", | |
| target_url: `${process.env.GITHUB_SERVER_URL}/${owner}/${repo}/actions/runs/${context.runId}`, | |
| description: `iOS UI tests (${process.env.CONFIGURATION_NAME}) are running.`, | |
| context: process.env.STATUS_CONTEXT, | |
| }); | |
| - uses: actions/checkout@v4 | |
| id: checkout | |
| with: | |
| repository: ${{ needs.prepare_uitests.outputs.repository || github.repository }} | |
| ref: ${{ needs.prepare_uitests.outputs.ref || github.sha }} | |
| persist-credentials: false | |
| - name: Run UI Tests | |
| id: run-tests | |
| uses: ./.github/actions/uitests | |
| with: | |
| xcode-version: ${{ matrix.xcode-version }} | |
| platform: ios | |
| destination: "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }}" | |
| artifact-name: ios-uitest-snapshots-${{ matrix.ios-version }}-${{ matrix.configuration.id }} | |
| update-reference: ${{ needs.prepare_uitests.outputs.update-reference == 'true' }} | |
| only-testing: ${{ needs.prepare_uitests.outputs.only-testing }} | |
| compute: ${{ matrix.configuration.compute == 1 }} | |
| - name: Require successful tests | |
| if: steps.run-tests.outputs.test-result != 'success' | |
| run: exit 1 | |
| - name: Complete PR status | |
| if: always() && github.event_name == 'issue_comment' && env.STATUS_ENABLED == 'true' && env.STATUS_SHA != '' | |
| uses: actions/github-script@v7 | |
| env: | |
| JOB_STATUS: ${{ job.status }} | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const state = process.env.JOB_STATUS === "success" ? "success" : | |
| process.env.JOB_STATUS === "cancelled" ? "error" : | |
| "failure"; | |
| const description = process.env.JOB_STATUS === "cancelled" ? | |
| "iOS UI tests were cancelled." : | |
| `iOS UI tests (${process.env.CONFIGURATION_NAME}) completed with ${state}.`; | |
| await github.rest.repos.createCommitStatus({ | |
| owner, | |
| repo, | |
| sha: process.env.STATUS_SHA, | |
| state, | |
| target_url: `${process.env.GITHUB_SERVER_URL}/${owner}/${repo}/actions/runs/${context.runId}`, | |
| description, | |
| context: process.env.STATUS_CONTEXT, | |
| }); | |
| macos_uitest: | |
| name: Execute UI tests on macOS (${{ matrix.configuration.id }}) | |
| outputs: | |
| sha: ${{ steps.run-tests.outputs.test-result == 'success' && needs.prepare_uitests.outputs.only-testing == '' && steps.checkout.outputs.commit || '' }} | |
| needs: prepare_uitests | |
| permissions: | |
| contents: read | |
| issues: read | |
| pull-requests: read | |
| statuses: write | |
| id-token: write | |
| if: >- | |
| needs.prepare_uitests.outputs.macos-requested == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-15] | |
| xcode-version: ["26.6"] | |
| release: [2024] | |
| configuration: ${{ fromJSON(needs.prepare_uitests.outputs.configuration-matrix) }} | |
| runs-on: | |
| - self-hosted | |
| - ${{ matrix.os }} | |
| - xcode-26.6 | |
| env: | |
| STATUS_CONTEXT: UI Tests / macOS / ${{ matrix.configuration.id }}${{ needs.prepare_uitests.outputs.only-testing != '' && ' / Selected' || '' }} | |
| STATUS_ENABLED: ${{ needs.prepare_uitests.outputs.status-enabled }} | |
| STATUS_SHA: ${{ needs.prepare_uitests.outputs.ref }} | |
| CONFIGURATION_NAME: ${{ matrix.configuration.id }} | |
| OPENSWIFTUI_WERROR: 0 | |
| OPENSWIFTUI_OPENATTRIBUTESHIMS_ATTRIBUTEGRAPH: ${{ matrix.configuration.attributegraph }} | |
| OPENSWIFTUI_OPENATTRIBUTESHIMS_COMPUTE: ${{ matrix.configuration.compute }} | |
| OPENSWIFTUI_COMPATIBILITY_TEST: 0 | |
| OPENSWIFTUI_SWIFT_LOG: 0 | |
| OPENSWIFTUI_SWIFT_CRYPTO: 0 | |
| OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }} | |
| OPENSWIFTUI_USE_LOCAL_DEPS: 1 | |
| OPENSWIFTUI_LINK_TESTING: 0 | |
| OPENSWIFTUI_SWIFTUI_RENDERER: ${{ matrix.configuration.swiftui_renderer }} | |
| GH_TOKEN: ${{ github.token }} | |
| steps: | |
| - name: Mark PR status running | |
| if: github.event_name == 'issue_comment' && env.STATUS_ENABLED == 'true' && env.STATUS_SHA != '' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| await github.rest.repos.createCommitStatus({ | |
| owner, | |
| repo, | |
| sha: process.env.STATUS_SHA, | |
| state: "pending", | |
| target_url: `${process.env.GITHUB_SERVER_URL}/${owner}/${repo}/actions/runs/${context.runId}`, | |
| description: `macOS UI tests (${process.env.CONFIGURATION_NAME}) are running.`, | |
| context: process.env.STATUS_CONTEXT, | |
| }); | |
| - uses: actions/checkout@v4 | |
| id: checkout | |
| with: | |
| repository: ${{ needs.prepare_uitests.outputs.repository || github.repository }} | |
| ref: ${{ needs.prepare_uitests.outputs.ref || github.sha }} | |
| persist-credentials: false | |
| - name: Run UI Tests | |
| id: run-tests | |
| uses: ./.github/actions/uitests | |
| with: | |
| xcode-version: ${{ matrix.xcode-version }} | |
| platform: macos | |
| destination: "platform=macOS" | |
| artifact-name: macos-uitest-snapshots-${{ matrix.configuration.id }} | |
| update-reference: ${{ needs.prepare_uitests.outputs.update-reference == 'true' }} | |
| only-testing: ${{ needs.prepare_uitests.outputs.only-testing }} | |
| compute: ${{ matrix.configuration.compute == 1 }} | |
| - name: Require successful tests | |
| if: steps.run-tests.outputs.test-result != 'success' | |
| run: exit 1 | |
| - name: Complete PR status | |
| if: always() && github.event_name == 'issue_comment' && env.STATUS_ENABLED == 'true' && env.STATUS_SHA != '' | |
| uses: actions/github-script@v7 | |
| env: | |
| JOB_STATUS: ${{ job.status }} | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const state = process.env.JOB_STATUS === "success" ? "success" : | |
| process.env.JOB_STATUS === "cancelled" ? "error" : | |
| "failure"; | |
| const description = process.env.JOB_STATUS === "cancelled" ? | |
| "macOS UI tests were cancelled." : | |
| `macOS UI tests (${process.env.CONFIGURATION_NAME}) completed with ${state}.`; | |
| await github.rest.repos.createCommitStatus({ | |
| owner, | |
| repo, | |
| sha: process.env.STATUS_SHA, | |
| state, | |
| target_url: `${process.env.GITHUB_SERVER_URL}/${owner}/${repo}/actions/runs/${context.runId}`, | |
| description, | |
| context: process.env.STATUS_CONTEXT, | |
| }); |