mirror of
https://github.com/wasp-lang/open-saas.git
synced 2025-05-12 05:10:11 +02:00
Added check for demo app patching to CI. (#206)
* Added check for demo app patching to CI. * fix
This commit is contained in:
parent
471217ba92
commit
f100fbd552
37
.github/workflows/e2e-tests.yml
vendored
37
.github/workflows/e2e-tests.yml
vendored
@ -26,11 +26,19 @@ jobs:
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Docker setup
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Install Wasp
|
||||
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v ${{ env.WASP_VERSION }}
|
||||
|
||||
- name: Docker setup
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Cache global node modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: node-modules-${{ runner.os }}-${{ hashFiles('template/app/package-lock.json') }}-${{ hashFiles('template/e2e-tests/package-lock.json') }}-wasp${{ env.WASP_VERSION }}-node${{ steps.setup-node.outputs.node-version }}
|
||||
restore-keys: |
|
||||
node-modules-${{ runner.os }}-
|
||||
|
||||
# In order for the app to run in the dev mode we need to set the required env vars even if
|
||||
# they aren't actually used by the app. This step sets mock env vars in order to pass the
|
||||
@ -43,22 +51,19 @@ jobs:
|
||||
cd app
|
||||
cp .env.server.example .env.server && cp .env.client.example .env.client
|
||||
|
||||
- name: Cache global node modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: node-modules-${{ runner.os }}-${{ hashFiles('template/app/package-lock.json') }}-${{ hashFiles('template/e2e-tests/package-lock.json') }}-wasp${{ env.WASP_VERSION }}-node${{ steps.setup-node.outputs.node-version }}
|
||||
restore-keys: |
|
||||
node-modules-${{ runner.os }}-
|
||||
- name: Check that patching demo app (opensaas-sh) works
|
||||
working-directory: ./opensaas-sh
|
||||
run: |
|
||||
./tools/patch.sh
|
||||
|
||||
- name: Install Node.js dependencies for Playwright tests
|
||||
- name: "[e2e-tests] Install Node.js dependencies for Playwright tests"
|
||||
if: steps.cache-e2e-tests.outputs.cache-hit != 'true'
|
||||
working-directory: ./template
|
||||
run: |
|
||||
cd e2e-tests
|
||||
npm ci
|
||||
|
||||
- name: Store Playwright's Version
|
||||
- name: "[e2e-tests] Store Playwright's Version"
|
||||
working-directory: ./template
|
||||
run: |
|
||||
cd e2e-tests
|
||||
@ -66,21 +71,21 @@ jobs:
|
||||
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
|
||||
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache Playwright Browsers for Playwright's Version
|
||||
- name: "[e2e-tests] Cache Playwright Browsers for Playwright's Version"
|
||||
id: cache-playwright-browsers
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}-${{ runner.os }}
|
||||
|
||||
- name: Set up Playwright
|
||||
- name: "[e2e-tests] Set up Playwright"
|
||||
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
|
||||
working-directory: ./template
|
||||
run: |
|
||||
cd e2e-tests
|
||||
npx playwright install --with-deps
|
||||
|
||||
- name: Install Stripe CLI
|
||||
- name: "[e2e-tests] Install Stripe CLI"
|
||||
run: |
|
||||
curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | sudo tee /usr/share/keyrings/stripe.gpg
|
||||
echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | sudo tee -a /etc/apt/sources.list.d/stripe.list
|
||||
@ -90,13 +95,13 @@ jobs:
|
||||
# For Stripe webhooks to work in development, we need to run the Stripe CLI to listen for webhook events.
|
||||
# The Stripe CLI will receive the webhook events from Stripe test payments and
|
||||
# forward them to our local server so that we can test the payment flow in our e2e tests.
|
||||
- name: Run Stripe CLI to listen for webhooks
|
||||
- name: "[e2e-tests] Run Stripe CLI to listen for webhooks"
|
||||
env:
|
||||
STRIPE_DEVICE_NAME: ${{ secrets.STRIPE_DEVICE_NAME }}
|
||||
run: |
|
||||
stripe listen --api-key ${{ secrets.STRIPE_KEY }} --forward-to localhost:3001/stripe-webhook &
|
||||
|
||||
- name: Run Playwright tests
|
||||
- name: "[e2e-tests] Run Playwright tests"
|
||||
env:
|
||||
# The e2e tests are testing parts of the app that need certain env vars, so we need to access them here.
|
||||
# These secretes can be set in your GitHub repo settings, e.g. https://github.com/<account>/<repo>/settings/secrets/actions
|
||||
|
@ -83,7 +83,9 @@ recreate_derived_dir() {
|
||||
done <<< "${BASE_FILES}"
|
||||
|
||||
# For each .diff file in diff dir, apply the patch to the corresponding base file in the derived dir.
|
||||
find "${DIFF_DIR}" -name "*.diff" | while IFS= read -r diff_filepath; do
|
||||
#local num_patches_failed
|
||||
local num_patches_failed=0
|
||||
while IFS= read -r diff_filepath; do
|
||||
local derived_filepath
|
||||
derived_filepath="${diff_filepath#${DIFF_DIR}/}"
|
||||
derived_filepath="${derived_filepath%.diff}"
|
||||
@ -98,9 +100,10 @@ recreate_derived_dir() {
|
||||
else
|
||||
echo "${patch_output}"
|
||||
echo -e "${RED_COLOR}[Failed with exit code ${patch_exit_code}]${RESET_COLOR}"
|
||||
num_patches_failed=$((num_patches_failed + 1))
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
done < <(find "${DIFF_DIR}" -name "*.diff")
|
||||
|
||||
# Delete any files that exist in the base dir but shouldn't exist in the derived dir.
|
||||
# TODO: also allow deletion of dirs.
|
||||
@ -123,6 +126,14 @@ recreate_derived_dir() {
|
||||
fi
|
||||
|
||||
echo "DONE: generated ${DERIVED_DIR}/"
|
||||
|
||||
if [ ${num_patches_failed} -gt 0 ]; then
|
||||
echo -e "${RED_COLOR}${num_patches_failed} patches failed, look into generated files for merge conflicts.${RESET_COLOR}"
|
||||
exit 1;
|
||||
else
|
||||
echo -e "${GREEN_COLOR}All patches successfully applied.${RESET_COLOR}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
if [ "$ACTION" == "diff" ]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user