-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgitHubActions.js
122 lines (105 loc) · 2.87 KB
/
gitHubActions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const {includeIf} = require('./utils');
function getGitHubActionsConfig(answers, framework) {
return `name: Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
test:
name: Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v4
id: yarn-cache
with:
path: \${{ steps.yarn-cache-dir-path.outputs.dir }}
key: \${{ runner.os }}-yarn-\${{ hashFiles('**/yarn.lock') }}
restore-keys: |
\${{ runner.os }}-yarn-
- name: Install Dependencies
run: yarn install --frozen-lockfile
${includeIf(
framework.alwaysIncludeUnitTesting || answers.unitTesting,
`
- name: Unit Tests
run: yarn test --watchAll=false
`
)}
- name: ESLint
run: yarn lint
${includeIf(
answers.cypress && answers.framework === 'expo',
`
- name: Install Expo CLI
run: yarn global add expo-cli
- name: Install Sharp CLI
run: yarn global add sharp-cli
`
)}${includeIf(
answers.cypress,
`
- name: Cypress Tests
uses: cypress-io/github-action@v4
with:
start: yarn ${
framework.ciDevServerScript ?? framework.devServerScript ?? 'start'
}
wait-on: 'http://localhost:${framework.devServerPort}'
`
)}`;
}
function getDetoxGitHubActionsConfig(answers) {
return `name: Detox
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
test:
runs-on: macos-12
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${answers.framework === 'expo' ? 16 : 18}
cache: "yarn"
- name: Cache Pods dependencies
uses: actions/cache@v4
with:
path: ios/Pods
key: \${{ runner.OS }}-pods-cache-\${{ hashFiles('**/ios/Podfile.lock') }}
restore-keys: |
\${{ runner.OS }}-pods-cache-
- name: Install npm dependencies
run: yarn install --frozen-lockfile
${
answers.framework === 'expo'
? `- name: Generate Xcode Project
run: npx expo prebuild -p ios`
: `- name: Install iOS dependencies
run: npx pod-install`
}
- name: Install Detox CLI
run: |
brew tap wix/brew
brew install applesimutils
npm install -g detox-cli
- name: Build App for Detox
run: detox build -c ios.sim.release
- uses: futureware-tech/simulator-action@v2
with:
model: "iPhone 14"
- name: Run Detox
run: detox test -c ios.sim.release
`;
}
module.exports = {getDetoxGitHubActionsConfig, getGitHubActionsConfig};