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

Update schema.graphql #26

Merged
merged 24 commits into from
Aug 20, 2024
Merged
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
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ on:
pull_request:
branches:
- main
paths:
- 'subgraphs/employees/schema.graphql'
- 'subgraphs/family/schema.graphql'
- 'subgraphs/products/schema.graphql'
- 'subgraphs/hobbies/schema.graphql'
types:
- opened
- reopened
Expand Down
133 changes: 96 additions & 37 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ export const getFilteredChangedFiles = ({
export const getRemovedGraphQLFilesInLastCommit = async ({
githubToken,
prNumber,
changedGraphQLFilesInPr,
}: {
githubToken: string;
prNumber: number;
changedGraphQLFilesInPr: string[];
}) => {
const octokit = github.getOctokit(githubToken);

Expand Down Expand Up @@ -150,14 +152,17 @@ export const getRemovedGraphQLFilesInLastCommit = async ({
}

// Filter out the files that were removed
const removedFiles = commitFiles.data.files?.filter((file) => file.status === 'removed');
const removedFilePaths = removedFiles.map((file) => file.filename);
const modifiedFiles = commitFiles.data.files?.filter((file) => file.status === 'modified');
const modifiedFilePaths = modifiedFiles.map((file) => file.filename);

const removedGraphQLFiles: string[] = mm(removedFilePaths, ['**/*.graphql', '**/*.gql', '**/*.graphqls'], {
const modifiedGraphQLFiles: string[] = mm(modifiedFilePaths, ['**/*.graphql', '**/*.gql', '**/*.graphqls'], {
dot: true,
noext: true,
}).map((element) => normalizeSeparators(element));
console.log('Removed files:', removedFilePaths, removedGraphQLFiles);

// find the file changes which exist in the last commit, but not in the current PR
// happens when a file is removed in the last commit, or when the changes are reverted.
const removedGraphQLFiles = modifiedGraphQLFiles.filter((file) => !changedGraphQLFilesInPr.includes(file));

return removedGraphQLFiles;
};
Loading