Skip to content

Commit 7ae6357

Browse files
authored
Merge pull request #3985 from aryaemami59/expo-example-ci
2 parents 7978bbb + a93ccaa commit 7ae6357

30 files changed

+13866
-1
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jobs:
149149
fail-fast: false
150150
matrix:
151151
node: ['18.x']
152-
example: ['cra4', 'cra5', 'next', 'vite', 'node-standard', 'node-esm']
152+
example: ['cra4', 'cra5', 'next', 'vite', 'node-standard', 'node-esm', 'expo']
153153
defaults:
154154
run:
155155
working-directory: ./examples/publish-ci/${{ matrix.example }}
@@ -183,6 +183,13 @@ jobs:
183183
- name: Show installed RTK versions
184184
run: yarn info @reduxjs/toolkit && yarn why @reduxjs/toolkit
185185

186+
- name: Set up JDK 17 for React Native build
187+
if: matrix.example == 'react-native' || matrix.example == 'expo'
188+
uses: actions/setup-java@v2
189+
with:
190+
java-version: '17.x'
191+
distribution: 'temurin'
192+
186193
- name: Build example
187194
run: NODE_OPTIONS=--openssl-legacy-provider yarn build
188195

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"@react-native",
5+
"plugin:@typescript-eslint/eslint-recommended",
6+
"plugin:@typescript-eslint/strict-type-checked",
7+
"plugin:@typescript-eslint/stylistic-type-checked",
8+
"plugin:react/jsx-runtime"
9+
],
10+
"ignorePatterns": [
11+
"node_modules",
12+
".vscode",
13+
"dist",
14+
"metro.config.js",
15+
"assets",
16+
".expo",
17+
".expo-shared",
18+
"webpack.config.ts"
19+
],
20+
"parser": "@typescript-eslint/parser",
21+
"parserOptions": {
22+
"project": true,
23+
"tsconfigRootDir": "./"
24+
},
25+
"plugins": ["@typescript-eslint"],
26+
"root": true,
27+
"rules": {
28+
"@typescript-eslint/consistent-type-imports": [
29+
2,
30+
{
31+
"fixStyle": "separate-type-imports"
32+
}
33+
]
34+
},
35+
"overrides": [
36+
{
37+
"files": ["./__tests__/**/*.ts", "./__tests__/**/*.tsx"],
38+
"env": { "jest": true }
39+
}
40+
]
41+
}

examples/publish-ci/expo/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
.yarn/
6+
7+
# Expo
8+
.expo/
9+
dist/
10+
web-build/
11+
12+
# Native
13+
*.orig.*
14+
*.jks
15+
*.p8
16+
*.p12
17+
*.key
18+
*.mobileprovision
19+
android
20+
ios
21+
22+
# Metro
23+
.metro-health-check*
24+
25+
# debug
26+
npm-debug.*
27+
yarn-debug.*
28+
yarn-error.*
29+
30+
# macOS
31+
.DS_Store
32+
*.pem
33+
34+
# local env files
35+
.env*.local
36+
37+
# typescript
38+
*.tsbuildinfo
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSameLine": true,
4+
"singleQuote": true,
5+
"trailingComma": "all"
6+
}

