Skip to content

Commit

Permalink
test: add install testing script to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Feb 4, 2025
1 parent 356a10a commit cdc379e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,18 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test-as-dependency:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: yarn
- name: Yarn
run: yarn
- name: Test install in other package
run: ./scripts/test-package/run.sh
14 changes: 11 additions & 3 deletions scripts/test-package/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
set -e

TEST_DIR="test-package"

mkdir "$TEST_DIR"

cp scripts/test-package/test-tsconfig.json "$TEST_DIR/tsconfig.json"
cp scripts/test-package/test-package.json "$TEST_DIR/package.json"
cd "$TEST_DIR"
npm install --install-links
mkdir src
echo -e "import { Unleash } from 'unleash-client';\nvoid Unleash;\nconsole.log('Hello world');" > src/index.ts
./node_modules/.bin/tsc -b tsconfig.json
cd ..
rm -rf "$TEST_DIR"

if [ "$(node . 2>&1)" = "Hello world" ]; then
echo "Output is correct"
(cd .. && rm -rf "$TEST_DIR")
else
echo "Output is incorrect" >&2
echo $(node . 2>&1)
(cd .. && rm -rf "$TEST_DIR")
exit 1
fi

0 comments on commit cdc379e

Please sign in to comment.