Skip to content

Commit

Permalink
chore: Enable linting Pods and re-organize setup.mjs file (#10880)
Browse files Browse the repository at this point in the history
## **Description**

This PR refactors setup.mjs file with the purpose of:
1. Moves Gemfile into iOS directory, which is where it belongs since it
only relates to iOS. We also updated everywhere that calls bundle
install or exec so it's calling it in the ios directory
2. Run pod install in CI for detecting diffs in Podfile.lock

Because we're now running pod install in the CI, the total `ci.yml` job
time will take longer. However, it still completes before some other
tasks such as unit tests. And since it runs in parallel to those, we
should not see an increase in total CI run time.

## **Related issues**

- #11293
- #9789

## **Manual testing steps**

- Running `yarn setup` still works normally when run locally
- CI passes when run
- CI fails when Podfile.lock is changed when pod install runs in the CI

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

Example of pod file diff detected

https://github.com/MetaMask/metamask-mobile/actions/runs/10746121351/job/29806449687?pr=10880

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: legobt <6wbvkn0j@anonaddy.me>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 24, 2024
1 parent 2eb1116 commit d2d4dee
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 177 deletions.
2 changes: 2 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ignores:
- 'webpack-cli'
- '@react-native-community/datetimepicker'
- '@react-native-community/slider'
- 'patch-package'
- '@lavamoat/allow-scripts'
# This is used on the patch for TokenRatesController of Assets controllers, for we to be able to use the last version of it
- cockatiel

Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ on:
pull_request:
merge_group:
types: [checks_requested]

jobs:
setup:
runs-on: ubuntu-20.04
check-diff:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: yarn
- uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 #v1
with:
ruby-version: '3.1.5'
bundler-cache: true
env:
BUNDLE_GEMFILE: ios/Gemfile
- name: Determine whether the current PR is a draft
id: set-is-draft
if: github.event_name == 'pull_request' && github.event.pull_request.number
Expand All @@ -27,7 +33,7 @@ jobs:
run: printf '%s\n\n%s' '@metamask:registry=https://npm.pkg.github.com' "//npm.pkg.github.com/:_authToken=${PACKAGE_READ_TOKEN}" > .npmrc
env:
PACKAGE_READ_TOKEN: ${{ secrets.PACKAGE_READ_TOKEN }}
- run: yarn setup --node
- run: yarn setup
- name: Require clean working directory
shell: bash
run: |
Expand All @@ -39,7 +45,6 @@ jobs:
fi
dedupe:
runs-on: ubuntu-20.04
needs: setup
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -58,7 +63,6 @@ jobs:
fi
scripts:
runs-on: ubuntu-20.04
needs: setup
strategy:
matrix:
scripts:
Expand Down Expand Up @@ -86,7 +90,6 @@ jobs:
fi
unit-tests:
runs-on: ubuntu-20.04
needs: setup
strategy:
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Expand Down Expand Up @@ -156,7 +159,6 @@ jobs:
js-bundle-size-check:
runs-on: ubuntu-20.04
needs: setup
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down Expand Up @@ -270,7 +272,7 @@ jobs:
runs-on: ubuntu-20.04
needs:
[
setup,
check-diff,
dedupe,
scripts,
unit-tests,
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ on:
branches: main
pull_request:


jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3

- uses: actions/checkout@v3

- name: Build and load
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
with:
context: .
file: scripts/docker/Dockerfile
Expand Down
10 changes: 0 additions & 10 deletions Gemfile

This file was deleted.

2 changes: 1 addition & 1 deletion bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ workflows:
- content: |-
#!/usr/bin/env bash
echo "Gems being installed with bundler gem"
bundle install
bundle install --gemfile=ios/Gemfile
echo "Node $NODE_VERSION being installed"
set -e
Expand Down
2 changes: 1 addition & 1 deletion docs/readme/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Install ruby version defined in the file `.ruby-version`
Install [`bundler`](https://bundler.io/) gem to manage and install gems such as Cocoapods. The `bundle install` command, which is run during `yarn setup` handles installing gem versions as specified in the project's `GemFile`

```bash
gem install bundler -v 2.5.8 && bundle install
gem install bundler -v 2.5.8 && bundle install --gemfile=ios/Gemfile
```

### Xcode
Expand Down
11 changes: 7 additions & 4 deletions ios/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true
source 'https://rubygems.org'

source "https://rubygems.org"
# Recommended to use http://rbenv.org/ to install and use this version
ruby '>= 3.1.5'

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# Allow minor version updates up to but excluding 2.0.0
gem 'cocoapods', '~> 1.12'

# gem "rails"
# Allow all version updates up to but excluding 7.1.0
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
File renamed without changes.
12 changes: 2 additions & 10 deletions ios/MetaMask.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1555,11 +1555,7 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
};
Expand Down Expand Up @@ -1603,11 +1599,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
5 changes: 0 additions & 5 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ def common_target_logic
# use_frameworks!
pod 'Permission-BluetoothPeripheral', :path => '../node_modules/react-native-permissions/ios/BluetoothPeripheral'
pod 'GzipSwift'

# Adding OpenSSL-Universal to fix build issues in react-native-quick-crypto
# Ref: https://github.com/margelo/react-native-quick-crypto/issues/121
# Ref: https://stackoverflow.com/questions/29082174/ios-xcode-build-failing-due-to-openssl/76455587#76455587
pod 'OpenSSL-Universal', :modular_headers => true, :configurations => ['Release']
end

target 'MetaMask' do
Expand Down
3 changes: 1 addition & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ DEPENDENCIES:
- GzipSwift
- lottie-ios (from `../node_modules/lottie-ios`)
- lottie-react-native (from `../node_modules/lottie-react-native`)
- OpenSSL-Universal
- OpenSSL-Universal (= 1.1.1100)
- Permission-BluetoothPeripheral (from `../node_modules/react-native-permissions/ios/BluetoothPeripheral`)
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
Expand Down Expand Up @@ -1303,6 +1302,6 @@ SPEC CHECKSUMS:
Yoga: 6f5ab94cd8b1ecd04b6e973d0bc583ede2a598cc
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 3514934ac1830af4ca844ba018f38720a48d006b
PODFILE CHECKSUM: 0e9407472193b5f7d5cfe4715c8f1f2c2fed42e5

COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"watch:clean": "./scripts/build.sh watcher clean",
"clean:ios": "rm -rf ios/build",
"pod:install": "command -v pod && bundle exec pod install --project-directory=ios || echo \"pod command not found. Skipping pod install\"",
"gem:bundle:install": "bundle install --gemfile=ios/Gemfile",
"clean:ppom": "rm -rf ppom/dist ppom/node_modules app/lib/ppom/ppom.html.js",
"clean:android": "rm -rf android/app/build",
"clean:node": "rm -rf node_modules && yarn --frozen-lockfile",
Expand All @@ -18,7 +19,6 @@
"lint:tsc": "tsc --project ./tsconfig.json",
"format": "prettier '**/*.{js,ts,tsx,json,feature}' --write",
"setup": "yarn clean && node scripts/setup.mjs",
"setup:node": "yarn allow-scripts && yarn patch-package",
"setup:e2e": "cd wdio && yarn install",
"setup:detox-e2e": "./scripts/detox-setup.sh",
"start:ios": "./scripts/build.sh ios debug",
Expand Down
9 changes: 6 additions & 3 deletions scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN bash -c "[ ${GID} != \"1000\" ] && groupadd -g ${GID} -U node userz || true
&& echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

# install ruby deps
COPY --chown=${UID}:${GID} Gemfile* .ruby-version /tmp/app/
COPY --chown=${UID}:${GID} ios/Gemfile* .ruby-version /tmp/app/
WORKDIR /tmp/app

####
Expand All @@ -58,7 +58,10 @@ RUN bash -c 'eval "$(/home/node/.rbenv/bin/rbenv init -)" \
&& bundle install'

# fix broken ipv6 on nodejs v20
env NODE_OPTIONS="--no-network-family-autoselection --trace-warnings"
env PATH=/home/node/.rbenv/shims/:$PATH
ENV NODE_OPTIONS="--no-network-family-autoselection --trace-warnings"
# minimize ruby memory usage
ENV MALLOC_ARENA_MAX=1
ENV PATH=/home/node/.rbenv/shims/:$PATH
ENV LANG=en_US.UTF-8

WORKDIR /app
Loading

0 comments on commit d2d4dee

Please sign in to comment.