Skip to content

Commit

Permalink
chore: add "smoke-test" bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Nov 2, 2023
1 parent 2c0cc57 commit ed4fb27
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 26 deletions.
27 changes: 2 additions & 25 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,5 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Override package.json version
run: |
COMMIT_HASH=$(git rev-parse HEAD)
echo "Latest commit: $COMMIT_HASH"
pnpm version $COMMIT_HASH
- name: Pack
run: pnpm pack

- name: Clone examples
run: git clone git@github.com:mswjs/examples.git

- name: Install example dependencies
working_directory: ./examples
run: pnpm install

- name: Link MSW build
working_directory: ./examples
run: |
pnpm link ../msw-$COMMIT_HASH.tgz
pnpm ls msw
- name: Tests
working_directory: ./examples
run: pnpm test
- name: Test examples
run: ./config/scripts/smoke-test.sh
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ stats.html
msw-*.tgz
.husky/_
.env
**/test-results
**/test-results

# Smoke test temporary files.
/package.json.copy
/examples
41 changes: 41 additions & 0 deletions config/scripts/smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -e

COMMIT_HASH=$(git rev-parse HEAD)
MSW_VERSION="0.0.0-$COMMIT_HASH"
echo "Latest commit: $COMMIT_HASH"
echo "In-progress MSW version: $MSW_VERSION"

PKG_JSON_COPY="package.json.copy"
cp package.json $PKG_JSON_COPY

pnpm version $MSW_VERSION --no-git-tag-version --allow-same-version

echo ""
echo "Packing MSW..."
pnpm pack

EXAMPLES_REPO=https://github.com/mswjs/examples.git
EXAMPLES_DIR=./examples
echo ""
echo "Cloning the examples from "$EXAMPLES_REPO"..."

if [[ -d "$EXAMPLES_DIR" ]]; then
echo "Examples already cloned, skipping..."
else
git clone $EXAMPLES_REPO $EXAMPLES_DIR
fi

echo ""
echo "Installing dependencies..."
cd $EXAMPLES_DIR
pnpm install

echo ""
echo "Linking MSW..."
pnpm add msw --filter="with-*" file:../../../msw-$MSW_VERSION.tgz
pnpm ls msw

echo ""
echo "Running tests..."
CI=1 pnpm test ; (cd ../ && mv $PKG_JSON_COPY ./package.json)

0 comments on commit ed4fb27

Please sign in to comment.