Skip to content

Commit

Permalink
Merge pull request #62 from berty/ci-checkout-modules
Browse files Browse the repository at this point in the history
fix(ci): checkout html git modules
  • Loading branch information
n0izn0iz authored Feb 16, 2022
2 parents a071544 + 388cba5 commit 978a286
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 33 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,38 @@ jobs:

- name: Install iOS app deps (node_modules)
working-directory: rn
run: make node_modules/.mkt
run: make node_modules

- name: Cache Gomobile framework
uses: n0izn0iz/mkache@5cedaeaf0b39a9220ae5a815cac8d2a924cee3ef
with:
rule: react-native-labs-bridge/ios/Labs.xcframework
makefile: rn/Makefile
key: ios-gomobile-labs-${{ matrix.golang }}

- name: Build Gomobile framework
working-directory: rn
run: make react-native-labs-bridge/ios/Labs.xcframework

- name: Install iOS app deps (XCode Workspace)
working-directory: rn
run: make ios/Pods/.mkt
run: make ios/Pods

# TODO: create action that automatically clones modules repos or use submodules

- name: Checkout ipfs-upload-file
uses: actions/checkout@v2
with:
repository: ipfs-examples/js-ipfs-http-client-upload-file
path: rn/html-mods/ipfs-upload-file/repo
ref: 44f4cd8bd0178e39e59eb8ab685dccecc4b64c89

- name: Checkout ipns-publish
uses: actions/checkout@v2
with:
repository: ipfs-examples/js-ipfs-browser-ipns-publish
path: rn/html-mods/ipns-publish/repo
ref: b5d5bf16236ad3052101e5893b9adcde332fbc23

- name: Build HTML Modules
working-directory: rn
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ clean.gen:
.PHONY: clean.gen

generate:
$(MAKE) -C rn node_modules/.mkt
$(MAKE) -C rn node_modules
buf generate api
set -e; for api in $$(ls api); do \
echo '/* eslint-disable no-dupe-class-members */' > rn/src/api/$${api}/v1/$${api}_pb_service.new.d.ts; \
Expand Down
22 changes: 13 additions & 9 deletions rn/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CI ?= false
CORE_PACKAGE = berty.tech/labs/go/bind/labs
IOS_CORE = react-native-labs-bridge/ios/Labs.xcframework
GO ?= go
go_srcs := $(call rwildcard,../go,*.go *.m *.h) ../go.sum

gomobile-ipfs-src=gomobile-ipfs/packages/build/ios/cocoapods
gomobile-ipfs-dst=ios/vendored_pods
Expand All @@ -32,13 +33,16 @@ html-mods.all:
### js

.PHONY: ios
ios: node_modules/.mkt ios/Pods/.mkt html-mods.all
ios: node_modules ios/Pods html-mods.all
npx react-native run-ios \
--port="$(METRO_RN_PORT)" \
$(if $(IOS_DEVICE),--udid='$(IOS_DEVICE)',) \
$(IOS_RN_FLAGS)

$(IOS_CORE): ../go.mod ../go.sum $(shell find ../go -name '*.go')
.PHONY: ios.core
ios.core: $(IOS_CORE)

$(IOS_CORE): $(go_srcs)
$(GO) run golang.org/x/mobile/cmd/gomobile init -v
CGO_CPPFLAGS=-DHAVE_GETHOSTUUID=0 $(GO) run golang.org/x/mobile/cmd/gomobile bind \
$(GOMOBILE_OPT) \
Expand All @@ -59,7 +63,7 @@ unlink:
cd react-native-labs-bridge && yarn unlink || true
rm -f .link

