skip building test harness in docker image (#551)

A small test harness bundle was recently added that is breaking the docker image build. It could be added to the docker image, but that would introduce a bunch of extraneous test file dependencies. So this tweaks the build to simply skip the test bundle if its primary source file is not found.

Also added some other test fixes along the way:
  * make a custom widget test more reliable
  * update a localization test now that `pt` exists
  * store more log info in artifact on error
pull/561/head
Paul Fitzpatrick 12 months ago committed by GitHub
parent 2d636c5890
commit 70935a4fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -103,23 +103,26 @@ jobs:
MOCHA_WEBDRIVER_SKIP_CLEANUP=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:nbrowser --parallel --jobs 3 MOCHA_WEBDRIVER_SKIP_CLEANUP=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:nbrowser --parallel --jobs 3
env: env:
TESTS: ${{ matrix.tests }} TESTS: ${{ matrix.tests }}
MOCHA_WEBDRIVER_LOGDIR: ${{ runner.temp }}/mocha-webdriver-logs MOCHA_WEBDRIVER_LOGDIR: ${{ runner.temp }}/test-logs/webdriver
TESTDIR: ${{ runner.temp }}/test-logs
- name: Prepare a safe artifact name - name: Prepare for saving artifact
if: failure() if: failure()
run: | run: |
ARTIFACT_NAME=logs-$(echo $TESTS | sed 's/[^-a-zA-Z0-9]/_/g') ARTIFACT_NAME=logs-$(echo $TESTS | sed 's/[^-a-zA-Z0-9]/_/g')
echo "Artifact name is '$ARTIFACT_NAME'" echo "Artifact name is '$ARTIFACT_NAME'"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
find $TESTDIR -iname "*.socket" -exec rm {} \;
env: env:
TESTS: ${{ matrix.tests }} TESTS: ${{ matrix.tests }}
TESTDIR: ${{ runner.temp }}/test-logs
- name: Save artifacts on failure - name: Save artifacts on failure
if: failure() if: failure()
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: ${{ env.ARTIFACT_NAME }} name: ${{ env.ARTIFACT_NAME }}
path: ${{ runner.temp }}/mocha-webdriver-logs # only exists for webdriver tests path: ${{ runner.temp }}/test-logs # only exists for webdriver tests
services: services:
# https://github.com/bitnami/bitnami-docker-minio/issues/16 # https://github.com/bitnami/bitnami-docker-minio/issues/16

@ -1,3 +1,4 @@
const fs = require('fs');
const MomentLocalesPlugin = require('moment-locales-webpack-plugin'); const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
const { ProvidePlugin } = require('webpack'); const { ProvidePlugin } = require('webpack');
const path = require('path'); const path = require('path');
@ -15,7 +16,11 @@ module.exports = {
account: "app/client/accountMain", account: "app/client/accountMain",
billing: "app/client/billingMain", billing: "app/client/billingMain",
activation: "app/client/activationMain", activation: "app/client/activationMain",
test: "test/client-harness/client", // Include client test harness if it is present (it won't be in
// docker image).
...(fs.existsSync("test/client-harness/client.js") ? {
test: "test/client-harness/client",
} : {}),
}, },
output: { output: {
filename: "[name].bundle.js", filename: "[name].bundle.js",

@ -4,27 +4,29 @@
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const ready = urlParams.get('ready') ? JSON.parse(urlParams.get('ready')) : undefined; const ready = urlParams.get('ready') ? JSON.parse(urlParams.get('ready')) : undefined;
if (ready && ready.onEditOptions) { function setup() {
ready.onEditOptions = () => { if (ready && ready.onEditOptions) {
document.getElementById('configure').innerHTML = 'called'; ready.onEditOptions = () => {
}; document.getElementById('configure').innerHTML = 'called';
} };
}
grist.ready(ready); grist.ready(ready);
grist.onOptions(data => { grist.onOptions(data => {
document.getElementById('onOptions').innerHTML = JSON.stringify(data); document.getElementById('onOptions').innerHTML = JSON.stringify(data);
}); });
grist.onRecord((data, mappings) => { grist.onRecord((data, mappings) => {
document.getElementById('onRecord').innerHTML = JSON.stringify(data); document.getElementById('onRecord').innerHTML = JSON.stringify(data);
document.getElementById('onRecordMappings').innerHTML = JSON.stringify(mappings); document.getElementById('onRecordMappings').innerHTML = JSON.stringify(mappings);
}); });
grist.onRecords((data, mappings) => { grist.onRecords((data, mappings) => {
document.getElementById('onRecords').innerHTML = JSON.stringify(data); document.getElementById('onRecords').innerHTML = JSON.stringify(data);
document.getElementById('onRecordsMappings').innerHTML = JSON.stringify(mappings); document.getElementById('onRecordsMappings').innerHTML = JSON.stringify(mappings);
}); });
}
async function run(handler) { async function run(handler) {
try { try {
@ -66,6 +68,7 @@ async function configure() {
} }
window.onload = () => { window.onload = () => {
setup();
document.getElementById('ready').innerText = 'ready'; document.getElementById('ready').innerText = 'ready';
document.getElementById('access').innerHTML = urlParams.get('access'); document.getElementById('access').innerHTML = urlParams.get('access');
document.getElementById('readonly').innerHTML = urlParams.get('readonly'); document.getElementById('readonly').innerHTML = urlParams.get('readonly');

@ -116,8 +116,7 @@ describe("Localization", function() {
// But only uz code is preloaded. // But only uz code is preloaded.
notPresent(uzResponse, "uz-UZ"); notPresent(uzResponse, "uz-UZ");
// For Portuguese we have only en. notPresent(ptResponse, "pt-PR", "uz", "en-US");
notPresent(ptResponse, "pt", "pt-PR", "uz", "en-US");
}); });
it("loads correct languages from file system", async function() { it("loads correct languages from file system", async function() {

@ -65,14 +65,14 @@ export class TestServerMerged extends EventEmitter implements IMochaServer {
await this.stop(); await this.stop();
} }
this._starts++; this._starts++;
const workerIdText = process.env.MOCHA_WORKER_ID || '0';
if (reset) { if (reset) {
if (process.env.TESTDIR) { if (process.env.TESTDIR) {
this.testDir = process.env.TESTDIR; this.testDir = path.join(process.env.TESTDIR, workerIdText);
} else { } else {
const workerId = process.env.MOCHA_WORKER_ID || '0';
// Create a testDir of the form grist_test_{USER}_{SERVER_NAME}_{WORKER_ID}, removing any previous one. // Create a testDir of the form grist_test_{USER}_{SERVER_NAME}_{WORKER_ID}, removing any previous one.
const username = process.env.USER || "nobody"; const username = process.env.USER || "nobody";
this.testDir = path.join(tmpdir(), `grist_test_${username}_${this._name}_${workerId}`); this.testDir = path.join(tmpdir(), `grist_test_${username}_${this._name}_${workerIdText}`);
await fse.remove(this.testDir); await fse.remove(this.testDir);
} }
} }
@ -99,7 +99,7 @@ export class TestServerMerged extends EventEmitter implements IMochaServer {
// logging. Server code uses a global logger, so it's hard to separate out (especially so if // logging. Server code uses a global logger, so it's hard to separate out (especially so if
// we ever run different servers for different tests). // we ever run different servers for different tests).
const serverLog = process.env.VERBOSE ? 'inherit' : nodeLogFd; const serverLog = process.env.VERBOSE ? 'inherit' : nodeLogFd;
const workerId = parseInt(process.env.MOCHA_WORKER_ID || '0', 10); const workerId = parseInt(workerIdText, 10);
const corePort = String(8295 + workerId * 2); const corePort = String(8295 + workerId * 2);
const untrustedPort = String(8295 + workerId * 2 + 1); const untrustedPort = String(8295 + workerId * 2 + 1);
const env: Record<string, string> = { const env: Record<string, string> = {

Loading…
Cancel
Save