Skip to content

Commit e418b6b

Browse files
chore: enable test example apps workflow (#1623)
1 parent 64e1e32 commit e418b6b

File tree

6 files changed

+1503
-1012
lines changed

6 files changed

+1503
-1012
lines changed

.github/workflows/example-apps.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
name: Test Example Apps
1+
name: Validate Example Apps
22

3-
on: [workflow_dispatch]
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: ['**']
48

59
jobs:
610
test-example:
711
strategy:
812
matrix:
9-
node: [18, 20, 22]
10-
example: [basic, react-navigation]
13+
example: [basic]
14+
1115
name: Test Example
1216
runs-on: ubuntu-latest
1317
timeout-minutes: 10
@@ -18,8 +22,14 @@ jobs:
1822
- name: Setup Node.js
1923
uses: actions/setup-node@v4
2024
with:
21-
node-version: ${{ matrix.node }}
25+
node-version: 20
2226
cache: 'yarn'
2327

2428
- name: Install and build
25-
run: cd examples/${{ matrix.example }} && yarn install && yarn test
29+
run: yarn --cwd examples/${{ matrix.example }} install
30+
31+
- name: Type Check
32+
run: yarn --cwd examples/${{ matrix.example }} typecheck
33+
34+
- name: Test
35+
run: yarn --cwd examples/${{ matrix.example }} test

examples/basic/.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@callstack"
3+
}

examples/basic/components/LoginForm.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import { StyleSheet, View, Text, TextInput, Pressable, ActivityIndicator } from 'react-native';
3+
import { theme } from '../theme';
34

45
type Props = {
56
onLoginSuccess: (user: string) => void;
@@ -77,7 +78,7 @@ export function LoginForm({ onLoginSuccess }: Props) {
7778
* @param password The password to authenticate.
7879
* @returns username if the username and password are correct, null otherwise.
7980
*/
80-
async function authUser(username: string, password: string): Promise<string | null> {
81+
function authUser(username: string, password: string): Promise<string | null> {
8182
return new Promise((resolve) =>
8283
setTimeout(() => {
8384
const hasValidCredentials = username === 'admin' && password === 'admin1';
@@ -98,17 +99,17 @@ const styles = StyleSheet.create({
9899
},
99100
textLabel: {
100101
fontSize: 16,
101-
color: '#444',
102+
color: theme.colors.label,
102103
},
103104
textInput: {
104105
fontSize: 20,
105106
padding: 8,
106107
marginVertical: 8,
107-
borderColor: 'black',
108+
borderColor: theme.colors.text,
108109
borderWidth: 1,
109110
},
110111
button: {
111-
backgroundColor: '#3256a8',
112+
backgroundColor: theme.colors.button,
112113
padding: 16,
113114
alignItems: 'center',
114115
justifyContent: 'center',
@@ -118,10 +119,10 @@ const styles = StyleSheet.create({
118119
buttonText: {
119120
fontSize: 20,
120121
fontWeight: '600',
121-
color: 'white',
122+
color: theme.colors.buttonText,
122123
},
123124
validator: {
124-
color: 'red',
125+
color: theme.colors.validator,
125126
fontSize: 18,
126127
marginTop: 8,
127128
},

examples/basic/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"web": "expo start --web",
88
"eject": "expo eject",
99
"test": "jest",
10+
"lint": "eslint .",
1011
"typecheck": "tsc --noEmit"
1112
},
1213
"dependencies": {
@@ -20,7 +21,10 @@
2021
"devDependencies": {
2122
"@babel/core": "^7.20.0",
2223
"@testing-library/react-native": "^12.4.0",
24+
"@types/eslint": "^8.56.10",
25+
"@types/jest": "^29.5.12",
2326
"@types/react": "~18.2.45",
27+
"eslint": "^8.57.0",
2428
"jest": "^29.7.0",
2529
"react-test-renderer": "18.2.0",
2630
"typescript": "^5.3.0"

examples/basic/theme.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
export const theme = {
2+
colors: {
3+
button: '#3256a8',
4+
buttonText: '#ffffff',
5+
validator: '#d0421b',
6+
text: '#333333',
7+
label: '#666666',
8+
},
9+
spacing: {
10+
s: 8,
11+
m: 16,
12+
l: 24,
13+
xl: 40,
14+
},
15+
textVariants: {
16+
header: {
17+
fontSize: 32,
18+
fontFamily: 'System',
19+
color: 'text',
20+
},
21+
title: {
22+
fontSize: 24,
23+
fontFamily: 'System',
24+
color: 'text',
25+
},
26+
body: {
27+
fontSize: 16,
28+
fontFamily: 'System',
29+
color: 'text',
30+
},
31+
},
32+
};

0 commit comments

Comments
 (0)