node_modules/.mkt: yarn.lock package.json $(wildcard patches/*)
node_modules: yarn.lock package.json $(wildcard patches/*)
$(MAKE) unlink
yarn $(if $(filter $(CI), true), --frozen-lockfile)
$(MAKE) .link
Expand All @@ -71,38 +75,38 @@ vendor/bundle: Gemfile Gemfile.lock
eval "$$(frum init)" && bundle install
touch $@

ios/Pods/.mkt: $(IOS_CORE) ios/Podfile ios/Podfile.lock node_modules/.mkt vendor/bundle
ios/Pods: $(IOS_CORE) ios/Podfile ios/Podfile.lock node_modules vendor/bundle
eval "$$(frum init)" && cd ios && bundle exec pod install --repo-update
touch $@

#### Android

.PHONY: android
android: node_modules/.mkt
android: node_modules
npx react-native run-android \
--port="$(METRO_RN_PORT)"

#### Lint

.PHONY: lint
lint: node_modules/.mkt
lint: node_modules
yarn lint
npx tsc

.PHONY: lint.fix
lint.fix: node_modules/.mkt
lint.fix: node_modules
yarn lint --fix
npx tsc

#### React-Native

.PHONY: metro.start
metro.start: node_modules/.mkt
metro.start: node_modules
npx react-native start --port=$(METRO_RN_PORT)


.PHONY: create-module
create-module: node_modules/.mkt
create-module: node_modules
SKIP_PREFLIGHT_CHECK=true npx ts-node -TH --files ./src/create-mod

.PHONY: clean
Expand Down
11 changes: 5 additions & 6 deletions rn/html-mods/ipfs-upload-file/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ BUNDLE_ROOT=$(RN_ROOT)/html-mods.bundle
BUILD_TARGET=$(BUNDLE_ROOT)/$(NAME)
INDEX_HTML=$(BUILD_TARGET)/index.html
REPO_ROOT=repo
NODE_MODULES_TARGET=$(REPO_ROOT)/node_modules/.mkt
REPO_TARGET=$(REPO_ROOT)/.mkt
NODE_MODULES=$(REPO_ROOT)/node_modules
DIST_DIR=$(REPO_ROOT)/dist

$(INDEX_HTML): $(REPO_TARGET) $(NODE_MODULES_TARGET) info.json
$(INDEX_HTML): $(REPO_ROOT) $(NODE_MODULES) info.json
rm -fr $(DIST_DIR)
cd $(REPO_ROOT) && npm run build

Expand All @@ -17,16 +16,16 @@ $(INDEX_HTML): $(REPO_TARGET) $(NODE_MODULES_TARGET) info.json
cp -r $(DIST_DIR) $(BUILD_TARGET)
cp info.json $(BUILD_TARGET)/info.json

$(REPO_TARGET): remote commit
$(REPO_ROOT): remote commit
rm -fr $(REPO_ROOT)
git clone $(shell cat remote) $(REPO_ROOT)
cd $(REPO_ROOT) && git checkout $(shell cat commit)
touch $@

$(NODE_MODULES_TARGET): $(REPO_TARGET) $(REPO_ROOT)/package.json
$(NODE_MODULES): $(REPO_ROOT) $(REPO_ROOT)/package.json
cd $(REPO_ROOT) && npm install
touch $@

dev: $(REPO_TARGET) $(NODE_MODULES_TARGET)
dev: $(REPO_ROOT) $(NODE_MODULES)
cd $(REPO_ROOT) && npm start
.PHONY: dev
11 changes: 5 additions & 6 deletions rn/html-mods/ipns-publish/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ BUNDLE_ROOT=$(RN_ROOT)/html-mods.bundle
BUILD_TARGET=$(BUNDLE_ROOT)/$(NAME)
INDEX_HTML=$(BUILD_TARGET)/index.html
REPO_ROOT=repo
NODE_MODULES_TARGET=$(REPO_ROOT)/node_modules/.mkt
REPO_TARGET=$(REPO_ROOT)/.mkt
NODE_MODULES=$(REPO_ROOT)/node_modules
DIST_DIR=$(REPO_ROOT)/dist

$(INDEX_HTML): $(REPO_TARGET) $(NODE_MODULES_TARGET) info.json
$(INDEX_HTML): $(REPO_ROOT) $(NODE_MODULES) info.json
rm -fr $(DIST_DIR)
cd $(REPO_ROOT) && npm run build

Expand All @@ -17,16 +16,16 @@ $(INDEX_HTML): $(REPO_TARGET) $(NODE_MODULES_TARGET) info.json
cp -r $(DIST_DIR) $(BUILD_TARGET)
cp info.json $(BUILD_TARGET)/info.json

$(REPO_TARGET): remote commit
$(REPO_ROOT): remote commit
rm -fr $(REPO_ROOT)
git clone $(shell cat remote) $(REPO_ROOT)
cd $(REPO_ROOT) && git checkout $(shell cat commit)
touch $@

$(NODE_MODULES_TARGET): $(REPO_TARGET) $(REPO_ROOT)/package.json
$(NODE_MODULES): $(REPO_ROOT) $(REPO_ROOT)/package.json
cd $(REPO_ROOT) && npm install
touch $@

dev: $(REPO_TARGET) $(NODE_MODULES_TARGET)
dev: $(REPO_ROOT) $(NODE_MODULES)
cd $(REPO_ROOT) && npm start
.PHONY: dev
2 changes: 1 addition & 1 deletion rn/html-mods/react-typescript/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RN_ROOT=../..
BUNDLE_ROOT=$(RN_ROOT)/html-mods.bundle
BUILD_TARGET=$(BUNDLE_ROOT)/$(NAME)
INDEX_HTML=$(BUILD_TARGET)/index.html
NODE_MODULES_TARGET=node_modules/.mkt
NODE_MODULES_TARGET=node_modules
DIST_DIR=build
SOURCES=$(shell find src public)

Expand Down
7 changes: 3 additions & 4 deletions rn/src/create-mod/presets/git/git.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ BUNDLE_ROOT=$(RN_ROOT)/html-mods.bundle
BUILD_TARGET=$(BUNDLE_ROOT)/$(NAME)
REPO_ROOT=<repoDir>
DIST_DIR=$(REPO_ROOT)/<distDir>
REPO_TARGET=$(REPO_ROOT)/.mkt

.PHONY: build
build: $(REPO_TARGET)
build: $(REPO_ROOT)
@echo --- Build Module ---
rm -fr $(DIST_DIR)
cd $(REPO_ROOT) && <buildCommand>
Expand All @@ -18,14 +17,14 @@ build: $(REPO_TARGET)
cp -r $(DIST_DIR) $(BUILD_TARGET)
cp info.json $(BUILD_TARGET)/info.json

$(REPO_TARGET): remote commit
$(REPO_ROOT): remote commit
@echo --- Clone repository ---
rm -fr $(REPO_ROOT)
git clone $(shell cat remote) $(REPO_ROOT)
cd $(REPO_ROOT) && git checkout $(shell cat commit)
touch $@

.PHONY: dev
dev: $(REPO_TARGET) $(NODE_MODULES_TARGET)
dev: $(REPO_ROOT) $(NODE_MODULES_TARGET)
@echo --- Start dev mode ---
cd $(REPO_ROOT) && <devCommand>
8 changes: 4 additions & 4 deletions rn/src/create-mod/presets/react/react.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ RN_ROOT=../..
BUNDLE_ROOT=$(RN_ROOT)/html-mods.bundle
BUILD_TARGET=$(BUNDLE_ROOT)/$(NAME)
INDEX_HTML=$(BUILD_TARGET)/index.html
NODE_MODULES_TARGET=node_modules/.mkt
NODE_MODULES=node_modules
DIST_DIR=build
SOURCES=$(shell find src public)

$(INDEX_HTML): $(NODE_MODULES_TARGET) $(SOURCES) info.json
$(INDEX_HTML): $(NODE_MODULES) $(SOURCES) info.json
@echo --- Build Module ---
rm -fr $(DIST_DIR)
npm run build
Expand All @@ -18,10 +18,10 @@ $(INDEX_HTML): $(NODE_MODULES_TARGET) $(SOURCES) info.json
cp -r $(DIST_DIR) $(BUILD_TARGET)
cp info.json $(BUILD_TARGET)/info.json

$(NODE_MODULES_TARGET): package.json
$(NODE_MODULES): package.json
npm install
touch $@

dev: $(NODE_MODULES_TARGET)
dev: $(NODE_MODULES)
npm start
.PHONY: dev

0 comments on commit 978a286

Please sign in to comment.