Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Expo v49 test fixture build #188

Merged
merged 14 commits into from
Jul 24, 2024
16 changes: 10 additions & 6 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
agents:
queue: "opensource"

steps:
#
# License audit
#
- label: ':copyright: License Audit'
timeout_in_minutes: 20
agents:
queue: opensource-arm-mac-cocoa-12
env:
DEVELOPER_DIR: "/Applications/Xcode13.app"
queue: "macos-14"
command: scripts/license_finder.sh

- label: ':android: Build expo APK'
key: "build-expo-apk"
timeout_in_minutes: 20
agents:
queue: "opensource-arm-mac-cocoa-12"
queue: "macos-14"
env:
EXPO_RELEASE_CHANNEL: ${BUILDKITE_BUILD_ID}
NODE_VERSION: "18.18"
JAVA_VERSION: "17"
artifact_paths: build/output.apk
commands:
- features/scripts/build-android.sh
Expand All @@ -25,10 +28,11 @@ steps:
key: "build-expo-ipa"
timeout_in_minutes: 20
agents:
queue: "opensource-arm-mac-cocoa-12"
queue: "macos-14"
env:
EXPO_RELEASE_CHANNEL: ${BUILDKITE_BUILD_ID}
DEVELOPER_DIR: "/Applications/Xcode14.app"
XCODE_VERSION: "15.3.0"
NODE_VERSION: "18.18"
artifact_paths: build/output.ipa
commands:
- bundle install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ compile_commands.json
.cache
.clangd
package-lock.json
yarn.lock
/config
31 changes: 24 additions & 7 deletions features/fixtures/test-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
npm-debug.*
web-build/

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
scenario.json
bugsnag-expo-*.tgz
android
ios
*.orig.*
web-build/

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo
4 changes: 2 additions & 2 deletions features/fixtures/test-app/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.bugsnag.expo.testfixture",
"bundleIdentifier": "com.bugsnag.expo.fixture",
"buildNumber": "1"
},
"android": {
"package": "com.bugsnag.expo.testfixture",
"package": "com.bugsnag.expo.fixture",
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
Expand Down
8 changes: 8 additions & 0 deletions features/fixtures/test-app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { registerRootComponent } from 'expo';

import App from './App';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);
30 changes: 18 additions & 12 deletions features/fixtures/test-app/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
const { getDefaultConfig } = require('@expo/metro-config');
const { getDefaultConfig } = require('expo/metro-config');
const path = require('path');

const defaultConfig = getDefaultConfig(__dirname);
// Find the project and workspace directories
const projectRoot = __dirname;
// This can be replaced with `find-yarn-workspace-root`
const workspaceRoot = path.resolve(projectRoot, '../../..');

defaultConfig.resolver.extraNodeModules = {
'expo': `${__dirname}/node_modules/expo`,
'expo-modules-core': `${__dirname}/node_modules/expo-modules-core`,
'react-native': `${__dirname}/node_modules/react-native`,
'react': `${__dirname}/node_modules/react`,
'@babel/runtime': `${__dirname}/node_modules/@babel/runtime`,
'promise': `${__dirname}/node_modules/promise`,
'@unimodules/core': `${__dirname}/node_modules/@unimodules/core`,
}
const config = getDefaultConfig(projectRoot);

module.exports = defaultConfig;
// 1. Watch all files within the monorepo
config.watchFolders = [workspaceRoot];
// 2. Let Metro know where to resolve packages and in what order
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, 'node_modules'),
path.resolve(workspaceRoot, 'node_modules'),
];
// 3. Force Metro to resolve (sub)dependencies only from the `nodeModulesPaths`
// config.resolver.disableHierarchicalLookup = true;

module.exports = config;
8 changes: 6 additions & 2 deletions features/fixtures/test-app/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "test-fixture",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"main": "index.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"@bugsnag/expo": "*",
"@react-native-community/netinfo": "9.3.10",
"expo": "^49.0.0",
"expo-application": "~5.3.0",
Expand All @@ -22,7 +23,10 @@
"react-native": "0.72.3"
},
"devDependencies": {
"@babel/core": "^7.20.0"
"@babel/core": "^7.20.0",
"@bugsnag/plugin-expo-eas-sourcemaps": "*",
"@bugsnag/source-maps": "^2.3.1",
"bugsnag-expo-cli": "*"
},
"private": true
}
21 changes: 4 additions & 17 deletions features/scripts/build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@ git clean -xfdf
# And the yarn cache is clean
yarn cache clean --all

# Install expo requirements
npm install

# Bump package versions to a high value so only our values will match
npx lerna version 999.999.999 --no-git-tag-version --no-push --no-changelog --yes

# Pack the packages and move them to the test fixture
npm pack packages/*/
mv *.tgz features/fixtures/test-app
# Install repo dependencies
yarn install

cd features/fixtures/test-app

# Install the bugsnag-expo-cli and run setup
npm install bugsnag-expo-cli*.tgz
# Set the api key via the CLI
./run-bugsnag-expo-cli

# Set EAS Project ID
Expand All @@ -29,13 +21,8 @@ sed -i '' "s/EXPO_EAS_PROJECT_ID/$EXPO_EAS_PROJECT_ID/g" app.json
# set bugsnag-js override versions if this build was triggered from the bugsnag-js repo
./set-bugsnag-js-overrides $BUGSNAG_JS_BRANCH $BUGSNAG_JS_COMMIT

# install the remaining packages, this also re-installs the correct @bugsnag/expo version
npm install *.tgz
npm install
yarn import

./run-bugsnag-expo-cli-install

cp $EXPO_UNIVERSAL_CREDENTIALS_DIR/* .
cp $EXPO_CREDENTIALS_DIR/* .

echo "Common setup complete"
6 changes: 6 additions & 0 deletions features/scripts/build-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ set -e

./features/scripts/build-common.sh

if [[ -z ${EAS_LOCAL_BUILD_WORKINGDIR:-} ]]; then
EAS_LOCAL_BUILD_WORKINGDIR=$BUILDKITE_BUILD_CHECKOUT_PATH/features/fixtures/build
export EAS_LOCAL_BUILD_WORKINGDIR
export EAS_LOCAL_BUILD_SKIP_CLEANUP=1
fi

pushd features/fixtures/test-app

eas build \
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@
"test:lint": "eslint --report-unused-disable-directives --max-warnings=0 .",
"local-npm:start": "verdaccio --config ./verdaccio-config.yml",
"local-npm:publish-all": "lerna publish --yes --force-publish --exact --no-push --no-git-reset --no-git-tag-version --registry 'http://localhost:4873'"
}
},
"private": true,
"workspaces": [
"packages/*", "features/fixtures/test-app"
]
}
Loading