Skip to content

Commit 322264b

Browse files
committed
test(ci): extract package creation script from patch-package flow
this will be reused in other flows to create local packages prior to testing, for use in the testing
1 parent 7ae0872 commit 322264b

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

.github/workflows/create_test_patches.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,15 @@ jobs:
5959
# yarn3+ by default disables lockfile alteration in CI. We want it.
6060
YARN_ENABLE_IMMUTABLE_INSTALLS: false
6161
run: |
62-
PACKAGE_LIST=`find packages -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | egrep -v 'template|invites'`
63-
mkdir $HOME/packages
64-
for PACKAGE in $PACKAGE_LIST; do
65-
echo "Packing PR version of package $PACKAGE"
66-
pushd packages/$PACKAGE;
67-
yarn pack;
68-
mv package.tgz $HOME/packages/react-native-firebase-${PACKAGE}.tgz;
69-
ls -la $HOME/packages/*${PACKAGE}*
70-
popd;
71-
done
72-
ls -la $HOME/packages/
62+
./.github/workflows/scripts/create_npm_packages.sh ./packages $HOME/packages
7363
cd $HOME
7464
npx @react-native-community/cli init template --skip-install --skip-git-init
7565
cd template
7666
yarn
7767
yarn add patch-package --dev
7868
mkdir patches || true
79-
for PACKAGE in $PACKAGE_LIST; do
69+
PACKED_PACKAGE_LIST=`find $HOME/packages/ -maxdepth 1 -mindepth 1 -type f -exec basename -s .tgz {} \; | cut -d'-' -f4-10 | sort`
70+
for PACKAGE in $PACKED_PACKAGE_LIST; do
8071
echo "Installing package $PACKAGE into fresh template app, then clobbering with PR version"
8172
yarn add @react-native-firebase/$PACKAGE || true
8273
if [ -d node_modules/@react-native-firebase/$PACKAGE ]; then
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
SOURCE_PACKAGE_DIR="$1"
4+
TARGET_PACKAGE_DIR="$2"
5+
6+
echo "Creating local npm packages from source '${SOURCE_PACKAGE_DIR}' in '${TARGET_PACKAGE_DIR}'..."
7+
8+
# Make sure our target directory exists and is clean from previous runs
9+
if ! [ -d "${TARGET_PACKAGE_DIR}" ]; then
10+
mkdir "${TARGET_PACKAGE_DIR}"
11+
else
12+
rm -f "${TARGET_PACKAGE_DIR}"/*.tgz
13+
fi
14+
15+
if ! [ -d "${SOURCE_PACKAGE_DIR}" ]; then
16+
echo "Source package dir '${SOURCE_PACKAGE_DIR} not found."
17+
exit 1;
18+
fi
19+
20+
# Get our full list of packages, except any we specifically ignore
21+
IGNORED_PACKAGE_NAMES='template|invites'
22+
PACKAGE_LIST=`find ${SOURCE_PACKAGE_DIR} -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | egrep -v "${IGNORED_PACKAGE_NAMES}"`
23+
24+
# Pack up each package
25+
for PACKAGE in $PACKAGE_LIST; do
26+
echo "Creating package for $PACKAGE from local source"
27+
pushd "${SOURCE_PACKAGE_DIR}/${PACKAGE}";
28+
yarn pack;
29+
mv package.tgz "${TARGET_PACKAGE_DIR}/react-native-firebase-${PACKAGE}.tgz";
30+
ls -la "${TARGET_PACKAGE_DIR}/react-native-firebase-${PACKAGE}.tgz"
31+
popd;
32+
done
33+
ls -la "${TARGET_PACKAGE_DIR}"

0 commit comments

Comments
 (0)