Skip to content

Commit 787bf39

Browse files
author
Pong Li
committed
Fixing github actions
1 parent 415d64a commit 787bf39

File tree

3 files changed

+72
-16
lines changed

3 files changed

+72
-16
lines changed

.github/workflows/npm-publish.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,51 @@ name: Node.js Package
55

66
on: push
77

8+
env:
9+
CI: true
10+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
11+
IASSIGN_SAUCE_USERNAME: ${{ secrets.IASSIGN_SAUCE_USERNAME }}
12+
IASSIGN_SAUCE_ACCESS_KEY: ${{ secrets.IASSIGN_SAUCE_ACCESS_KEY }}
13+
IASSIGN_QA_SAUCE_USERNAME: ${{ secrets.IASSIGN_QA_SAUCE_USERNAME }}
14+
IASSIGN_QA_SAUCE_ACCESS_KEY: ${{ secrets.IASSIGN_QA_SAUCE_ACCESS_KEY }}
15+
GIT_COMMIT: ${{ github.sha }}
16+
BUILD_NUMBER: ${{ github.run_id }}
17+
GIT_BRANCH: ${{ github.ref }}
18+
819
jobs:
920
build:
1021
runs-on: ubuntu-latest
22+
1123
steps:
1224
- uses: actions/checkout@v2
1325
- uses: actions/setup-node@v2
1426
with:
1527
node-version: 14
28+
29+
- name: pre-browser-test
30+
run: |
31+
export LAUNCHERS_COUNT=$(node -p -e "Object.keys(require('./allCustomLaunchers.json')).length")
32+
export TESTS_COUNT=12
33+
test $LAUNCHERS_COUNT == $TESTS_COUNT || { echo "Number of browser tests ($"TESTS_COUNT") is not the same as number of launchers ($LAUNCHERS_COUNT)"; false; }
1634
- run: npm ci
1735
- run: npm test
1836

