Skip to content

refactor(kinesis): use withLock instead of paired lock and unlock calls #2663

refactor(kinesis): use withLock instead of paired lock and unlock calls

refactor(kinesis): use withLock instead of paired lock and unlock calls #2663

Workflow file for this run

name: Unit Tests | All
on:
workflow_call:
inputs:
identifier:
required: true
type: string
workflow_dispatch:
inputs:
ios:
description: '📱 iOS'
required: true
default: true
type: boolean
macos:
description: '💻 macOS'
required: true
default: true
type: boolean
tvos:
description: '📺 tvOS'
required: true
default: true
type: boolean
watchos:
description: '⌚️ watchOS'
required: true
default: true
type: boolean
visionos:
description: 'ᯅ visionOS'
required: true
default: true
type: boolean
push:
branches-ignore:
- main
- release
permissions:
contents: read
concurrency:
group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref_name != 'main'}}
jobs:
detect:
name: Detect affected targets
runs-on: macos-15
outputs:
cov: ${{ steps.sel.outputs.cov }}
nocov: ${{ steps.sel.outputs.nocov }}
covfiles: ${{ steps.sel.outputs.covfiles }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: sel
run: |
# Gate only on a genuine feature-branch push. Deploy pipelines invoke this workflow via
# workflow_call (which passes `identifier`), and manual runs use workflow_dispatch — both
# must exercise the full matrix, so only an unqualified `push` event is change-gated.
if [ -n "${{ inputs.identifier }}" ] || [ "${{ github.event_name }}" != "push" ]; then
sel=$(jq -c 'keys' scripts/python/unit_test_groups.json)
else
base='${{ github.event.pull_request.base.ref || 'main' }}'
git fetch --no-tags origin "$base" || true
git diff --name-only "$(git merge-base HEAD "origin/$base")" HEAD > /tmp/changed.txt
swift package dump-package > /tmp/package.json
sel=$(python3 scripts/python/affected_targets.py \
--package /tmp/package.json --changed /tmp/changed.txt \
--groups scripts/python/unit_test_groups.json | grep '^selected=' | cut -d= -f2-)
fi
echo "selected: $sel"
# Coverage matrix: the selected schemes that carry codecov flags (excludes the
# no-coverage InternalAWSPinpointUnitTests, which has no `flags`).
covfiles=$(jq -c --argjson sel "$sel" \
'[to_entries[] | select(.value.flags != null and (.key as $k | $sel | index($k))) | {scheme: .key, flags: .value.flags}]' \
scripts/python/unit_test_groups.json)
{
echo "nocov=$(jq -c '[.[]|select(.=="InternalAWSPinpointUnitTests")]' <<<"$sel")"
echo "cov=$(jq -c '[.[]|select(.!="InternalAWSPinpointUnitTests")]' <<<"$sel")"
echo "covfiles=$covfiles"
} >> "$GITHUB_OUTPUT"
targets-without-coverage:
name: ${{ matrix.scheme }} Unit Tests
needs: detect
if: ${{ needs.detect.outputs.nocov != '[]' }}
strategy:
fail-fast: false
matrix:
scheme: ${{ fromJSON(needs.detect.outputs.nocov) }}
uses: ./.github/workflows/run_unit_tests_platforms.yml
with:
scheme: ${{ matrix.scheme }}
generate_coverage_report: false
targets-with-coverage:
name: ${{ matrix.scheme }} Unit Tests
needs: detect
if: ${{ needs.detect.outputs.cov != '[]' }}
strategy:
fail-fast: false
matrix:
scheme: ${{ fromJSON(needs.detect.outputs.cov) }}
uses: ./.github/workflows/run_unit_tests_platforms.yml
with:
scheme: ${{ matrix.scheme }}
generate_coverage_report: ${{ vars.DISABLE_COVERAGE_REPORT != 'true' }}
report-coverage:
needs: [detect, targets-with-coverage]
if: ${{ vars.DISABLE_COVERAGE_REPORT != 'true' && needs.detect.outputs.covfiles != '[]' }}
name: ${{ matrix.file.scheme }} Unit Tests
strategy:
fail-fast: false
matrix:
file: ${{ fromJSON(needs.detect.outputs.covfiles) }}
uses: ./.github/workflows/upload_coverage_report.yml
with:
scheme: ${{ matrix.file.scheme }}
flags: ${{ matrix.file.flags }}
secrets: inherit
unit-test-pass-confirmation:
runs-on: ubuntu-latest
name: Confirm Passing Unit Tests
if: ${{ !cancelled() }}
needs: [
detect,
targets-with-coverage,
targets-without-coverage
]
env:
EXIT_CODE: ${{ contains(needs.*.result, 'failure') && 1 || 0 }}
steps:
- run: exit $EXIT_CODE