Skip to content

Commit

Permalink
Augment action to upload error artifact if detected
Browse files Browse the repository at this point in the history
  • Loading branch information
olivia committed Feb 10, 2023
1 parent d47aa77 commit 26f57cb
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ jobs:
run: |
npm ci
npm run build
- uses: actions/upload-artifact@v3
with:
name: build-error
path: build-error.log
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
build-error.log*

# Runtime data
pids
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions scripts/build-all.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import {rimraf} from 'rimraf';
import {buildNames} from './build-names';
import {buildV3} from './build-v3';

import fs from 'fs/promises';
import {clearErrorLog} from './error-log';
async function build() {
await rimraf('dist')

await buildV3();
await buildNames();
try {
await rimraf('dist');
await clearErrorLog();
await buildV3();
await buildNames();
} catch (e) {
fs.writeFile('./build-error.log', e.toString());
}
}

build();
2 changes: 2 additions & 0 deletions scripts/build-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as fs from 'fs';
import {keyboardDefinitionV3ToVIADefinitionV3} from '@the-via/reader';
import process from 'process';
import {getDefinitionsPath, getOutputPath} from './get-path';
import {writeToErrorLog} from './error-log';

export async function buildNames() {
try {
Expand All @@ -26,6 +27,7 @@ export async function buildNames() {
console.log(`Generated ${outputPath}/keyboard_names.json`);
} catch (error) {
console.error(error);
await writeToErrorLog(error);
process.exit(1);
}
}
2 changes: 2 additions & 0 deletions scripts/build-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import stringify from 'json-stringify-pretty-compact';
import {buildIsolatedDefinitions} from './build-isolated-definitions';
import {getCommonMenusPath, getOutputPath} from './get-path';
import {hashJSON} from './hash-json';
import {writeToErrorLog} from './error-log';
var packageJson = require('../package.json');

export async function buildV3() {
Expand Down Expand Up @@ -85,6 +86,7 @@ export async function buildV3() {
});
} catch (error) {
console.error(error);
await writeToErrorLog(error);
process.exit(1);
}
}
9 changes: 9 additions & 0 deletions scripts/error-log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import fs from 'fs/promises';

export const clearErrorLog = async () => {
return fs.rm('build-error.log', {force: true});
};
export const writeToErrorLog = async (err: Error) => {
const errorStr = err.toString();
return fs.writeFile('build-error.log', errorStr);
};

0 comments on commit 26f57cb

Please sign in to comment.