Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint 8 Support #73

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ Thumbs.db
__tests__/runner/*
# dont ignore lib files so we dont need to build in action
# lib/**/*
README.md
README.md
.idea/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14
FROM node:16

# LABEL com.github.actions.name="ESLint Action"
# LABEL com.github.actions.description="Lint your Javascript projects with inline lint error annotations on pull requests."
Expand Down
148 changes: 74 additions & 74 deletions lib/api.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCurrentWorkflow = exports.updateCheck = exports.createCheck = exports.fetchFilesBatchCommit = exports.fetchFilesBatchPR = void 0;
const tslib_1 = require("tslib");
const core = tslib_1.__importStar(require("@actions/core"));
const constants_1 = require("./constants");
function fetchFilesBatchPR(client, prNumber, startCursor, owner = constants_1.OWNER, repo = constants_1.REPO) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCurrentWorkflow = exports.updateCheck = exports.createCheck = exports.fetchFilesBatchCommit = exports.fetchFilesBatchPR = void 0;
const tslib_1 = require("tslib");
const core = tslib_1.__importStar(require("@actions/core"));
const constants_1 = require("./constants");
function fetchFilesBatchPR(client, prNumber, startCursor, owner = constants_1.OWNER, repo = constants_1.REPO) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { repository } = yield client.graphql(`
query ChangedFilesBatch(
$owner: String!
Expand All @@ -31,69 +31,69 @@ function fetchFilesBatchPR(client, prNumber, startCursor, owner = constants_1.OW
}
}
}
`, { owner, repo, prNumber, startCursor });
const pr = repository.pullRequest;
if (!pr || !pr.files) {
core.info(`No PR or PR files detected`);
return { files: [] };
}
core.info(`PR with files detected: ${pr.files.edges.map((e) => e.node.path)}`);
return Object.assign(Object.assign({}, pr.files.pageInfo), { files: pr.files.edges.map((e) => e.node.path) });
});
}
exports.fetchFilesBatchPR = fetchFilesBatchPR;
function fetchFilesBatchCommit(client, data, owner = constants_1.OWNER, repo = constants_1.REPO) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {
const resp = yield client.repos.getCommit({
owner,
repo,
ref: data.sha,
});
const filesChanged = resp.data.files.map((f) => f.filename);
core.info(`Files changed: ${filesChanged}`);
return filesChanged;
}
catch (err) {
core.error(err);
return [];
}
});
}
exports.fetchFilesBatchCommit = fetchFilesBatchCommit;
function createCheck(client, data, owner = constants_1.OWNER, repo = constants_1.REPO) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const params = {
name: constants_1.NAME,
head_sha: data.sha,
status: 'in_progress',
started_at: new Date().toISOString(),
owner,
repo,
};
const createCheckResult = yield client.checks.create(params);
data.state.checkId = createCheckResult.data.id;
return (nextParams) => updateCheck(createCheckResult, data, client, owner, repo, nextParams);
});
}
exports.createCheck = createCheck;
function updateCheck(createCheckResult, data, client, owner, repo, nextParams) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const params = Object.assign({ name: constants_1.NAME, check_run_id: createCheckResult.data.id, status: 'in_progress', owner,
repo }, nextParams);
const result = yield client.checks.update(params);
return result;
});
}
exports.updateCheck = updateCheck;
function getCurrentWorkflow(client, data, owner = constants_1.OWNER, repo = constants_1.REPO) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const workflows = yield client.actions.listRepoWorkflows({
owner,
repo,
});
const currentWorkflow = workflows.data.workflows.find((workflow) => workflow.name === data.name);
return currentWorkflow;
});
}
exports.getCurrentWorkflow = getCurrentWorkflow;
`, { owner, repo, prNumber, startCursor });
const pr = repository.pullRequest;
if (!pr || !pr.files) {
core.info(`No PR or PR files detected`);
return { files: [] };
}
core.info(`PR with files detected: ${pr.files.edges.map((e) => e.node.path)}`);
return Object.assign(Object.assign({}, pr.files.pageInfo), { files: pr.files.edges.map((e) => e.node.path) });
});
}
exports.fetchFilesBatchPR = fetchFilesBatchPR;
function fetchFilesBatchCommit(client, data, owner = constants_1.OWNER, repo = constants_1.REPO) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {
const resp = yield client.repos.getCommit({
owner,
repo,
ref: data.sha,
});
const filesChanged = resp.data.files.map((f) => f.filename);
core.info(`Files changed: ${filesChanged}`);
return filesChanged;
}
catch (err) {
core.error(err);
return [];
}
});
}
exports.fetchFilesBatchCommit = fetchFilesBatchCommit;
function createCheck(client, data, owner = constants_1.OWNER, repo = constants_1.REPO) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const params = {
name: constants_1.NAME,
head_sha: data.sha,
status: 'in_progress',
started_at: new Date().toISOString(),
owner,
repo,
};
const createCheckResult = yield client.checks.create(params);
data.state.checkId = createCheckResult.data.id;
return (nextParams) => updateCheck(createCheckResult, data, client, owner, repo, nextParams);
});
}
exports.createCheck = createCheck;
function updateCheck(createCheckResult, data, client, owner, repo, nextParams) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const params = Object.assign({ name: constants_1.NAME, check_run_id: createCheckResult.data.id, status: 'in_progress', owner,
repo }, nextParams);
const result = yield client.checks.update(params);
return result;
});
}
exports.updateCheck = updateCheck;
function getCurrentWorkflow(client, data, owner = constants_1.OWNER, repo = constants_1.REPO) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const workflows = yield client.actions.listRepoWorkflows({
owner,
repo,
});
const currentWorkflow = workflows.data.workflows.find((workflow) => workflow.name === data.name);
return currentWorkflow;
});
}
exports.getCurrentWorkflow = getCurrentWorkflow;
Loading