diff --git a/.changeset/modern-pillows-eat.md b/.changeset/modern-pillows-eat.md new file mode 100644 index 000000000..3bd650e15 --- /dev/null +++ b/.changeset/modern-pillows-eat.md @@ -0,0 +1,5 @@ +--- +'@callstack/reassure-gh-actions': minor +--- + +Add custom gh actions package for reassure diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 25a2f3a52..18f568c34 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,8 +37,19 @@ jobs: - name: Run performance tests run: cd examples/native && ./reassure-tests.sh - - - name: Run Danger.js - run: yarn danger ci + + build-validate-pref-tests-with-custom-action: + runs-on: ubuntu-latest + name: A job to test the new custom GH action + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16.x + cache: 'yarn' + - run: yarn install --force + - run: cd examples/native && ./reassure-tests.sh + - uses: ./../../packages/reassure-gh-action env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file diff --git a/packages/reassure-gh-action/action.yml b/packages/reassure-gh-action/action.yml new file mode 100644 index 000000000..f0bc9b799 --- /dev/null +++ b/packages/reassure-gh-action/action.yml @@ -0,0 +1,12 @@ +name: 'reassureGHAction' +description: 'Checks the files output by example react-native reassure tests' +inputs: + inputFilePath: + description: 'The input test file path' + required: false + debug: + description: 'Flag to enable debug' + required: false +runs: + using: 'node16' + main: 'lib/module/index.js' diff --git a/packages/reassure-gh-action/package.json b/packages/reassure-gh-action/package.json new file mode 100644 index 000000000..0a2ee6111 --- /dev/null +++ b/packages/reassure-gh-action/package.json @@ -0,0 +1,42 @@ +{ + "name": "@callstack/reassure-gh-actions", + "version": "0.0.1", + "description": "Performance testing companion for React and React Native", + "main": "lib/commonjs/index", + "module": "lib/module/index", + "types": "lib/typescript/index.d.ts", + "source": "src/index", + "scripts": { + "build": "bob build" + }, + "keywords": [ + "react-native", + "ios", + "android" + ], + "repository": "https://github.com/callstack/reassure", + "author": "Maciej Jastrzębski (https://github.com/mdjastrzebski)", + "contributors": [ + "Jakub Bujko (https://github.com/Xiltyn)", + "Tomasz Krzyżowski (https://github.com/TMaszko)", + "Michał Pierzchała (https://github.com/thymikee)" + ], + "license": "MIT", + "bugs": { + "url": "https://github.com/callstack/reassure/issues" + }, + "homepage": "https://github.com/callstack/reassure#readme", + "dependencies": { + "@actions/core": "^1.10.0", + "@actions/github": "^5.1.1" + }, + "react-native-builder-bob": { + "source": "src", + "output": "lib", + "targets": [ + "commonjs", + "module", + "typescript" + ] + } +} diff --git a/packages/reassure-gh-action/src/index.ts b/packages/reassure-gh-action/src/index.ts new file mode 100644 index 000000000..8c0ff4b25 --- /dev/null +++ b/packages/reassure-gh-action/src/index.ts @@ -0,0 +1,14 @@ +import path from 'path'; +import core from '@actions/core'; +import { reassureGhAction, reassureGhActionConfig } from './reassureGhAction'; + +const index = () => { + const inputFilePath = core.getInput('inputFilePath', { required: false }); + const debug = !!core.getInput('debug', { required: false }); + + const defaultInputFilePath = path.join(__dirname, './examples/native/.reassure/output.md'); + const config: reassureGhActionConfig = { inputFilePath: inputFilePath || defaultInputFilePath, debug }; + reassureGhAction(config); +}; + +export default index; diff --git a/packages/reassure-gh-action/src/reassureGhAction.ts b/packages/reassure-gh-action/src/reassureGhAction.ts new file mode 100644 index 000000000..7f9513fd6 --- /dev/null +++ b/packages/reassure-gh-action/src/reassureGhAction.ts @@ -0,0 +1,35 @@ +import * as fs from 'fs'; +import * as path from 'path'; + +export type reassureGhActionConfig = { inputFilePath: string; debug?: boolean }; + +export function reassureGhAction(config: reassureGhActionConfig = { inputFilePath: '.reassure/output.md' }) { + const _warning = ` + ⚠️ No output file found @ ${config.inputFilePath} + ------------------------------------------------------------- + Review reassure configuration and make sure your markdown output + file can be found in the location shown above. + ------------------------------------------------------------- + `; + + try { + const perfFilePath = path.resolve(config.inputFilePath); + const perfFileContents = fs.readFileSync(perfFilePath, 'utf8'); + + if (config.debug) { + if (!perfFileContents) { + console.log(_warning); + } else { + console.log(perfFileContents); + } + } else { + if (!perfFileContents) { + console.warn(_warning); + } else { + console.log(perfFileContents); + } + } + } catch (error) { + console.error(_warning, error); + } +} diff --git a/packages/reassure-gh-action/tsconfig.json b/packages/reassure-gh-action/tsconfig.json new file mode 100644 index 000000000..3bf687616 --- /dev/null +++ b/packages/reassure-gh-action/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "allowJs": true, + "baseUrl": "./", + "isolatedModules": true, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "esModuleInterop": true, + "importsNotUsedAsValues": "error", + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "lib": ["esnext"], + "module": "CommonJS", + "moduleResolution": "node", + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noImplicitUseStrict": false, + "noStrictGenericChecks": false, + "noUnusedLocals": true, + "noUnusedParameters": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "strict": true, + "target": "esnext" + }, + "include": ["src/**/*"], + "exclude": ["**/__tests__/**"] +} diff --git a/yarn.lock b/yarn.lock index 0d0aa309f..82ca4c709 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,31 @@ # yarn lockfile v1 +"@actions/core@^1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f" + integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug== + dependencies: + "@actions/http-client" "^2.0.1" + uuid "^8.3.2" + +"@actions/github@^5.1.1": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@actions/github/-/github-5.1.1.tgz#40b9b9e1323a5efcf4ff7dadd33d8ea51651bbcb" + integrity sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g== + dependencies: + "@actions/http-client" "^2.0.1" + "@octokit/core" "^3.6.0" + "@octokit/plugin-paginate-rest" "^2.17.0" + "@octokit/plugin-rest-endpoint-methods" "^5.13.0" + +"@actions/http-client@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.0.1.tgz#873f4ca98fe32f6839462a6f046332677322f99c" + integrity sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw== + dependencies: + tunnel "^0.0.6" + "@ampproject/remapping@^2.1.0": version "2.1.2" resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.1.2.tgz#4edca94973ded9630d20101cd8559cedb8d8bd34" @@ -1829,6 +1854,19 @@ before-after-hook "^2.2.0" universal-user-agent "^6.0.0" +"@octokit/core@^3.6.0": + version "3.6.0" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.6.0.tgz#3376cb9f3008d9b3d110370d90e0a1fcd5fe6085" + integrity sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q== + dependencies: + "@octokit/auth-token" "^2.4.4" + "@octokit/graphql" "^4.5.8" + "@octokit/request" "^5.6.3" + "@octokit/request-error" "^2.0.5" + "@octokit/types" "^6.0.3" + before-after-hook "^2.2.0" + universal-user-agent "^6.0.0" + "@octokit/endpoint@^6.0.1": version "6.0.12" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.12.tgz#3b4d47a4b0e79b1027fb8d75d4221928b2d05658" @@ -1852,6 +1890,11 @@ resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-11.2.0.tgz#b38d7fc3736d52a1e96b230c1ccd4a58a2f400a6" integrity sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA== +"@octokit/openapi-types@^12.11.0": + version "12.11.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-12.11.0.tgz#da5638d64f2b919bca89ce6602d059f1b52d3ef0" + integrity sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ== + "@octokit/plugin-paginate-rest@^2.16.8": version "2.17.0" resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz#32e9c7cab2a374421d3d0de239102287d791bce7" @@ -1859,6 +1902,13 @@ dependencies: "@octokit/types" "^6.34.0" +"@octokit/plugin-paginate-rest@^2.17.0": + version "2.21.3" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz#7f12532797775640dbb8224da577da7dc210c87e" + integrity sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw== + dependencies: + "@octokit/types" "^6.40.0" + "@octokit/plugin-request-log@^1.0.4": version "1.0.4" resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz#5e50ed7083a613816b1e4a28aeec5fb7f1462e85" @@ -1872,6 +1922,14 @@ "@octokit/types" "^6.34.0" deprecation "^2.3.1" +"@octokit/plugin-rest-endpoint-methods@^5.13.0": + version "5.16.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz#7ee8bf586df97dd6868cf68f641354e908c25342" + integrity sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw== + dependencies: + "@octokit/types" "^6.39.0" + deprecation "^2.3.1" + "@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": version "2.1.0" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" @@ -1881,7 +1939,7 @@ deprecation "^2.0.0" once "^1.4.0" -"@octokit/request@^5.6.0": +"@octokit/request@^5.6.0", "@octokit/request@^5.6.3": version "5.6.3" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0" integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A== @@ -1910,6 +1968,13 @@ dependencies: "@octokit/openapi-types" "^11.2.0" +"@octokit/types@^6.39.0", "@octokit/types@^6.40.0": + version "6.41.0" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.41.0.tgz#e58ef78d78596d2fb7df9c6259802464b5f84a04" + integrity sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg== + dependencies: + "@octokit/openapi-types" "^12.11.0" + "@react-native-community/cli-clean@^9.1.0": version "9.1.0" resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-9.1.0.tgz#8d6c3591dbaa52a02bf345dcd79c3a997df6ade5" @@ -8490,6 +8555,11 @@ tty-table@^4.1.5: wcwidth "^1.0.1" yargs "^17.1.1" +tunnel@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" + integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== + turbo-darwin-64@1.5.6: version "1.5.6" resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.5.6.tgz#2e0e14343c84dde33b5a09ea5389ee6a9565779c" @@ -8716,6 +8786,11 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + v8-to-istanbul@^9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz#b6f994b0b5d4ef255e17a0d17dc444a9f5132fa4"