Skip to content

Commit

Permalink
[CI] Move machines to M1 for 0.72
Browse files Browse the repository at this point in the history
  • Loading branch information
cipolleschi committed Jun 28, 2024
1 parent e24be30 commit 92a0b45
Show file tree
Hide file tree
Showing 86 changed files with 5,453 additions and 21 deletions.
44 changes: 23 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ references:

cache_keys:
checkout_cache_key: &checkout_cache_key v1-checkout
gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }}
gems_cache_key: &gems_cache_key v1-gems-{{ arch }}-{{ checksum "Gemfile.lock" }}
gradle_cache_key: &gradle_cache_key v1-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "packages/react-native/ReactAndroid/gradle.properties" }}
hermes_workspace_cache_key: &hermes_workspace_cache_key v4-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_linux_cache_key: &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
pods_cache_key: &pods_cache_key v8-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ arch }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ arch }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
pods_cache_key: &pods_cache_key v8-pods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
windows_yarn_cache_key: &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
yarn_cache_key: &yarn_cache_key v5-yarn-cache-{{ .Environment.CIRCLE_JOB }}
rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ checksum "/tmp/required_ruby" }}
rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ arch }}-{{ checksum "/tmp/required_ruby" }}

cache_paths:
hermes_workspace_macos_cache_paths: &hermes_workspace_macos_cache_paths
Expand Down Expand Up @@ -128,7 +128,7 @@ executors:
<<: *defaults
macos:
xcode: *xcode_version
resource_class: macos.x86.medium.gen2
resource_class: macos.m1.medium.gen1
environment:
- RCT_BUILD_HERMES_FROM_SOURCE: true

Expand Down Expand Up @@ -171,7 +171,7 @@ commands:
- restore_cache:
key: *rbenv_cache_key
- run:
name: Bundle Install
name: Install the proper Ruby and run Bundle install
command: |
# Check if rbenv is installed. CircleCI is migrating to rbenv so we may not need to always install it.
Expand Down Expand Up @@ -202,8 +202,10 @@ commands:
# Set ruby dependencies
rbenv global << parameters.ruby_version >>
if [[ $(echo << parameters.ruby_version >> | awk -F'.' '{print $1}') == "2" ]]; then
rbenv rehash
gem install bundler -v 2.4.22
else
rbenv rehash
gem install bundler
fi
bundle check || bundle install --path vendor/bundle --clean
Expand Down Expand Up @@ -1582,15 +1584,15 @@ workflows:
- test_ios_template:
requires:
- build_npm_package
name: "Test Template with Ruby 2.7.7"
ruby_version: "2.7.7"
name: "Test Template with Ruby 2.7.8"
ruby_version: "2.7.8"
architecture: "NewArch"
flavor: "Debug"
- test_ios_template:
requires:
- build_npm_package
name: "Test Template with Ruby 3.2.0"
ruby_version: "3.2.0"
name: "Test Template with Ruby 3.2.2"
ruby_version: "3.2.2"
architecture: "NewArch"
flavor: "Debug"
- test_ios_template:
Expand Down Expand Up @@ -1727,14 +1729,14 @@ workflows:
- test_ios_rntester:
requires:
- build_hermes_macos
name: "Test RNTester with Ruby 2.7.7"
ruby_version: "2.7.7"
name: "Test RNTester with Ruby 2.7.8"
ruby_version: "2.7.8"
architecture: "NewArch"
- test_ios_rntester:
requires:
- build_hermes_macos
name: "Test RNTester with Ruby 3.2.0"
ruby_version: "3.2.0"
name: "Test RNTester with Ruby 3.2.2"
ruby_version: "3.2.2"
architecture: "NewArch"
- test_ios_rntester:
requires:
Expand All @@ -1744,17 +1746,17 @@ workflows:
architecture: ["NewArch", "OldArch"]
jsengine: ["Hermes", "JSC"]
- test_ios:
name: "Test iOS with Ruby 2.7.7"
name: "Test iOS with Ruby 2.7.8"
run_unit_tests: true
requires:
- build_hermes_macos
ruby_version: "2.7.7"
ruby_version: "2.7.8"
- test_ios:
name: "Test iOS with Ruby 3.2.0"
name: "Test iOS with Ruby 3.2.2"
run_unit_tests: true
requires:
- build_hermes_macos
ruby_version: "3.2.0"
ruby_version: "3.2.2"
- test_ios:
run_unit_tests: true
requires:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.cleanAssetCatalog = cleanAssetCatalog;
exports.getImageSet = getImageSet;
exports.isCatalogAsset = isCatalogAsset;
exports.writeImageSet = writeImageSet;
var _assetPathUtils = _interopRequireDefault(require("./assetPathUtils"));
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/

