From 8789d9c94fd7fbb040d5b50a89e0aa9f839249da Mon Sep 17 00:00:00 2001 From: overtorment Date: Sat, 30 Nov 2024 19:24:16 +0000 Subject: [PATCH] FIX: GlaDOS now checks all tests, not just unit; also sends tg notifications --- src/main.ts | 60 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/src/main.ts b/src/main.ts index 2bd9005..674fd73 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,6 @@ import * as github from "@actions/github"; +const querystring = require('querystring'); +const https = require('https'); const token = process.env.TOKEN; if (!token) { @@ -58,6 +60,8 @@ async function run(): Promise { let approved = false; let e2ePassed = false; let unitTestsPassed = false; + let integrationTestsPassed = false; + let lintTestsPassed = false; let thereAreBlockerLabels = false; let outsiderContributor = pr.head.repo.full_name !== "BlueWallet/BlueWallet"; @@ -87,13 +91,13 @@ async function run(): Promise { }); for (const check of checks.data.check_runs) { - if (check.name.startsWith("Travis CI") && check.conclusion === "success") - e2ePassed = true; - if (check.name === "e2e" && check.conclusion === "success") - e2ePassed = true; - if (check.name === "test" && check.conclusion === "success") + if (check.name === "e2e" && check.conclusion === "success") e2ePassed = true; + if (check.name === "test" && check.conclusion === "success") { + // in job "test" we run all of it, so if it passes - all of them passed unitTestsPassed = true; - // so if Travis or GithubActions passes - it still gets green lights since its the same set of tests + integrationTestsPassed = true; + lintTestsPassed = true; + } } if (reviews.data.length >= 1) { @@ -145,17 +149,17 @@ async function run(): Promise { ); for (const status of statuses.data.statuses) { - if ( - status.context.startsWith("ci/circleci") && - status.state === "success" - ) - unitTestsPassed = true; + if (status.context.startsWith("ci/circleci: unit") && status.state === "success") unitTestsPassed = true; + if (status.context.startsWith("ci/circleci: integration") && status.state === "success") integrationTestsPassed = true; + if (status.context.startsWith("ci/circleci: lint") && status.state === "success") lintTestsPassed = true; } console.log({ approved, e2ePassed, unitTestsPassed, + integrationTestsPassed, + lintTestsPassed, outsiderContributor, thereAreBlockerLabels, }); @@ -164,10 +168,13 @@ async function run(): Promise { approved && e2ePassed && unitTestsPassed && + integrationTestsPassed && + lintTestsPassed && !outsiderContributor && !thereAreBlockerLabels ) { console.log("LGTM. lets merge"); + postDataToTrafficRobot('GlaDOS: Im going to merge ' + 'https://github.com/BlueWallet/BlueWallet/pull/' + pr.number + " (" + pr.title + ")", process.env.CONNECTOR_ID); // continue; // fixme try { @@ -199,4 +206,35 @@ async function run(): Promise { } } + +function postDataToTrafficRobot(data, connectorId) { + var postData = querystring.stringify({ + data + }); + + var options = { + hostname: 'push.tg', + port: 443, + path: '/' + connectorId, + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Length': postData.length + } + }; + + var req = https.request(options, (res) => { + res.on('data', (d) => { + process.stdout.write(d); + }); + }); + + req.on('error', (e) => { + console.error(e); + }); + + req.write(postData); + req.end(); +} + run();