Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: make bundle compatible with Windows and test it in CI #344

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ jobs:
echo The zipped WordPress plugin packages/web-component/wordpress-plugin/read-along-web-app-loader.zip is out of date.; \
false; \
fi
- name: make sure bundling works
shell: bash
run: |
npx nx bundle web-component
git status
git diff --word-diff=porcelain --word-diff-regex=... --color | perl -ple 's/^(\x1b[^ -+]{0,6})? (.{81,})$/$1 . " " . substr($2, 0, 40) . " [... " . (length($2)-80) . " bytes ...] " . substr($2, -40)/ex'
6 changes: 1 addition & 5 deletions .github/workflows/windows-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,4 @@ jobs:
- run: npx nx check-l10n studio-web
- run: npx nx build ngx-web-component
- run: npx nx build studio-web

# bundle only works in Git Bash on Windows, so don't exercise it here, we know it'll fail.
#- run: npx nx bundle web-component
# shell: bash
# continue-on-error: true
- run: npx nx bundle web-component
15 changes: 15 additions & 0 deletions packages/web-component/bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# This script is used to bundle the web component for including in Offline HTML files
# created by studio-web

set -o errexit
set -o verbose

node b64Fonts.js
npx webpack --config webpack.config.js
packageVersion=$(npm view ../../node_modules/@readalongs/web-component version)
timestamp=$(date "+%Y-%m-%d+%H-%M-%S")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing that if you have bash on Windows then you also have date?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, once you're in bash, you get the standard *nix command line tools, even on Windows, through msys, mingw64, cygwin or some derivative. I'm not aware of any instance of bash on Windows that's not based on one of those. Git systematically comes with Git Bash on Windows, that's the one I always use now, it's lightweight but has everything I need to make my Windows machine pleasant to use.

cd ../studio-web
npm pkg set singleFileBundleVersion="${packageVersion}"
npm pkg set singleFileBundleTimestamp="${timestamp}"
2 changes: 1 addition & 1 deletion packages/web-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dist/"
],
"scripts": {
"bundle": "node b64Fonts.js && webpack --config webpack.config.js; packageVersion=$(npm view ../../node_modules/@readalongs/web-component version); timestamp=$(date \"+%Y-%m-%d+%H-%M-%S\") && cd ../studio-web && npm pkg set singleFileBundleVersion=\"${packageVersion}\" && npm pkg set singleFileBundleTimestamp=\"${timestamp}\"",
"bundle": "bash bundle.sh",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, that's ... much nicer looking

"cy:run": "cypress run",
"test:full-pipeline": "npm run serve-test-data & nx run serve & npm run wait-for-test-server && npm run test:once",
"test:once": "cypress run",
Expand Down