Skip to content

Commit 8d5e09f

Browse files
authored
chore: add github workflow to test every template (#276)
1 parent 2bc26b4 commit 8d5e09f

File tree

6 files changed

+136
-21
lines changed

6 files changed

+136
-21
lines changed

.github/workflows/build-templates.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build all templates
2+
on:
3+
push:
4+
5+
jobs:
6+
build-templates:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
type:
12+
- module
13+
- view
14+
language:
15+
- java-objc
16+
- java-swift
17+
- kotlin-objc
18+
- kotlin-swift
19+
- cpp
20+
example:
21+
- native
22+
include:
23+
- type: module
24+
language: js
25+
example: expo
26+
- type: module
27+
language: js
28+
example: native
29+
- type: module-legacy
30+
language: java-objc
31+
example: native
32+
- type: module-turbo
33+
language: java-objc
34+
example: native
35+
- type: module-mixed
36+
language: java-objc
37+
example: native
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v3
42+
43+
- name: Setup Node.js
44+
uses: actions/[email protected]
45+
with:
46+
node-version: 16.x
47+
cache: yarn
48+
49+
- name: Restore project yarn cache
50+
id: root-yarn-cache
51+
uses: actions/cache@v3
52+
with:
53+
path: |
54+
**/node_modules
55+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
56+
57+
- name: Install dependencies
58+
if: steps.root-yarn-cache.outputs.cache-hit != 'true'
59+
run: |
60+
yarn install --frozen-lockfile
61+
62+
- name: Build package
63+
run: |
64+
yarn workspace create-react-native-library prepare
65+
66+
- name: Create temporary working directory
67+
run: |
68+
mkdir ../tmp
69+
70+
- name: Create library
71+
working-directory: ../tmp
72+
run: |
73+
../react-native-builder-bob/packages/create-react-native-library/bin/create-react-native-library react-native-test \
74+
--slug react-native-test \
75+
--description test \
76+
--author-name test \
77+
--author-email test@test \
78+
--author-url https://test.test \
79+
--repo-url https://test.test \
80+
--type ${{ matrix.type }} \
81+
--languages ${{ matrix.language }} \
82+
--example ${{ matrix.example }}
83+
84+
- name: Cache dependencies of library
85+
id: library-yarn-cache
86+
uses: actions/cache@v3
87+
with:
88+
path: |
89+
../tmp/react-native-test/node_modules
90+
../tmp/example/node_modules
91+
key: ${{ runner.os }}-library-yarn-${{ matrix.type }}-${{ matrix.language }}-${{ matrix.example}}-${{ hashFiles('yarn.lock') }}
92+
93+
- name: Install dependencies of library
94+
if: steps.library-yarn-cache.outputs.cache-hit != 'true'
95+
working-directory: ../tmp/react-native-test
96+
run: |
97+
yarn install
98+
99+
- name: Lint library
100+
working-directory: ../tmp/react-native-test
101+
run: |
102+
yarn lint
103+
104+
- name: Typecheck library
105+
working-directory: ../tmp/react-native-test
106+
run: |
107+
yarn typescript
108+
109+
- name: Test library
110+
working-directory: ../tmp/react-native-test
111+
run: |
112+
yarn test
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
name: Test monorepo
1+
name: Check project
22
on:
3-
pull_request:
4-
branches:
5-
- main
3+
push:
64

75
jobs:
8-
test-monorepo:
9-
name: Test monorepo
6+
check-project:
107
runs-on: ubuntu-latest
118
steps:
12-
- name: Checkout repo
9+
- name: Checkout
1310
uses: actions/checkout@v3
1411

15-
- name: Install node
12+
- name: Setup Node.js
1613
uses: actions/setup-node@v3
1714
with:
18-
node-version: 16.13.x
15+
node-version: 16.x
1916
cache: yarn
2017

21-
- name: Restore dependencies
18+
- name: Restore yarn cache
2219
id: yarn-cache
2320
uses: actions/cache@v3
2421
with:
25-
path: '**/node_modules'
22+
path: |
23+
**/node_modules
2624
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
2725

2826
- name: Install dependencies
2927
if: steps.yarn-cache.outputs.cache-hit != 'true'
3028
run: yarn install --frozen-lockfile
3129

32-
- name: Lint files
30+
- name: Lint
3331
run: yarn lint
3432

35-
- name: Build packages in the monorepo
33+
- name: Build packages
3634
run: yarn lerna run prepare
3735

38-
- name: Typecheck files
36+
- name: Typecheck
3937
run: yarn typescript

packages/create-react-native-library/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ const args: Record<ArgName, yargs.Options> = {
122122
},
123123
'type': {
124124
description: 'Type of library you want to develop',
125-
choices: ['module', 'view'],
125+
choices: [
126+
'module-legacy',
127+
'module-turbo',
128+
'module-mixed',
129+
'module',
130+
'view',
131+
],
126132
},
127133
'example': {
128134
description: 'Type of example app',

packages/create-react-native-library/templates/example/example/react-native.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
const path = require('path');
22

3-
module.exports = {
4-
<% if (project.native) { -%>
3+
module.exports = {<% if (project.native) { %>
54
dependencies: {
6-
'<%- project.slug -%>': {
5+
'<% project.slug -%>': {
76
root: path.join(__dirname, '..'),
87
},
98
},

packages/create-react-native-library/templates/native-library-legacy/src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const LINKING_ERROR =
66
'- You rebuilt the app after installing the package\n' +
77
'- You are not using Expo Go\n';
88

9-
const <%- project.name -%> = NativeModules.<%- project.name -%>
10-
? NativeModules.<%- project.name -%>
9+
const <%- project.name -%> = NativeModules.<%- project.name %>
10+
? NativeModules.<%- project.name %>
1111
: new Proxy(
1212
{},
1313
{

packages/create-react-native-library/templates/native-library-turbo/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const <%- project.name -%> = require('./Native<%- project.name -%>').default
1+
const <%- project.name -%> = require('./Native<%- project.name -%>').default;
22

33
export function multiply(a: number, b: number): number {
44
return <%- project.name -%>.multiply(a, b);

0 commit comments

Comments
 (0)