-
Notifications
You must be signed in to change notification settings - Fork 21
139 lines (136 loc) · 4.81 KB
/
tests.yaml
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: CI
on:
push:
branches: [ master ]
release:
types: [ published ]
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # https://crontab.guru/every-week
env:
TEST_APP_DEPS: react-native-modal react-native-webview
TEST_APP_DEV_DEPS: typescript @babel/preset-env react-shallow-renderer
RN_BUNDLE_ARGS: --entry-file index.js --platform android --dev false --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm test
test-yarn:
needs: build
runs-on: ubuntu-latest
outputs:
rn-version: ${{ steps.rn-version.outputs.value }}
steps:
- uses: actions/checkout@v4
with:
path: react-native-hcaptcha
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- run: npx react-native init rnexample
- id: rn-version
working-directory: rnexample
run: |
RN_VERSION=$(cat package.json | jq ".dependencies.\"react-native\"" -r)
echo "value=${RN_VERSION}" >> $GITHUB_OUTPUT
- name: Run yarn add ...
working-directory: rnexample
run: |
yarn add @hcaptcha/react-native-hcaptcha@file:../react-native-hcaptcha
yarn add --dev ${{ env.TEST_APP_DEV_DEPS }}
yarn add ${{ env.TEST_APP_DEPS }}
cp ../react-native-hcaptcha/Example.App.js App.js
cp ../react-native-hcaptcha/Example.jest.config.js jest.config.js
- run: |
mkdir -p android/app/src/main/assets
mkdir -p android/app/src/main/res
yarn react-native bundle ${{ env.RN_BUNDLE_ARGS }}
working-directory: rnexample
- run: cat package.json
working-directory: rnexample
- run: yarn test --config ./jest.config.js
working-directory: rnexample
- run: npx --yes check-peer-dependencies --yarn --runOnlyOnRootDependencies
working-directory: rnexample
test-npm:
needs: build
runs-on: ubuntu-latest
outputs:
rn-version: ${{ steps.rn-version.outputs.value }}
steps:
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- run: npx react-native init rnexample
- id: rn-version
working-directory: rnexample
run: |
RN_VERSION=$(cat package.json | jq ".dependencies.\"react-native\"" -r)
echo "value=${RN_VERSION}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
path: rnexample/react-native-hcaptcha
- name: Run npm install ...
working-directory: rnexample
run: |
npm i --save file:./react-native-hcaptcha
npm i --save --include=dev ${{ env.TEST_APP_DEV_DEPS }}
npm i --save ${{ env.TEST_APP_DEPS }}
cp ./react-native-hcaptcha/Example.App.js App.js
cp ./react-native-hcaptcha/Example.jest.config.js jest.config.js
- run: |
mkdir -p android/app/src/main/assets
mkdir -p android/app/src/main/res
npx react-native bundle ${{ env.RN_BUNDLE_ARGS }}
working-directory: rnexample
- run: cat package.json
working-directory: rnexample
- run: npm run test -- --config ./jest.config.js
working-directory: rnexample
- run: npx --yes check-peer-dependencies --npm --runOnlyOnRootDependencies
working-directory: rnexample
- run: |
echo "org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m" >> gradle.properties
./gradlew assemble
working-directory: rnexample/android
- uses: actions/upload-artifact@v4
with:
name: apks
path: rnexample/android/app/build/outputs/apk/release/app-release.apk
create-an-issue:
runs-on: ubuntu-latest
needs: [test-npm, test-yarn]
if: always() && github.event == 'schedule' && (needs.test-npm.result == 'failure' || needs.test-yarn.result == 'failure')
steps:
- uses: actions/checkout@v4
- run: |
RN_VERSION="${{ needs.test-npm.outputs.rn-version || needs.test-yarn.outputs.rn-version }}"
GHA_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
echo "RN_VERSION=${RN_VERSION}" >> $GITHUB_ENV
echo "GHA_RUN_URL=${GHA_RUN_URL}" >> $GITHUB_ENV
- uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
assignees: CAMOBAP
update_existing: true
filename: .github/examples-issue-template.md
release:
if: github.event_name == 'release'
needs: [test-npm, test-yarn]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: npm release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm ci
npm publish