Skip to content

CI

CI #176

Workflow file for this run

name: CI
on:
push:
branches: [ master ]
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@v3
- 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@v3
with:
path: react-native-hcaptcha
- 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 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:
- 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@v3
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: ./gradlew assemble
working-directory: rnexample/android
- uses: actions/upload-artifact@v3
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@v3
- 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