Skip to content

Commit 582b041

Browse files
committed
Add script to run tests and corresponding workflow
1 parent c97af06 commit 582b041

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

lib/node_modules/@stdlib/_tools/scripts/publish_packages.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var ENV = require( '@stdlib/process/env' );
5151
var debug = logger( 'scripts:publish-packages' );
5252

5353
var START_PKG_INDEX = 0;
54-
var END_PKG_INDEX = 110;
54+
var END_PKG_INDEX = 1;
5555

5656
var INSTALLATION_SECTION = [
5757
'<section class="installation">',
@@ -156,6 +156,31 @@ var WORKFLOW_PUBLISH = [
156156
' channel: \'#npm-ci\'',
157157
' if: failure()'
158158
].join( '\n' );
159+
var WORKFLOW_TESTS = [
160+
'name: Pass Tests',
161+
'',
162+
'on: push',
163+
'',
164+
'jobs:',
165+
' tests:',
166+
' runs-on: ubuntu-latest',
167+
' env:',
168+
' SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}',
169+
' steps:',
170+
' - uses: actions/checkout@v2',
171+
' - uses: actions/setup-node@v1',
172+
' with:',
173+
' node-version: 14',
174+
' - run: |',
175+
' npm install',
176+
' npm test',
177+
' - uses: act10ns/slack@v1',
178+
' with:',
179+
' status: ${{ job.status }}',
180+
' steps: ${{ toJson(steps) }}',
181+
' channel: \'#npm-ci\'',
182+
' if: failure()'
183+
].join( '\n' );
159184
var WORKFLOW_INSTALL = [
160185
'name: Test Installing Dependencies',
161186
'',
@@ -447,7 +472,6 @@ function publish( pkg, clbk ) {
447472
}
448473
}
449474
}
450-
writeFileSync( pkgJsonPath, JSON.stringify( pkgJSON, null, ' ' ).concat( '\n' ) );
451475
fs.mkdirSync( join( dist, '.github', 'workflows' ), {
452476
'recursive': true
453477
});
@@ -458,6 +482,12 @@ function publish( pkg, clbk ) {
458482
workflowPath = join( dist, '.github', 'workflows', 'close_pull_requests.yml' );
459483
pth = 'https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/'+pkg;
460484
writeFileSync( workflowPath, replace( WORKFLOW_CLOSE_PULLS, '<pkg-path>', pth ) );
485+
if ( contains( devDeps, 'tape' ) ) {
486+
workflowPath = join( dist, '.github', 'workflows', 'pass_tests.yml' );
487+
writeFileSync( workflowPath, WORKFLOW_TESTS );
488+
pkgJSON.scripts.test = 'tape test/**.js';
489+
}
490+
writeFileSync( pkgJsonPath, JSON.stringify( pkgJSON, null, ' ' ).concat( '\n' ) );
461491

462492
mdPath = join( dist, 'CONTRIBUTING.md' );
463493
writeFileSync( mdPath, CONTRIBUTING );

0 commit comments

Comments
 (0)