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

Website infrastructure, WIP #1151

Merged
merged 40 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e76551f
🧩 [consolidate]: Each Standalone bundles to dist/example.
rolyp Oct 22, 2024
4954f5b
🧩 [add-unused]: Start on new bundle-page setup, but want special trea…
rolyp Oct 22, 2024
bad79a6
❗ [incomplete]: Progress but subfolders with spurious leading hyphen.
rolyp Oct 22, 2024
bcda733
🔧 [meta]: Discard purs-backend-es output for now.
rolyp Oct 22, 2024
0da8ef6
❗ [fix]: toLispCase helper.
rolyp Oct 22, 2024
bbc3e31
🧩 [consolidate]: Avoid duplicate processing of .purs/.html files.
rolyp Oct 22, 2024
cc6a9f2
🧩 [add-unused]: test-page-all, currently no tests though.
rolyp Oct 22, 2024
9a83af0
❗ [incomplete]: Migrate Fluid test (but doesn't work).
rolyp Oct 22, 2024
e652ac8
🧩 [consolidate]: Remove redundant stripping of prefix/suffix.
rolyp Oct 22, 2024
17f335e
❗ [fix]: Path to test module.
rolyp Oct 22, 2024
315e6ab
🧩 [refactor]: Extract bundle-website-new.sh.
rolyp Oct 22, 2024
866031d
🧩 [refactor]: Extract test-website.sh.
rolyp Oct 22, 2024
f28e994
❗ [fix]: Fix up Yarn scripts.
rolyp Oct 22, 2024
3f30b84
❗ [fix]: Various bits of progress but Puppeteer test paths wrong..
rolyp Oct 22, 2024
9c7734b
🧩 [doc] : Better output logging.
rolyp Oct 22, 2024
246da2a
❗ [fix]: First successful web test with new setup.
rolyp Oct 22, 2024
ee69a7c
❗ [fix]: ESOP25Artifact target.
rolyp Oct 22, 2024
6b1b7ed
❗ [fix]: build-fluid-org target.
rolyp Oct 22, 2024
7d46839
🧩 [remove-unused]: Old scripts.
rolyp Oct 22, 2024
0e68825
🧩 [consolidate]: Remove old stuff, just to create new Misc website now.
rolyp Oct 22, 2024
3097104
🧩 [new-test]: test-all runs test-website-all.
rolyp Oct 23, 2024
8004daa
🧩 [remove-unused]: Obsolete HTML files.
rolyp Oct 23, 2024
410a670
❗ [fix]: Dummy Misc.html required to get Misc included in build.
rolyp Oct 23, 2024
9c57838
🧩 [refactor]: Generalise test-website to look for folder rather than …
rolyp Oct 23, 2024
9e87cd6
❗ [incomplete]: WIP, minor consolidation of bundle-website/build/copy…
rolyp Oct 23, 2024
75f7e8a
🧩 [remove-unused]: Bunch of old stuff.
rolyp Oct 23, 2024
e1bf74b
❗ [fix]: Add WEBSITE argument to test-page for correct path resolution.
rolyp Oct 23, 2024
31a1b62
❗ [fix]: test-website deals with individual tests correctly.
rolyp Oct 23, 2024
f49f776
🧩 [consolidate]: Remove redundant build of FluidOrg, also don't need …
rolyp Oct 23, 2024
2a2ec63
❗ [fix]: Typo.
rolyp Oct 23, 2024
b9ea64e
🔧 [meta]: Merge develop.
rolyp Oct 31, 2024
2eba05e
🔧 [meta]: Enable more tracing.
rolyp Oct 31, 2024
8653630
🧩 [consolidate]: Extract toLispCase.
rolyp Nov 1, 2024
b99e66a
🧩 [move]: compile.sh and clean.sh to util.
rolyp Nov 1, 2024
027793a
🧩 [consolidate]: Invoke lisp-case in separate shell so it doesn't inh…
rolyp Nov 1, 2024
ff0eb42
🔧 [meta]: Discard stdout from purs-tidy.
rolyp Nov 1, 2024
1189afc
🧩 [consolidate]: Remove two unnecessary assignments.
rolyp Nov 1, 2024
8587145
❗ [fix]: Ah, problem was MacOS case insensitivity malarky again.
rolyp Nov 1, 2024
8f963c8
❗ [fix]: Ah, problem was MacOS case insensitivity malarky again.
rolyp Nov 1, 2024
6b964b4
❗ [fix]: Another case fix.
rolyp Nov 1, 2024
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
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ jobs:
- name: build
run: |
yarn install
yarn build-website
yarn build-fluid-org
- name: gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: dist/website
keep_files: true # student-projects and internships folders may exist in "release"
publish_dir: dist/fluid-org
keep_files: false

deploy-ESOP-artifact:
runs-on: ubuntu-22.04
Expand All @@ -59,10 +59,10 @@ jobs:
- name: build
run: |
yarn install
yarn build-ESOP-artifact
yarn build-esop2025-artifact
- name: gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: dist/ESOP-artifact
publish_dir: dist/esop2025-artifact
keep_files: false
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@
"tidy": "./script/tidy.sh",
"build": "./script/build.sh",
"build-test": "./script/build-test.sh",
"bundle-article": "./script/bundle-article.sh",
"bundle-bench": "./script/bundle-bench.sh",
"bundle-ESOP-artifact": "./script/bundle-ESOP-artifact.sh",
"bundle-standalone-all": "./script/bundle-standalone-all.sh",
"bundle-standalone": "./script/bundle-standalone.sh",
"serve-website": "./script/serve.sh website",
"serve-bench": "./script/serve.sh bench",
"bundle-page": "./script/bundle-page.sh",
"bundle-website": "./script/bundle-website.sh",
"bundle-website-all": "./script/bundle-website-all.sh",
"serve": "./script/serve.sh",
"test": "./script/test.sh",
"test-browser": "./script/test.sh --browsers=Chrome --singleRun=false",
"test-standalone": "./script/test-standalone.sh",
"test-standalone-all": "./script/test-standalone-all.sh",
"test-page": "./script/test-page.sh",
"test-website": "./script/test-website.sh",
"test-website-all": "./script/test-website-all.sh",
"test-all": "./script/test-all.sh",
"npm-publish": "./script/npm-publish.sh"
},
Expand Down
10 changes: 6 additions & 4 deletions puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ require('http-shutdown').extend();

