Skip to content

Commit

Permalink
ci: restructure setup
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiKilian committed Nov 24, 2024
1 parent cab6e95 commit 872c101
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,27 @@ name: Android Build

on:
workflow_call:
inputs:
NVMRC:
required: true
type: string

jobs:
build_example:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./packages/react-native-app

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup node ${{ inputs.NVMRC }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NVMRC }}
- name: Setup
uses: ./.github/actions/setup

- name: Setup JDK zulu 17
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "17"

- name: Enable Corepack
run: corepack enable

- run: yarn install --immutable --check-cache
working-directory: packages/react-native-app

- run: ./gradlew assemble
working-directory: packages/react-native-app/android
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ name: iOS Build & Detox

on:
workflow_call:
inputs:
NVMRC:
required: true
type: string

jobs:
build:
runs-on: macos-latest
timeout-minutes: 45 # Figure out why this job can be super slow; runner hardware?
timeout-minutes: 30

defaults:
run:
Expand All @@ -20,16 +16,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup node ${{ inputs.NVMRC }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NVMRC }}

- name: Enable Corepack
run: corepack enable

- name: Install Yarn Dependencies
run: yarn install --immutable --check-cache
- name: Setup
uses: ./.github/actions/setup

- name: Install Pod Dependencies
run: cd ios && pod --version && pod install
Expand Down
32 changes: 32 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Setup
description: Setup Node.js and install dependencies

inputs:
registry-url:
description: Optional registry to set up for auth.

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
registry-url: ${{ inputs.registry-url }}

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v4
with:
path: |
**/node_modules
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
shell: bash
File renamed without changes.
84 changes: 0 additions & 84 deletions .github/workflows/on-push.yml

This file was deleted.

100 changes: 100 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Review

on:
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
types:
- checks_requested

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Lint with ESLint
run: yarn lint:eslint

- name: Lint with TSC
run: yarn lint:tsc

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Test with Jest
run: yarn test

codegen:
name: Codegen
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Codegen
run: yarn codegen

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Build
run: yarn prepack

android:
name: Android
needs: [lint, test, codegen, build]
uses: ./.github/actions/android/action.yml

ios:
name: iOS
needs: [lint, test, codegen, build]
uses: ./.github/actions/ios/action.yml

publish:
name: Publish
if: startsWith(github.ref, 'refs/tags/')
needs: [lint, test, codegen, build, android, ios]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
with:
registry-url: https://registry.npmjs.org/

- name: Setup .yarnrc.yml
run: yarn config set npmAuthToken $NPM_AUTH_TOKEN
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}

- name: Publish
run: yarn npm publish
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.12.1
22.11.0
1 change: 0 additions & 1 deletion packages/react-native-app/.nvmrc

This file was deleted.

0 comments on commit 872c101

Please sign in to comment.