diff --git a/.github/workflows/ci-checks.yaml b/.github/workflows/ci-checks.yaml index 948e45d..0d8bec9 100644 --- a/.github/workflows/ci-checks.yaml +++ b/.github/workflows/ci-checks.yaml @@ -14,5 +14,4 @@ jobs: with: node-version: 16 - run: npm install - - run: npm run prebuild - run: npm run test:ci diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 77a7266..27d16e6 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -15,8 +15,8 @@ jobs: strategy: matrix: node-version: [16.x] - os: [ubuntu-latest] - fail-fast: true + os: [ubuntu-latest, macos-latest, windows-latest] + fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -24,13 +24,17 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + + - name: Setup docker for macos + if: matrix.os == 'macos-latest' + run: | + brew install docker + colima start + echo DOCKER_HOST="unix:///${HOME}/.colima/default/docker.sock" >> $GITHUB_ENV - name: Install packages run: npm ci - - name: Install act - run: npm run prebuild - - name: Test run: npm test diff --git a/jest.config.ts b/jest.config.ts index 5293cf6..2f57ce1 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -18,7 +18,7 @@ const jestConfig: Config.InitialOptions = { ], testLocationInResults: true, testResultsProcessor: "jest-sonar-reporter", - testTimeout: 100000, + testTimeout: 120000, testPathIgnorePatterns: ["/build"], }; export default jestConfig; diff --git a/package-lock.json b/package-lock.json index 39b918a..8b2914c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,23 +1,26 @@ { "name": "@kie/act-js", - "version": "2.0.7", + "version": "2.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@kie/act-js", - "version": "2.0.7", + "version": "2.0.8", "hasInstallScript": true, "license": "SEE LICENSE IN LICENSE", "dependencies": { "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", "ajv": "^8.12.0", + "bin-links": "^4.0.1", "express": "^4.18.1", "follow-redirects": "^1.15.2", + "tar": "^6.1.13", "yaml": "^2.1.3" }, "bin": { - "act-js": "build/bin/act" + "act-js": "bin/act" }, "devDependencies": { "@octokit/rest": "^19.0.5", @@ -1264,6 +1267,26 @@ "node": ">= 14" } }, + "node_modules/@octokit/request/node_modules/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dev": true, + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/@octokit/rest": { "version": "19.0.5", "dev": true, @@ -1727,6 +1750,14 @@ "node": ">=0.4.0" } }, + "node_modules/adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "engines": { + "node": ">=6.0" + } + }, "node_modules/aggregate-error": { "version": "3.1.0", "dev": true, @@ -1953,6 +1984,32 @@ "dev": true, "license": "Apache-2.0" }, + "node_modules/bin-links": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.1.tgz", + "integrity": "sha512-bmFEM39CyX336ZGGRsGPlc6jZHriIoHacOQcTt72MktIjpPhZoP4te2jOyUXF3BLILmJ8aNLncoPVeIIFlrDeA==", + "dependencies": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/bin-links/node_modules/write-file-atomic": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.0.tgz", + "integrity": "sha512-R7NYMnHSlV42K54lwY9lvW6MnSm1HSJqZL3xiSgi9E7//FYaI74r2G0rd+/X6VAMkHEdzxQaU5HUOXWUz5kA/w==", + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "dev": true, @@ -2173,6 +2230,14 @@ "node": ">= 6" } }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "engines": { + "node": ">=10" + } + }, "node_modules/ci-info": { "version": "3.6.1", "dev": true, @@ -2279,6 +2344,14 @@ "node": ">=12" } }, + "node_modules/cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/co": { "version": "4.6.0", "dev": true, @@ -3078,6 +3151,28 @@ "node": ">=12" } }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "dev": true, @@ -3340,7 +3435,6 @@ }, "node_modules/imurmurhash": { "version": "0.1.4", - "dev": true, "license": "MIT", "engines": { "node": ">=0.8.19" @@ -4595,6 +4689,48 @@ "node": "*" } }, + "node_modules/minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/ms": { "version": "2.1.2", "license": "MIT" @@ -4641,25 +4777,6 @@ "node": ">= 10.13" } }, - "node_modules/node-fetch": { - "version": "2.6.7", - "dev": true, - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-int64": { "version": "0.4.0", "dev": true, @@ -4678,6 +4795,14 @@ "node": ">=0.10.0" } }, + "node_modules/npm-normalize-package-bin": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.0.tgz", + "integrity": "sha512-g+DPQSkusnk7HYXr75NtzkIP4+N81i3RPsGFidF3DzHd9MT9wWngmqoeg/fnHFz5MNdtG4w03s+QnhewSLTT2Q==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/npm-run-path": { "version": "4.0.1", "dev": true, @@ -5121,6 +5246,14 @@ "dev": true, "license": "MIT" }, + "node_modules/read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/readdirp": { "version": "3.6.0", "dev": true, @@ -5405,7 +5538,6 @@ }, "node_modules/signal-exit": { "version": "3.0.7", - "dev": true, "license": "ISC" }, "node_modules/simple-git": { @@ -5624,6 +5756,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tar": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", + "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^4.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/terminal-link": { "version": "2.1.1", "dev": true, @@ -5701,8 +5849,9 @@ }, "node_modules/tr46": { "version": "0.0.3", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true }, "node_modules/ts-jest": { "version": "28.0.8", @@ -5977,13 +6126,15 @@ }, "node_modules/webidl-conversions": { "version": "3.0.1", - "dev": true, - "license": "BSD-2-Clause" + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true }, "node_modules/whatwg-url": { "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, - "license": "MIT", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -6059,12 +6210,12 @@ }, "node_modules/yallist": { "version": "4.0.0", - "dev": true, "license": "ISC" }, "node_modules/yaml": { - "version": "2.2.1", - "license": "ISC", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==", "engines": { "node": ">= 14" } @@ -6933,6 +7084,17 @@ "is-plain-object": "^5.0.0", "node-fetch": "^2.6.7", "universal-user-agent": "^6.0.0" + }, + "dependencies": { + "node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dev": true, + "requires": { + "whatwg-url": "^5.0.0" + } + } } }, "@octokit/request-error": { @@ -7255,6 +7417,11 @@ "version": "8.2.0", "dev": true }, + "adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==" + }, "aggregate-error": { "version": "3.1.0", "dev": true, @@ -7404,6 +7571,28 @@ "version": "2.2.3", "dev": true }, + "bin-links": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.1.tgz", + "integrity": "sha512-bmFEM39CyX336ZGGRsGPlc6jZHriIoHacOQcTt72MktIjpPhZoP4te2jOyUXF3BLILmJ8aNLncoPVeIIFlrDeA==", + "requires": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "dependencies": { + "write-file-atomic": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.0.tgz", + "integrity": "sha512-R7NYMnHSlV42K54lwY9lvW6MnSm1HSJqZL3xiSgi9E7//FYaI74r2G0rd+/X6VAMkHEdzxQaU5HUOXWUz5kA/w==", + "requires": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + } + } + } + }, "binary-extensions": { "version": "2.2.0", "dev": true @@ -7535,6 +7724,11 @@ } } }, + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" + }, "ci-info": { "version": "3.6.1", "dev": true @@ -7597,6 +7791,11 @@ "wrap-ansi": "^7.0.0" } }, + "cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==" + }, "co": { "version": "4.6.0", "dev": true @@ -8114,6 +8313,24 @@ "universalify": "^2.0.0" } }, + "fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "requires": { + "minipass": "^3.0.0" + }, + "dependencies": { + "minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "requires": { + "yallist": "^4.0.0" + } + } + } + }, "fs.realpath": { "version": "1.0.0", "dev": true @@ -8257,8 +8474,7 @@ } }, "imurmurhash": { - "version": "0.1.4", - "dev": true + "version": "0.1.4" }, "indent-string": { "version": "4.0.0", @@ -9056,6 +9272,35 @@ "brace-expansion": "^1.1.7" } }, + "minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==" + }, + "minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "dependencies": { + "minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "requires": { + "yallist": "^4.0.0" + } + } + } + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" + }, "ms": { "version": "2.1.2" }, @@ -9083,13 +9328,6 @@ "propagate": "^2.0.0" } }, - "node-fetch": { - "version": "2.6.7", - "dev": true, - "requires": { - "whatwg-url": "^5.0.0" - } - }, "node-int64": { "version": "0.4.0", "dev": true @@ -9102,6 +9340,11 @@ "version": "3.0.0", "dev": true }, + "npm-normalize-package-bin": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.0.tgz", + "integrity": "sha512-g+DPQSkusnk7HYXr75NtzkIP4+N81i3RPsGFidF3DzHd9MT9wWngmqoeg/fnHFz5MNdtG4w03s+QnhewSLTT2Q==" + }, "npm-run-path": { "version": "4.0.1", "dev": true, @@ -9350,6 +9593,11 @@ "version": "18.2.0", "dev": true }, + "read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==" + }, "readdirp": { "version": "3.6.0", "dev": true, @@ -9518,8 +9766,7 @@ } }, "signal-exit": { - "version": "3.0.7", - "dev": true + "version": "3.0.7" }, "simple-git": { "version": "3.17.0", @@ -9646,6 +9893,19 @@ "version": "1.0.0", "dev": true }, + "tar": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", + "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "requires": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^4.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + } + }, "terminal-link": { "version": "2.1.1", "dev": true, @@ -9693,6 +9953,8 @@ }, "tr46": { "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, "ts-jest": { @@ -9835,10 +10097,14 @@ }, "webidl-conversions": { "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "dev": true }, "whatwg-url": { "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, "requires": { "tr46": "~0.0.3", @@ -9886,11 +10152,12 @@ "dev": true }, "yallist": { - "version": "4.0.0", - "dev": true + "version": "4.0.0" }, "yaml": { - "version": "2.2.1" + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==" }, "yargs": { "version": "17.6.2", diff --git a/package.json b/package.json index d4029a1..99674aa 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "@kie/act-js", - "version": "2.0.7", + "version": "2.0.8", "description": "nodejs wrapper for nektos/act", "main": "build/src/index.js", "types": "build/src/index.d.ts", "bin": { - "act-js": "build/bin/act" + "act-js": "bin/act" }, "files": [ - "build/bin", - "build/src" + "build/src", + "scripts" ], "repository": { "type": "git", @@ -26,12 +26,12 @@ "nektos/act" ], "scripts": { - "preinstall": "npm run prebuild", - "prebuild": "./scripts/act.sh 0.2.43", + "postinstall": "node scripts/postinstall.js 0.2.43", "build": "tsc && tsc-alias", - "postbuild": "cp -r ./bin ./build", + "pretest": "npm run postinstall && cp -r build/bin bin", "test": "jest unit/", "test:report": "npm test -- --coverage --testResultsProcessor=jest-sonar-reporter", + "pretest:ci": "npm run pretest", "test:ci": "jest ./test/ci/", "lint": "eslint .", "lint:fix": "eslint . --fix", @@ -64,9 +64,12 @@ }, "dependencies": { "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", "ajv": "^8.12.0", + "bin-links": "^4.0.1", "express": "^4.18.1", "follow-redirects": "^1.15.2", + "tar": "^6.1.13", "yaml": "^2.1.3" }, "jestSonar": { diff --git a/scripts/act.sh b/scripts/act.sh deleted file mode 100755 index 5c1fc1d..0000000 --- a/scripts/act.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -if [ $# -eq 0 ] -then - curl https://raw.githubusercontent.com/nektos/act/master/install.sh | bash -else - curl https://raw.githubusercontent.com/nektos/act/master/install.sh | bash -s -- v$1 -fi diff --git a/scripts/postinstall.js b/scripts/postinstall.js new file mode 100644 index 0000000..09e8a21 --- /dev/null +++ b/scripts/postinstall.js @@ -0,0 +1,185 @@ +#!/usr/bin/env node + +// Ref 1: https://github.com/supabase/cli/blob/main/scripts/postinstall.js +const binLinks = require("bin-links"); +const fs = require("fs"); +const path = require("path"); +const tar = require("tar"); +const gzip = require("zlib"); +const zip = require("adm-zip"); +const { https } = require("follow-redirects"); + +// version +const VERSION = process.argv[2] ?? process.env.ACT_VERSION; + +// Mapping between Node's `process.platform` to Golang's +const PLATFORM_MAPPING = { + darwin: "Darwin", + linux: "Linux", + win32: "Windows", +}; + +// Mapping between Node's `process.platform` and `process.arch` to nektos/act compatible arch +const PLATFORM_TO_ARCH_MAPPING = { + Darwin: { + x64: "x86_64", + arm64: "arm64", + }, + Linux: { + x64: "x86_64", + arm64: "arm64", + arm6: "armv6", + arm7: "armv7", + }, + Windows: { + x64: "x86_64", + arm64: "arm64", + arm7: "armv7", + }, +}; + +const readPackageJson = async () => { + const packageJsonPath = path.join(".", "package.json"); + const contents = await fs.promises.readFile(packageJsonPath); + return JSON.parse(contents); +}; + +const getBinPath = () => { + let binPath = path.join("build", "bin", "act"); + if (process.platform == "win32") { + binPath += ".exe"; + } + return { + binPath, + binName: path.basename(binPath), + binDir: path.dirname(binPath), + }; +}; + +const getDownloadUrl = () => { + const platform = PLATFORM_MAPPING[process.platform]; + if (!platform) { + throw Error( + "Installation is not supported for this platform: " + process.platform + ); + } + + let arch = PLATFORM_TO_ARCH_MAPPING[platform][process.arch]; + + // see: https://github.com/nodejs/node/issues/9491 + const armVersion = process.config.variables.arm_version; + if (arch === "arm") { + arch += armVersion; + } + + if (!arch) { + throw Error( + "Installation is not supported for this architecture: " + process.arch + ); + } + + // Build the download url from package.json + const pkgName = "act"; + const repo = "nektos/act"; + let extension = "tar.gz"; + + if (process.platform == "win32") { + extension = "zip"; + } + + return `https://github.com/${repo}/releases/download/v${VERSION}/${pkgName}_${platform}_${arch}.${extension}`; +}; + +const downloadWindows = async (url, binName, binDir) => { + console.info("Downloading", url); + + await new Promise((resolve, reject) => { + https + .get(url, (res) => { + let buffer; + + res.on("data", (chunk) => { + if (!buffer) { + buffer = chunk; + } else { + buffer = Buffer.concat([buffer, chunk]); + } + }); + + res.on("end", () => { + // we have unzip for windows + const unzip = new zip(buffer); + unzip.extractEntryTo(unzip.getEntry(binName), binDir, false, true); + resolve(); + }); + }) + .on("error", (err) => { + console.log("Error: ", err.message); + reject( + "Unable to install act. Set ACT_BINARY enn variable to point to the path of your locally installed act" + ); + }); + }); +}; + +const downloadOthers = async (url, binName, binDir) => { + // First we will un-gzip, then we will untar. + const ungz = gzip.createGunzip(); + const untar = tar.x({ cwd: binDir }, [binName]); + + console.info("Downloading", url); + + https + .get(url, (res) => { + res.pipe(ungz).pipe(untar); + }) + .on("error", (err) => { + console.log("Error: ", err.message); + throw "Unable to install act. Set ACT_BINARY enn variable to point to the path of your locally installed act"; + }); + + await new Promise((resolve, reject) => { + ungz.on("error", reject); + untar.on("error", reject); + untar.on("end", () => resolve()); + }); +}; + +/** + * Downloads the binary from package url and stores at + * ./bin in the package's root. + * + * See: https://docs.npmjs.com/files/package.json#bin + */ +async function main() { + const yarnGlobal = JSON.parse( + process.env.npm_config_argv || "{}" + ).original?.includes("global"); + if (process.env.npm_config_global || yarnGlobal) { + throw `Installing act-js CLI as a global module is not supported. + Please directly install nektos/act from https://github.com/nektos/act#installation + `; + } + + const pkg = await readPackageJson(); + const { binPath, binName, binDir } = getBinPath(); + const url = getDownloadUrl(); + await fs.promises.mkdir(binDir, { recursive: true }); + + if (process.platform === "win32") { + await downloadWindows(url, binName, binDir); + } else { + await downloadOthers(url, binName, binDir); + } + + // Link the binaries in postinstall to support yarn + await binLinks({ + path: path.resolve("."), + pkg: { ...pkg, bin: { [pkg.name]: binPath } }, + }); + + // TODO: verify checksums + console.info("Installed act CLI successfully"); +} + +main(); diff --git a/test/unit/act/act.test.ts b/test/unit/act/act.test.ts index 2c00ed5..b0c6b22 100644 --- a/test/unit/act/act.test.ts +++ b/test/unit/act/act.test.ts @@ -46,7 +46,7 @@ describe("list", () => { }); }); -describe("run", () => { +(process.platform === "linux" ? describe : describe.skip)("run", () => { test("run with job", async () => { const act = new Act(); const output = await act