19-
publish-npm:
20-
needs: build
37+
deploy:
2138
runs-on: ubuntu-latest
39+
needs: build
40+
if: github.ref == 'refs/heads/master'
41+
2242
steps:
2343
- uses: actions/checkout@v2
2444
- uses: actions/setup-node@v2
2545
with:
2646
node-version: 14
2747
registry-url: https://registry.npmjs.org/
28-
- run: npm ci
48+
- run: |
49+
npm ci
50+
npm run coveralls
51+
export REMOTE_VERSION=$(npm dist-tag ls immutable-assign | cut -d' ' -f 2)
52+
export LOCAL_VERSION=$(node -p -e "require('./package.json').version")
53+
test "$REMOTE_VERSION" != "$LOCAL_VERSION" && echo "paul debug should publish"
54+
# test "$REMOTE_VERSION" != "$LOCAL_VERSION" && npm publish
55+

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ interface IIassignOption {
445445

446446
## History
447447

448+
* 2.1.5 - Migrated to github actions
448449
* 2.1.4 - Reduce the package size to 11.9 kB
449450
* 2.1.1 - Added function overload 3 to pass in known property paths (array). Refer to [example 10](#example-10-update-nested-level-object-properties-using-property-paths-overload-3)
450451
* 2.0.8 - Fixed bug for undefined properties.
@@ -472,8 +473,8 @@ interface IIassignOption {
472473
* 1.0.16 - Tested in Node.js and major browsers (IE 11, Chrome 52, Firefox 47, Edge 13, PhantomJS 2)
473474

474475

475-
[1]: https://travis-ci.org/engineforce/ImmutableAssign.svg?branch=master
476-
[2]: https://travis-ci.org/engineforce/ImmutableAssign
476+
[1]: https://github.com/engineforce/ImmutableAssign/actions/workflows/npm-publish.yml/badge.svg?branch=master
477+
[2]: https://github.com/engineforce/ImmutableAssign/actions
477478
[3]: https://badge.fury.io/js/immutable-assign.svg
478479
[4]: https://badge.fury.io/js/immutable-assign
479480
[5]: https://coveralls.io/repos/github/engineforce/ImmutableAssign/badge.svg?branch=master

karma.conf.js

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,66 @@
11
// Karma configuration
22
// Generated on Wed Aug 10 2016 13:14:23 GMT+1000 (AUS Eastern Standard Time)
33
var { readFileSync } = require('fs');
4-
var { toPairs, fromPairs } = require('lodash');
4+
var { toPairs, fromPairs, take } = require('lodash');
5+
var assert = require('assert')
56
var {
67
NO_PROXY,
7-
TRAVIS_COMMIT,
8-
TRAVIS_BUILD_NUMBER,
9-
TRAVIS_BRANCH,
8+
GIT_COMMIT,
9+
BUILD_NUMBER,
10+
GIT_BRANCH,
1011
CUSTOM_JOB_INDEX,
1112
IASSIGN_SAUCE_USERNAME,
1213
IASSIGN_SAUCE_ACCESS_KEY,
1314
IASSIGN_QA_SAUCE_USERNAME,
1415
IASSIGN_QA_SAUCE_ACCESS_KEY
1516
} = process.env;
1617

18+
console.log("ENV", {
19+
NO_PROXY,
20+
GIT_COMMIT,
21+
BUILD_NUMBER,
22+
GIT_BRANCH,
23+
CUSTOM_JOB_INDEX,
24+
IASSIGN_SAUCE_USERNAME,
25+
IASSIGN_SAUCE_ACCESS_KEY: `${mask(IASSIGN_SAUCE_ACCESS_KEY)}`,
26+
IASSIGN_QA_SAUCE_USERNAME,
27+
IASSIGN_QA_SAUCE_ACCESS_KEY: `${mask(IASSIGN_QA_SAUCE_ACCESS_KEY)}`,
28+
})
29+
30+
function mask(text) {
31+
if (!text) {
32+
return text
33+
}
34+
35+
if (typeof text !== "string") {
36+
return text
37+
}
38+
39+
return text.slice(0, 3) + '...' + text.slice(-3)
40+
}
41+
1742
var customLaunchers = [];
1843

1944
if (process.argv.indexOf('--browsers') <= -1) {
20-
console.assert(TRAVIS_COMMIT, 'TRAVIS_COMMIT must exist');
21-
console.assert(TRAVIS_BUILD_NUMBER, 'TRAVIS_BUILD_NUMBER must exist');
22-
console.assert(CUSTOM_JOB_INDEX, 'CUSTOM_JOB_INDEX must exist');
45+
assert(GIT_COMMIT, 'GIT_COMMIT must exist');
46+
assert(BUILD_NUMBER, 'BUILD_NUMBER must exist');
47+
assert(GIT_BRANCH, 'GIT_BRANCH must exist');
48+
assert(CUSTOM_JOB_INDEX, 'CUSTOM_JOB_INDEX must exist');
2349

2450
CUSTOM_JOB_INDEX = parseInt(CUSTOM_JOB_INDEX);
25-
var buildId = TRAVIS_COMMIT + '-' + TRAVIS_BUILD_NUMBER;
26-
var branch = TRAVIS_BRANCH || 'branch';
51+
var buildId = GIT_COMMIT + '-' + BUILD_NUMBER;
2752

28-
if (branch !== 'master') {
53+
if (branch !== 'refs/heads/master') {
2954
var SAUCE_USERNAME = IASSIGN_QA_SAUCE_USERNAME;
3055
var SAUCE_ACCESS_KEY = IASSIGN_QA_SAUCE_ACCESS_KEY;
3156
} else {
3257
var SAUCE_USERNAME = IASSIGN_SAUCE_USERNAME;
3358
var SAUCE_ACCESS_KEY = IASSIGN_SAUCE_ACCESS_KEY;
3459
}
3560

61+
assert(SAUCE_USERNAME, 'CUSTOM_JOB_INDEX must exist');
62+
assert(SAUCE_ACCESS_KEY, 'CUSTOM_JOB_INDEX must exist');
63+
3664
var allCustomLaunchers = JSON.parse(
3765
readFileSync(`./allCustomLaunchers.json`, 'utf8')
3866
);
@@ -41,7 +69,7 @@ if (process.argv.indexOf('--browsers') <= -1) {
4169
]);
4270

4371
console.log({
44-
TRAVIS_BRANCH,
72+
GIT_BRANCH,
4573
buildId,
4674
CUSTOM_JOB_INDEX,
4775
customLaunchers,

0 commit comments

Comments
 (0)