Skip to content

Commit

Permalink
split into common and action-specific utils
Browse files Browse the repository at this point in the history
  • Loading branch information
alexivanov committed Mar 20, 2024
1 parent 1593a63 commit afb4e4e
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 30 deletions.
14 changes: 7 additions & 7 deletions src/actions/in-cloud/in-cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { METICULOUS_LOGGER_NAME } from "@alwaysmeticulous/common";
import { executeRemoteTestRun } from "@alwaysmeticulous/remote-replay-launcher";
import { initSentry } from "@alwaysmeticulous/sentry";
import log from "loglevel";
import { throwIfCannotConnectToOrigin } from "../../utils/check-connection";
import { safeEnsureBaseTestsExists } from "../../utils/ensure-base-exists.utils";
import { getEnvironment } from "../../utils/environment.utils";
import { getBaseAndHeadCommitShas } from "../../utils/get-base-and-head-commit-shas";
import { getCodeChangeEvent } from "../../utils/get-code-change-event";
import { initLogger, setLogLevel, shortSha } from "../../utils/logger.utils";
import { getOctokitOrFail } from "../../utils/octokit";
import { throwIfCannotConnectToOrigin } from "../../common/check-connection";
import { safeEnsureBaseTestsExists } from "../../common/ensure-base-exists.utils";
import { getEnvironment } from "../../common/environment.utils";
import { getBaseAndHeadCommitShas } from "../../common/get-base-and-head-commit-shas";
import { getCodeChangeEvent } from "../../common/get-code-change-event";
import { initLogger, setLogLevel, shortSha } from "../../common/logger.utils";
import { getOctokitOrFail } from "../../common/octokit";
import { getInCloudActionInputs } from "./get-inputs";

export const runMeticulousTestsInCloudAction = async (): Promise<void> => {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/main/get-inputs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getInputFromEnv } from "../../utils/get-input-from-env";
import { getInputFromEnv } from "../../common/get-input-from-env";

export const getMainActionInputs = () => {
// The names, required value, and types should match that in action.yml
Expand Down
24 changes: 12 additions & 12 deletions src/actions/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import { RunningTestRunExecution } from "@alwaysmeticulous/sdk-bundles-api";
import { initSentry } from "@alwaysmeticulous/sentry";
import debounce from "lodash.debounce";
import log from "loglevel";
import { addLocalhostAliases } from "../../utils/add-localhost-aliases";
import { throwIfCannotConnectToOrigin } from "../../utils/check-connection";
import { LOGICAL_ENVIRONMENT_VERSION } from "../../utils/constants";
import { safeEnsureBaseTestsExists } from "../../utils/ensure-base-exists.utils";
import { getEnvironment } from "../../utils/environment.utils";
import { getBaseAndHeadCommitShas } from "../../utils/get-base-and-head-commit-shas";
import { getCodeChangeEvent } from "../../utils/get-code-change-event";
import { initLogger, setLogLevel, shortSha } from "../../utils/logger.utils";
import { getOctokitOrFail } from "../../utils/octokit";
import { spinUpProxyIfNeeded } from "../../utils/proxy";
import { ResultsReporter } from "../../utils/results-reporter";
import { waitForDeploymentUrl } from "../../utils/wait-for-deployment-url";
import { throwIfCannotConnectToOrigin } from "../../common/check-connection";
import { safeEnsureBaseTestsExists } from "../../common/ensure-base-exists.utils";
import { getEnvironment } from "../../common/environment.utils";
import { getBaseAndHeadCommitShas } from "../../common/get-base-and-head-commit-shas";
import { getCodeChangeEvent } from "../../common/get-code-change-event";
import { initLogger, setLogLevel, shortSha } from "../../common/logger.utils";
import { getOctokitOrFail } from "../../common/octokit";
import { getMainActionInputs } from "./get-inputs";
import { addLocalhostAliases } from "./utils/add-localhost-aliases";
import { LOGICAL_ENVIRONMENT_VERSION } from "./utils/constants";
import { spinUpProxyIfNeeded } from "./utils/proxy";
import { ResultsReporter } from "./utils/results-reporter";
import { waitForDeploymentUrl } from "./utils/wait-for-deployment-url";

const EXECUTION_OPTIONS = {
...DEFAULT_EXECUTION_OPTIONS,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ export const EXPECTED_PERMISSIONS_BLOCK = [
// the environment changes in a way that would cause a replay to behave differently, e.g. upgrading to a newer
// replay-orchestrator-launcher version, or changing the version of puppeteer.
export const LOGICAL_ENVIRONMENT_VERSION = 5;

export const DOCS_URL = "https://app.meticulous.ai/docs/github-actions-v2";
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
RunningTestRunExecution,
} from "@alwaysmeticulous/sdk-bundles-api";
import log from "loglevel";
import { CodeChangeEvent } from "../types";
import { DOCS_URL } from "./constants";
import { DOCS_URL } from "../../../common/constants";
import {
DEFAULT_FAILED_OCTOKIT_REQUEST_MESSAGE,
isGithubPermissionsError,
} from "./error.utils";
import { shortSha } from "./logger.utils";
import { updateStatusComment } from "./update-status-comment";
} from "../../../common/error.utils";
import { shortSha } from "../../../common/logger.utils";
import { updateStatusComment } from "../../../common/update-status-comment";
import { CodeChangeEvent } from "../../../types";

const SHORT_SHA_LENGTH = 7;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { METICULOUS_LOGGER_NAME } from "@alwaysmeticulous/common";
import { Hub } from "@sentry/node";
import { Transaction } from "@sentry/types";
import log from "loglevel";
import { DOCS_URL, EXPECTED_PERMISSIONS_BLOCK } from "./constants";
import { isGithubPermissionsError } from "./error.utils";
import { DOCS_URL } from "../../../common/constants";
import { isGithubPermissionsError } from "../../../common/error.utils";
import { EXPECTED_PERMISSIONS_BLOCK } from "./constants";

const TIMEOUT_MS = 30 * 60 * 1_000; // 30 minutes
const MIN_POLL_FREQUENCY = 1_000;
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DOCS_URL = "https://app.meticulous.ai/docs/github-actions-v2";
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {
import { METICULOUS_LOGGER_NAME } from "@alwaysmeticulous/common";
import log from "loglevel";
import { Duration } from "luxon";
import { LOGICAL_ENVIRONMENT_VERSION } from "../actions/main/utils/constants";
import { CodeChangeEvent } from "../types";
import { DOCS_URL, LOGICAL_ENVIRONMENT_VERSION } from "./constants";
import { DOCS_URL } from "./constants";
import {
DEFAULT_FAILED_OCTOKIT_REQUEST_MESSAGE,
isGithubPermissionsError,
Expand Down Expand Up @@ -68,6 +69,7 @@ export const ensureBaseTestsExists = async ({
const testRun = await getLatestTestRunResults({
client: createClient({ apiToken }),
commitSha: base,
// TODO(in-cloud action): Set useCloudReplayEnvironmentVersion instead
logicalEnvironmentVersion: LOGICAL_ENVIRONMENT_VERSION,
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit afb4e4e

Please sign in to comment.