Skip to content

Commit 70047f8

Browse files
authored
Merge pull request #7 from brionmario/move-quickstarts-to-samples
Add the SDK quickstart samples
2 parents d707654 + fc75389 commit 70047f8

279 files changed

Lines changed: 34647 additions & 75 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/bump-version/action.yml‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: Bump Sample Version
22
description: >
33
Bumps the version of a sample app in its native version manifest, so samples
44
built on different stacks can share one release flow. Supported manifests
5-
(checked in order): package.json (npm/pnpm/yarn) and pubspec.yaml (Flutter/Dart).
5+
(checked in order): package.json (npm/pnpm/yarn), pubspec.yaml (Flutter/Dart),
6+
build.gradle.kts (Android) and *.xcodeproj/project.pbxproj (iOS).
67
78
inputs:
89
path:
@@ -72,8 +73,37 @@ runs:
7273
fi
7374
sed -i -E "s/^version:[[:space:]]*[^[:space:]#]+/version: ${VERSION}+${BUILD}/" "${MANIFEST}"
7475
76+
elif [ -f "${SAMPLE_PATH}/build.gradle.kts" ] && grep -q 'versionName = "' "${SAMPLE_PATH}/build.gradle.kts"; then
77+
MANIFEST="${SAMPLE_PATH}/build.gradle.kts"
78+
CURRENT=$(sed -n -E 's/^[[:space:]]*versionName = "([^"]+)".*/\1/p' "${MANIFEST}" | head -1)
79+
CODE=$(sed -n -E 's/^[[:space:]]*versionCode = ([0-9]+).*/\1/p' "${MANIFEST}" | head -1)
80+
if [ -z "${CURRENT}" ] || [ -z "${CODE}" ]; then
81+
echo "Error: no 'versionName'/'versionCode' found in ${MANIFEST}"
82+
exit 1
83+
fi
84+
85+
VERSION=$(bump_semver "${CURRENT}")
86+
# versionCode must increase monotonically for Android to accept the upgrade.
87+
sed -i -E "s/^([[:space:]]*versionName = )\"[^\"]+\"/\1\"${VERSION}\"/" "${MANIFEST}"
88+
sed -i -E "s/^([[:space:]]*versionCode = )[0-9]+/\1$((CODE + 1))/" "${MANIFEST}"
89+
90+
elif PBXPROJ=$(ls "${SAMPLE_PATH}"/*.xcodeproj/project.pbxproj 2>/dev/null | head -1) && [ -n "${PBXPROJ}" ]; then
91+
MANIFEST="${PBXPROJ}"
92+
CURRENT=$(sed -n -E 's/^[[:space:]]*MARKETING_VERSION = ([^;]+);.*/\1/p' "${MANIFEST}" | head -1)
93+
BUILD=$(sed -n -E 's/^[[:space:]]*CURRENT_PROJECT_VERSION = ([0-9]+);.*/\1/p' "${MANIFEST}" | head -1)
94+
if [ -z "${CURRENT}" ] || [ -z "${BUILD}" ]; then
95+
echo "Error: no 'MARKETING_VERSION'/'CURRENT_PROJECT_VERSION' found in ${MANIFEST}"
96+
exit 1
97+
fi
98+
99+
VERSION=$(bump_semver "${CURRENT}")
100+
# Every build configuration carries its own copy, so rewrite all of them. The build
101+
# number (CFBundleVersion) must increase monotonically, like the Flutter +N above.
102+
sed -i -E "s/^([[:space:]]*MARKETING_VERSION = )[^;]+;/\1${VERSION};/" "${MANIFEST}"
103+
sed -i -E "s/^([[:space:]]*CURRENT_PROJECT_VERSION = )[0-9]+;/\1$((BUILD + 1));/" "${MANIFEST}"
104+
75105
else
76-
echo "Error: no supported version manifest (package.json, pubspec.yaml) found in ${SAMPLE_PATH}"
106+
echo "Error: no supported version manifest (package.json, pubspec.yaml, build.gradle.kts, project.pbxproj) found in ${SAMPLE_PATH}"
77107
exit 1
78108
fi
79109

‎.github/workflows/pr-builder.yml‎

Lines changed: 138 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ jobs:
3434
with:
3535
fail-on-severity: high
3636
deny-licenses: GPL-3.0-only,GPL-3.0-or-later,AGPL-3.0-only,AGPL-3.0-or-later
37+
# No patched release exists for either advisory, and both are reached only through nuxt's
38+
# build and dev tooling in quickstarts/nuxt, which ignores them for `pnpm audit` too (see its
39+
# pnpm-workspace.yaml for the full justification). Drop each once upstream ships a fix.
40+
# GHSA-vfj7-8cjw-p6xm: braces stack-exhaustion DoS on the project's own glob patterns.
41+
# GHSA-86w9-cpqp-85rv: node-forge signature verification; only used for local dev certs.
42+
allow-ghsas: GHSA-vfj7-8cjw-p6xm, GHSA-86w9-cpqp-85rv
43+
# ThunderID's own Apache-2.0 package, which the dependency graph reports with the non-SPDX
44+
# lowercase id `apache-2.0`, failing the license validity check.
45+
allow-dependencies-licenses: pkg:pub/thunderid_flutter
3746
comment-summary-in-pr: always
3847
base-ref: ${{ github.event.pull_request.base.sha }}
3948
head-ref: ${{ github.event.pull_request.head.sha }}
@@ -43,30 +52,40 @@ jobs:
4352
runs-on: ubuntu-latest
4453
timeout-minutes: 5
4554
outputs:
46-
samples: ${{ steps.find.outputs.samples }}
55+
node: ${{ steps.find.outputs.node }}
56+
flutter: ${{ steps.find.outputs.flutter }}
57+
android: ${{ steps.find.outputs.android }}
58+
ios: ${{ steps.find.outputs.ios }}
4759
steps:
4860
- name: 📥 Checkout Code
4961
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5062

51-
# Every <category>/<sample>/ directory at the repo root with a package.json is a sample.
63+
# Every <category>/<sample>/ directory at the repo root is a sample. Its stack is picked from
64+
# the manifest at its root: package.json (Node.js), pubspec.yaml (Flutter),
65+
# settings.gradle.kts (Android) or Package.swift (iOS).
5266
- name: 🔍 Find Samples
5367
id: find
5468
run: |
55-
samples=$(find . -mindepth 3 -maxdepth 3 -name package.json -not -path "./.*" -not -path "*/node_modules/*" \
56-
-exec dirname {} \; 2>/dev/null | sed 's#^\./##' | sort | jq -R . | jq -cs .)
57-
echo "samples=$samples" >> "$GITHUB_OUTPUT"
58-
echo "Samples: $samples"
69+
find_samples() {
70+
find . -mindepth 3 -maxdepth 3 -name "$1" -not -path "./.*" -not -path "*/node_modules/*" \
71+
-exec dirname {} \; 2>/dev/null | sed 's#^\./##' | sort | jq -R . | jq -cs .
72+
}
73+
for stack in node:package.json flutter:pubspec.yaml android:settings.gradle.kts ios:Package.swift; do
74+
samples=$(find_samples "${stack#*:}")
75+
echo "${stack%%:*}=$samples" >> "$GITHUB_OUTPUT"
76+
echo "${stack%%:*} samples: $samples"
77+
done
5978
6079
build-lint:
6180
name: 🔨 Build & Lint (${{ matrix.sample }})
6281
needs: discover
63-
if: ${{ needs.discover.outputs.samples != '[]' }}
82+
if: ${{ needs.discover.outputs.node != '[]' }}
6483
runs-on: ubuntu-latest
6584
timeout-minutes: 15
6685
strategy:
6786
fail-fast: false
6887
matrix:
69-
sample: ${{ fromJson(needs.discover.outputs.samples) }}
88+
sample: ${{ fromJson(needs.discover.outputs.node) }}
7089
defaults:
7190
run:
7291
working-directory: ${{ matrix.sample }}
@@ -99,11 +118,119 @@ jobs:
99118
- name: 🔍 Security Audit
100119
run: pnpm audit --audit-level=high
101120

121+
# Not every sample has a formatter, a linter or a build step (e.g. the Node.js
122+
# server quickstarts run their sources directly), so each runs only where defined.
102123
- name: 🎨 Check Formatting
103-
run: pnpm format:check
124+
run: pnpm run --if-present format:check
104125

105126
- name: 🧹 Lint
106-
run: pnpm lint
127+
run: pnpm run --if-present lint
107128

108129
- name: 🔨 Build
109-
run: pnpm build
130+
run: pnpm run --if-present build
131+
132+
build-flutter:
133+
name: 🦋 Analyze & Build (${{ matrix.sample }})
134+
needs: discover
135+
if: ${{ needs.discover.outputs.flutter != '[]' }}
136+
runs-on: ubuntu-latest
137+
timeout-minutes: 30
138+
strategy:
139+
fail-fast: false
140+
matrix:
141+
sample: ${{ fromJson(needs.discover.outputs.flutter) }}
142+
defaults:
143+
run:
144+
working-directory: ${{ matrix.sample }}
145+
steps:
146+
- name: 📥 Checkout Code
147+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
148+
149+
- name: ☕ Set up JDK
150+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4
151+
with:
152+
distribution: 'temurin'
153+
java-version: '17'
154+
155+
- name: 🐦 Set up Flutter
156+
uses: subosito/flutter-action@4cab68ce0f1c7c924f688bff4792e044f1aeb30c # v2
157+
with:
158+
channel: stable
159+
cache: true
160+
161+
# Samples that bundle a .env as an asset need the file present to build.
162+
- name: 🔐 Create .env
163+
run: if [ -f .env.example ] && [ ! -f .env ]; then cp .env.example .env; fi
164+
165+
- name: 📦 Get Dependencies
166+
run: flutter pub get
167+
168+
- name: 🔍 Analyze
169+
run: flutter analyze
170+
171+
- name: 🔨 Build Android APK
172+
run: flutter build apk --debug
173+
174+
build-android:
175+
name: 🤖 Build (${{ matrix.sample }})
176+
needs: discover
177+
if: ${{ needs.discover.outputs.android != '[]' }}
178+
runs-on: ubuntu-latest
179+
timeout-minutes: 30
180+
strategy:
181+
fail-fast: false
182+
matrix:
183+
sample: ${{ fromJson(needs.discover.outputs.android) }}
184+
defaults:
185+
run:
186+
working-directory: ${{ matrix.sample }}
187+
steps:
188+
- name: 📥 Checkout Code
189+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
190+
191+
- name: ☕ Set up JDK
192+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4
193+
with:
194+
distribution: 'temurin'
195+
java-version: '17'
196+
197+
- name: 🗄️ Cache Gradle
198+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
199+
with:
200+
path: |
201+
~/.gradle/caches
202+
~/.gradle/wrapper
203+
key: ${{ runner.os }}-gradle-${{ matrix.sample }}-${{ hashFiles(format('{0}/**/*.gradle.kts', matrix.sample), format('{0}/**/gradle-wrapper.properties', matrix.sample)) }}
204+
restore-keys: |
205+
${{ runner.os }}-gradle-${{ matrix.sample }}-
206+
207+
- name: 🔨 Build Debug APK
208+
run: ./gradlew assembleDebug
209+
210+
build-ios:
211+
name: 🍎 Build (${{ matrix.sample }})
212+
needs: discover
213+
if: ${{ needs.discover.outputs.ios != '[]' }}
214+
runs-on: macos-latest
215+
timeout-minutes: 30
216+
strategy:
217+
fail-fast: false
218+
matrix:
219+
sample: ${{ fromJson(needs.discover.outputs.ios) }}
220+
defaults:
221+
run:
222+
working-directory: ${{ matrix.sample }}
223+
steps:
224+
- name: 📥 Checkout Code
225+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
226+
227+
- name: 🗄️ Cache Swift Packages
228+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
229+
with:
230+
path: ${{ matrix.sample }}/.build
231+
key: ${{ runner.os }}-swift-${{ matrix.sample }}-${{ hashFiles(format('{0}/Package.resolved', matrix.sample)) }}
232+
restore-keys: |
233+
${{ runner.os }}-swift-${{ matrix.sample }}-
234+
235+
- name: 🔨 Build
236+
run: swift build

0 commit comments

Comments
 (0)