const app = express();

app.use(serve(__dirname + '/dist/' + process.argv[3]));
const root = __dirname + '/dist/' + process.argv[3];
app.use(serve(root));

const server = app.listen(8080, function() {
console.log("Server running");
console.log("Serving content from " + root);
}).withShutdown();

(async () => {
try {
const testFile = process.argv[2]
import('./output-es/' + testFile + '/index.js').then(({ main }) => {
const module = process.argv[2]
console.log('Loading Puppeteer test module:', module);
import('./output-es/' + module + '/index.js').then(({ main }) => {
main().then(serverDown);
}).catch(err => {
console.error("Failed to load PureScript output:", err);
Expand Down
3 changes: 2 additions & 1 deletion script/build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
set -xe

yarn build
yarn bundle-standalone-all
yarn bundle-website Esop2025Artifact
yarn bundle-website Misc
yarn test-all
10 changes: 2 additions & 8 deletions script/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/usr/bin/env bash
set -xe

WEBSITE=website

rm -rf dist/
./script/compile.sh
./script/bundle-website.sh
./script/util/compile.sh
./script/bundle.sh test Test.Test
./script/util/copy-static.sh $WEBSITE
cp -r web/pdf dist/$WEBSITE

# Don't include standalone examples yet as they take a long time
./script/bundle-fluid-org.sh
14 changes: 0 additions & 14 deletions script/bundle-ESOP-artifact.sh

This file was deleted.

10 changes: 0 additions & 10 deletions script/bundle-article.sh

This file was deleted.

10 changes: 0 additions & 10 deletions script/bundle-bench.sh

This file was deleted.

10 changes: 10 additions & 0 deletions script/bundle-fluid-org.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -xe

WEBSITE=FluidOrg
yarn bundle-website $WEBSITE

WEBSITE_LISP_CASE=$(./script/util/lisp-case.sh "$WEBSITE")
unzip archive/0.3.1.zip -d dist/$WEBSITE_LISP_CASE > /dev/null # already has 0.3.1 as top-level folder
unzip archive/0.6.1.zip -d dist/$WEBSITE_LISP_CASE/0.6.1 > /dev/null
cp -r web/pdf dist/$WEBSITE_LISP_CASE
21 changes: 21 additions & 0 deletions script/bundle-page.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# run from project root
set -xe

MODULE=$1
SRC_PATH=${MODULE//./\/}
SRC_PATH_LISP_CASE=$(./script/util/lisp-case.sh "$SRC_PATH")
echo "$SRC_PATH -> $SRC_PATH_LISP_CASE"

if [[ ! -e "src/Website/$SRC_PATH.purs" ]]; then
./script/util/clean.sh $SRC_PATH_LISP_CASE
cp src/Website/$SRC_PATH.html dist/$SRC_PATH_LISP_CASE/index.html
else
./script/util/bundle.sh $SRC_PATH_LISP_CASE Website.$MODULE

if [[ -e "src/Website/$SRC_PATH.html" ]]; then
cp src/Website/$SRC_PATH.html dist/$SRC_PATH_LISP_CASE/index.html
else
cp web/template.html dist/$SRC_PATH_LISP_CASE/index.html
fi
fi
11 changes: 0 additions & 11 deletions script/bundle-standalone-all.sh

This file was deleted.

26 changes: 0 additions & 26 deletions script/bundle-standalone.sh

This file was deleted.

14 changes: 14 additions & 0 deletions script/bundle-website-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# run from project root
# set -x
set -e

WEBSITES=($(for FILE in src/Website/*.{purs,html}; do
basename "$FILE" | sed 's/\.[^.]*$//'
done | sort -u))

echo "Bundling websites: ${WEBSITES[@]}"

for WEBSITE in "${WEBSITES[@]}"; do
. script/bundle-website.sh $WEBSITE
done
27 changes: 21 additions & 6 deletions script/bundle-website.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
#!/usr/bin/env bash
# run from project root
set -xe

WEBSITE=website
WEBSITE=$1
. script/bundle-page.sh $WEBSITE

./script/bundle.sh $WEBSITE Standalone.Website
# Only support one level of nesting for now
shopt -s nullglob

unzip archive/0.3.1.zip -d dist/$WEBSITE # already has 0.3.1 as top-level folder
unzip archive/0.6.1.zip -d dist/$WEBSITE/0.6.1
set +x
PAGES=($(for FILE in src/Website/$WEBSITE/*.{purs,html}; do
basename "$FILE" | sed 's/\.[^.]*$//'
done | sort -u))
set -x

# until we have a more uniform structure:
cp src/Standalone/Website.html dist/$WEBSITE/index.html
echo "Processing ${WEBSITE} pages: ${PAGES[@]}"

for PAGE in "${PAGES[@]}"; do
. script/bundle-page.sh $WEBSITE.$PAGE
done
shopt -u nullglob

WEBSITE_LISP_CASE=$(./script/util/lisp-case.sh "$WEBSITE")
./script/util/copy-static.sh $WEBSITE_LISP_CASE

echo "Bundled website $WEBSITE"
2 changes: 1 addition & 1 deletion script/bundle.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -xe

. script/clean.sh $1
. script/util/clean.sh $1
. script/util/bundle.sh ${@:1}
2 changes: 1 addition & 1 deletion script/npm-publish.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# run from project root
set -xe #propagate errors to parent script
set -xe

yarn build-article
yarn config set registry "https://registry.npmjs.org/" #yarn command sets registry to https://registry.yarnpkg.com; re-set to npm
Expand Down
2 changes: 1 addition & 1 deletion script/test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -xe

. script/test.sh
. script/test-standalone-all.sh website
. script/test-website-all.sh
19 changes: 19 additions & 0 deletions script/test-page.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e

yarn puppeteer browsers install chrome
yarn puppeteer browsers install firefox

WEBSITE=$1
MODULE=$2

SRC_PATH=${MODULE//./\/}
if [ ! -e "src/Website/$SRC_PATH.purs" ]; then
echo "Error: 'Website/$SRC_PATH.purs' not found."
exit 1
fi

# don't need to have "deployed" this to dist/
# instead the following just picks up from output-es/
WEBSITE_LISP_CASE=$(./script/util/lisp-case.sh "$WEBSITE")
node puppeteer.js Website.Test.$MODULE $WEBSITE_LISP_CASE
11 changes: 0 additions & 11 deletions script/test-standalone-all.sh

This file was deleted.

17 changes: 0 additions & 17 deletions script/test-standalone.sh

This file was deleted.

15 changes: 15 additions & 0 deletions script/test-website-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# run from project root
set -xe

set +x
WEBSITES=($(for FILE in src/Website/*.{purs,html}; do
basename "$FILE" | sed 's/\.[^.]*$//'
done | sort -u))
set -x

echo "Checking for website tests: ${WEBSITES[@]}"

for WEBSITE in "${WEBSITES[@]}"; do
. script/test-website.sh $WEBSITE
done
29 changes: 29 additions & 0 deletions script/test-website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# run from project root
set -e

WEBSITE=$1

if [ -e "src/Website/Test/$WEBSITE" ] || [ -e "src/Website/Test/$WEBSITE.purs" ]; then
echo "Testing website: ${WEBSITE}"

if [ -e "src/Website/Test/$WEBSITE.purs" ]; then
. script/test-page.sh $WEBSITE $WEBSITE
fi

if [ -e "src/Website/Test/$WEBSITE" ]; then
PAGES=($(for FILE in src/Website/Test/$WEBSITE/*.purs; do
basename "$FILE" | sed 's/\.[^.]*$//'
done | sort -u))
else
PAGES=()
fi

echo "Processing ${#PAGES[@]} additional Test/${WEBSITE} pages: ${PAGES[@]}"

for PAGE in "${PAGES[@]}"; do
. script/test-page.sh $WEBSITE $WEBSITE.$PAGE
done
else
echo "No tests found for: ${WEBSITE}"
fi
2 changes: 1 addition & 1 deletion script/tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -xe

# Got bored of trying to make recursive globs work cross-platform way
yarn purs-tidy format-in-place src/*.purs src/**/*.purs src/App/**/*.purs src/App/View/**/*.purs test/*.purs test/**/*.purs
yarn purs-tidy format-in-place src/*.purs src/**/*.purs src/App/**/*.purs src/App/View/**/*.purs test/*.purs test/**/*.purs > /dev/null
2 changes: 1 addition & 1 deletion script/util/bundle.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
set -xe
yarn purs-backend-es bundle-app --main $2 --to dist/$1/fluid.js ${@:3}
yarn purs-backend-es bundle-app --main $2 --to dist/$1/fluid.js ${@:3} > /dev/null
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions script/util/lisp-case.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e

toLispCase() {
INPUT="$1"
RESULT=$(echo "$INPUT" | sed -E 's/([a-z0-9])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]')
echo "$RESULT"
}

toLispCase "$1"
Loading