function cleanAssetCatalog(catalogDir) {
const files = _fs.default
.readdirSync(catalogDir)
.filter((file) => file.endsWith(".imageset"));
for (const file of files) {
_fs.default.rmSync(_path.default.join(catalogDir, file), {
recursive: true,
force: true,
});
}
}
function getImageSet(catalogDir, asset, scales) {
const fileName = _assetPathUtils.default.getResourceIdentifier(asset);
return {
basePath: _path.default.join(catalogDir, `${fileName}.imageset`),
files: scales.map((scale, idx) => {
const suffix = scale === 1 ? "" : `@${scale}x`;
return {
name: `${fileName + suffix}.${asset.type}`,
scale,
src: asset.files[idx],
};
}),
};
}
function isCatalogAsset(asset) {
return asset.type === "png" || asset.type === "jpg" || asset.type === "jpeg";
}
function writeImageSet(imageSet) {
_fs.default.mkdirSync(imageSet.basePath, {
recursive: true,
});
for (const file of imageSet.files) {
const dest = _path.default.join(imageSet.basePath, file.name);
_fs.default.copyFileSync(file.src, dest);
}
_fs.default.writeFileSync(
_path.default.join(imageSet.basePath, "Contents.json"),
JSON.stringify({
images: imageSet.files.map((file) => ({
filename: file.name,
idiom: "universal",
scale: `${file.scale}x`,
})),
info: {
author: "xcode",
version: 1,
},
})
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/

import type { AssetData } from "metro/src/Assets";

declare export function cleanAssetCatalog(catalogDir: string): void;

type ImageSet = {
basePath: string,
files: { name: string, src: string, scale: number }[],
};

declare export function getImageSet(
catalogDir: string,
asset: AssetData,
scales: $ReadOnlyArray<number>
): ImageSet;

declare export function isCatalogAsset(asset: AssetData): boolean;

declare export function writeImageSet(imageSet: ImageSet): void;
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/

/**
* FIXME: using number to represent discrete scale numbers is fragile in essence because of
* floating point numbers imprecision.
*/
function getAndroidAssetSuffix(scale) {
switch (scale) {
case 0.75:
return "ldpi";
case 1:
return "mdpi";
case 1.5:
return "hdpi";
case 2:
return "xhdpi";
case 3:
return "xxhdpi";
case 4:
return "xxxhdpi";
default:
return "";
}
}

// See https://developer.android.com/guide/topics/resources/drawable-resource.html
const drawableFileTypes = new Set(["gif", "jpeg", "jpg", "png", "webp", "xml"]);
function getAndroidResourceFolderName(asset, scale) {
if (!drawableFileTypes.has(asset.type)) {
return "raw";
}
const suffix = getAndroidAssetSuffix(scale);
if (!suffix) {
throw new Error(
`Don't know which android drawable suffix to use for asset: ${JSON.stringify(
asset
)}`
);
}
return `drawable-${suffix}`;
}
function getResourceIdentifier(asset) {
const folderPath = getBasePath(asset);
return `${folderPath}/${asset.name}`
.toLowerCase()
.replace(/\//g, "_") // Encode folder structure in file name
.replace(/([^a-z0-9_])/g, "") // Remove illegal chars
.replace(/^assets_/, ""); // Remove "assets_" prefix
}

function getBasePath(asset) {
let basePath = asset.httpServerLocation;
if (basePath[0] === "/") {
basePath = basePath.substr(1);
}
return basePath;
}
var _default = {
getAndroidAssetSuffix,
getAndroidResourceFolderName,
getResourceIdentifier,
getBasePath,
};
exports.default = _default;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/

export type PackagerAsset = $ReadOnly<{
httpServerLocation: string,
name: string,
type: string,
...
}>;

/**
* FIXME: using number to represent discrete scale numbers is fragile in essence because of
* floating point numbers imprecision.
*/
declare function getAndroidAssetSuffix(scale: number): string;

declare function getAndroidResourceFolderName(
asset: PackagerAsset,
scale: number
): string;

declare function getResourceIdentifier(asset: PackagerAsset): string;

declare function getBasePath(asset: PackagerAsset): string;

declare export default {
getAndroidAssetSuffix: getAndroidAssetSuffix,
getAndroidResourceFolderName: getAndroidResourceFolderName,
getResourceIdentifier: getResourceIdentifier,
getBasePath: getBasePath,
};
Loading

0 comments on commit 92a0b45

Please sign in to comment.