Skip to content

Commit

Permalink
rename to GithubActions
Browse files Browse the repository at this point in the history
  • Loading branch information
krzkaczor committed Sep 3, 2019
1 parent b68528a commit d25fcde
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Env, CiProvider } from "./types";

export class Github implements CiProvider {
export class GithubActions implements CiProvider {
constructor(private readonly env: Env) {}

isCurrentlyRunning(): boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { join } from "path";

import { readEnvFile } from "./utils";
import { Github } from "../Github";
import { GithubActions } from "../GithubActions";

describe("Github", () => {
describe("Github Actions", () => {
const env = readEnvFile(join(__dirname, "__fixtures__", "github/pr.env"));
const envFork = readEnvFile(join(__dirname, "__fixtures__", "github/fork.env"));
const envNoPR = readEnvFile(join(__dirname, "__fixtures__", "github/nopr.env"));
Expand All @@ -16,43 +16,43 @@ describe("Github", () => {
envNoPR.GITHUB_EVENT_PATH = join(__dirname, envNoPR.GITHUB_EVENT_PATH || "");

it("should detect github", () => {
const provider = new Github(env);
const provider = new GithubActions(env);

expect(provider.isCurrentlyRunning()).toBe(true);
});

it("should not detect github when not running inside github", () => {
const provider = new Github({});
const provider = new GithubActions({});

expect(provider.isCurrentlyRunning()).toBe(false);
});

it("should get pull request id", () => {
const provider = new Github(env);
const provider = new GithubActions(env);

expect(provider.getPullRequestID()).toBe(2);
});

it("should not get pull request id if not running in PR context", () => {
const provider = new Github(envNoPR);
const provider = new GithubActions(envNoPR);

expect(provider.getPullRequestID()).toBeUndefined();
});

it("should get target SHA", () => {
const provider = new Github(env);
const provider = new GithubActions(env);

expect(provider.getCurrentSha()).toBe("ffac537e6cbbf934b08745a378932722df287a53");
});

it("should not detect fork mode", () => {
const provider = new Github(env);
const provider = new GithubActions(env);

expect(provider.isFork()).toBe(false);
});

it("should detect fork mode", () => {
const provider = new Github(envFork);
const provider = new GithubActions(envFork);

expect(provider.isFork()).toBe(true);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/ci-providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Circle } from "./Circle";
import { Travis } from "./Travis";
import { Semaphore } from "./Semaphore";
import { BuildKite } from "./BuildKite";
import { Github } from "./Github";
import { GithubActions } from "./GithubActions";

import { CiProvider, Env } from "./types";
import { crash } from "../utils/errors";
Expand All @@ -14,7 +14,7 @@ const providers: { new (env: Env, localProject?: string): CiProvider }[] = [
Semaphore,
BuildKite,
LocalProvider,
Github,
GithubActions,
];

// @todo refactor passing CLI options
Expand Down

0 comments on commit d25fcde

Please sign in to comment.