examples/publish-ci/expo/App.tsx

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import type { FC } from 'react';
2+
import {
3+
SafeAreaView,
4+
ScrollView,
5+
StatusBar,
6+
StyleSheet,
7+
Text,
8+
View,
9+
useColorScheme,
10+
} from 'react-native';
11+
import { Provider } from 'react-redux';
12+
import { store } from './src/app/store';
13+
import { Counter } from './src/features/counter/Counter';
14+
15+
import {
16+
DebugInstructions,
17+
HermesBadge,
18+
LearnMoreLinks,
19+
ReloadInstructions,
20+
} from 'react-native/Libraries/NewAppScreen';
21+
import { Header } from './src/components/Header';
22+
import { LearnReduxLinks } from './src/components/LearnReduxLinks';
23+
import { Section } from './src/components/Section';
24+
import { TypedColors } from './src/constants/TypedColors';
25+
26+
export const App: FC = () => {
27+
const isDarkMode = useColorScheme() === 'dark';
28+
29+
const backgroundStyle = {
30+
backgroundColor: isDarkMode ? TypedColors.darker : TypedColors.lighter,
31+
};
32+
33+
return (
34+
<Provider store={store}>
35+
<SafeAreaView style={backgroundStyle}>
36+
<StatusBar
37+
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
38+
backgroundColor={backgroundStyle.backgroundColor}
39+
/>
40+
<ScrollView
41+
contentInsetAdjustmentBehavior="automatic"
42+
style={backgroundStyle}>
43+
<Header />
44+
<HermesBadge />
45+
<View
46+
style={{
47+
backgroundColor: isDarkMode
48+
? TypedColors.black
49+
: TypedColors.white,
50+
}}>
51+
<Counter />
52+
<Section title="Step One">
53+
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
54+
screen and then come back to see your edits.
55+
</Section>
56+
<Section title="See Your Changes">
57+
<ReloadInstructions />
58+
</Section>
59+
<Section title="Debug">
60+
<DebugInstructions />
61+
</Section>
62+
<Section title="Learn More Redux">
63+
Discover what to do next with Redux:
64+
</Section>
65+
<LearnReduxLinks />
66+
<Section title="Learn More React Native">
67+
Read the docs to discover what to do next:
68+
</Section>
69+
<LearnMoreLinks />
70+
</View>
71+
</ScrollView>
72+
</SafeAreaView>
73+
</Provider>
74+
);
75+
};
76+
77+
const styles = StyleSheet.create({
78+
highlight: {
79+
fontWeight: '700',
80+
},
81+
});
82+
83+
export default App;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { render } from '@testing-library/react-native';
2+
import renderer from 'react-test-renderer';
3+
import { App } from '../App';
4+
5+
test('renders correctly', () => {
6+
renderer.create(<App />);
7+
const element = render(<App />);
8+
expect(element).toBeDefined();
9+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { CounterState } from '../src/features/counter/counterSlice';
2+
import {
3+
counterSlice,
4+
decrement,
5+
increment,
6+
incrementByAmount,
7+
} from '../src/features/counter/counterSlice';
8+
9+
describe('counter reducer', () => {
10+
const { reducer: counterReducer } = counterSlice;
11+
const initialState: CounterState = {
12+
value: 3,
13+
status: 'idle',
14+
};
15+
16+
test('should handle initial state', () => {
17+
expect(counterReducer(undefined, { type: 'unknown' })).toStrictEqual({
18+
value: 0,
19+
status: 'idle',
20+
});
21+
});
22+
23+
test('should handle increment', () => {
24+
const actual = counterReducer(initialState, increment());
25+
expect(actual.value).toBe(4);
26+
});
27+
28+
test('should handle decrement', () => {
29+
const actual = counterReducer(initialState, decrement());
30+
expect(actual.value).toBe(2);
31+
});
32+
33+
test('should handle incrementByAmount', () => {
34+
const actual = counterReducer(initialState, incrementByAmount(2));
35+
expect(actual.value).toBe(5);
36+
});
37+
});

examples/publish-ci/expo/app.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"expo": {
3+
"name": "expo-template-redux-typescript",
4+
"slug": "expo-template-redux-typescript",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/icon.png",
8+
"userInterfaceStyle": "light",
9+
"splash": {
10+
"image": "./assets/splash.png",
11+
"resizeMode": "contain",
12+
"backgroundColor": "#ffffff"
13+
},
14+
"assetBundlePatterns": [
15+
"**/*"
16+
],
17+
"ios": {
18+
"supportsTablet": true
19+
},
20+
"android": {
21+
"adaptiveIcon": {
22+
"foregroundImage": "./assets/adaptive-icon.png",
23+
"backgroundColor": "#ffffff"
24+
},
25+
"package": "com.anonymous.expotemplatereduxtypescript"
26+
},
27+
"web": {
28+
"favicon": "./assets/favicon.png"
29+
}
30+
}
31+
}
Loading
1.43 KB
Loading

0 commit comments

Comments
 (0)