Skip to content
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
19 changes: 14 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
node: [ "14", "16", "18" ]
framework: [ "next", "nuxt", "angular" ]
node: [ "14", "16" ]
framework: [ "next", "angular", "custom" ]
exclude:
# seeing failures on this one, skip for now
- os: ubuntu-latest
Expand Down Expand Up @@ -91,7 +91,8 @@ jobs:
- name: Test
run: |
npm i -g firebase-tools
npm i --only production --prefix $(npm root -g)/firebase-tools --ignore-scripts --force --save . || true
npm i --only production --force --ignore-scripts --save --prefix $(npm root -g)/firebase-tools $(npm pack .)
firebase --open-sesame frameworkawareness
npm run test:${{ matrix.framework }}
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
Expand All @@ -102,7 +103,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
node: [ "14", "16", "18" ]
node: [ "14", "16" ]
exclude:
# we build with this combination, safely skip
- os: ubuntu-latest
Expand All @@ -128,6 +129,14 @@ jobs:
run: npm ci
- name: Build
run: npm run build
- name: Test
run: |
npm i -g firebase-tools
npm i --only production --force --ignore-scripts --save --prefix $(npm root -g)/firebase-tools $(npm pack .)
firebase --open-sesame frameworkawareness
npm run test
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

# Break the branch protection test into a seperate step, so we can manage the matrix more easily
test_and_contribute:
Expand All @@ -140,8 +149,8 @@ jobs:
publish:
runs-on: ubuntu-latest
name: Publish (NPM)
# needs: ['build', 'test']
needs: ['build']
# needs: ['build', 'test']
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
steps:
- name: Checkout
Expand Down
4,353 changes: 4,353 additions & 0 deletions e2e/custom/package-lock.json

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions e2e/custom/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "express-app",
"version": "0.0.0",
"scripts": {
"build": "spack && npm run static && npm run prerender",
"static": "cp static/* lib",
"prerender": "ts-node tools/prerender.ts"
},
"directories": {
"serve": "lib"
},
"files": ["lib", "server.js"],
"main": "server.js",
"dependencies": {
"express": "^4.18.0",
"firebase": "^9.6.11",
"rxfire": "^6.0.3",
"rxjs": "^7.5.5"
},
"devDependencies": {
"@swc/cli": "^0.1.57",
"@swc/core": "^1.2.173",
"@types/express": "^4.17.13",
"@types/node": "^17.0.29",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
}
}
30 changes: 30 additions & 0 deletions e2e/custom/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require('express');
const { join } = require('path');

const server = express();
const distFolder = join(process.cwd(), 'lib');

server.set('views engine', 'html');
server.set('views', distFolder);

server.get('*.*', express.static(distFolder, {
maxAge: '1y'
}));

server.get('/profile', (req, res) => {
console.log(req);
res.send('...');
});

server.get('/', (req, res) => {
console.log(req);
res.send('...');
});

if (require.main.filename === __filename) {
const port = process.env.PORT || 8080;
server.listen(port);
console.log(`listening on port ${port}...`);
}

exports.app = () => server;
10 changes: 10 additions & 0 deletions e2e/custom/spack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { config } = require("@swc/core/spack");

module.exports = config({
entry: {
web: __dirname + "/src/index.ts",
},
output: {
path: __dirname + "/lib",
},
});
1 change: 1 addition & 0 deletions e2e/custom/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {}
Empty file added e2e/custom/static/styles.css
Empty file.
73 changes: 73 additions & 0 deletions e2e/custom/tools/prerender.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { mkdirSync, writeFileSync } from 'fs';
import { exit } from 'process';
import { promisify } from 'util';

const sleep = promisify(setTimeout);

const prerender = async () => {

console.log('Starting express server...');
await sleep(1_200);

console.log('Prerendering /...');
writeFileSync('./lib/index.html', '...');
await sleep(200);

console.log('Prerendering /posts...');
writeFileSync('./lib/posts.html', '...');
await sleep(200);

console.log('Prerendering /authors...');
writeFileSync('./lib/authors.html', '...');
await sleep(200);

const words = ['drown',
'wacky',
'shop',
'clip',
'earth',
'astonishing',
'observation',
'range',
'craven',
'sort',
'absorbing',
'classy',
'grateful',
'unequal',
'rude',
'ruddy',
'bait',
'refuse',
'amazing',
'merciful',
'education',
'basket',
'icy'];

const randomWord = () => words[words.length * Math.random() | 0];
const randomPostName = () => [randomWord(), randomWord(), randomWord()].join('-');

try { mkdirSync('./lib/posts') } catch(e) { };

const postCount = 56;
const posts = [];
for (let i = 0; i < postCount; i++) {
posts.push(randomPostName());
}

let i = 0;
for (const post of posts) {
console.log(`Prerendering /posts/${post}... (${i++}/${postCount})`);
try { writeFileSync(`./lib/posts/${post}.html`, '...') } catch(e) {};
await sleep(60);
}

console.log('Prerender complete, terminating express server...');

};

prerender().then(() => exit(0), e => {
console.error(e.message);
exit(1)
});
Loading