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

Detect deletion of slides #1430

Closed
wants to merge 5 commits into from
Closed

Detect deletion of slides #1430

wants to merge 5 commits into from

Conversation

Gourav2609
Copy link
Contributor

closes issue #1417

@Gourav2609
Copy link
Contributor Author

any suggestions🙂 ?

Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to be able to test this out. We could do so in this PR, but maybe a better approach would be to put this functionality in a shell script that could also be run locally, for testing purposes.

- name: List deleted slides
id: deleted-slides
run: |
deleted_slides=$(git diff --name-only HEAD^ HEAD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will include all modified slides, right?

Also, this only compares HEAD^ to HEAD -- what if the PR has multiple commits in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated it in my new commit .

for slide in $deleted_slides; do
slide_filename=$(basename -- "$slide")
slide_name="${slide_filename%.*}"
entry_exists=$(grep -c "\[slide.$slide_name\]" book.toml)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this pattern is intended to match. It looks like a character class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pattern "\[slide.$slide_name\]" is not intended to create a character class. Instead, it is meant to match a string in the format of [slide.slide_name] where slide_name is a placeholder for the actual name of the slide.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah -- and where does that appear in book.toml?

@djmitche
Copy link
Collaborator

Oh, and please update the title of the PR to reflect what it does.

@Gourav2609 Gourav2609 changed the title updated workflow Detect deletion of slides Oct 25, 2023
Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like to have a way to test this! I suspect this won't work as written (at least since it's looking for a pattern that doesn't exist in the file), but it's hard to tell for sure.

base_branch=$(jq -r .pull_request.base.ref "$GITHUB_EVENT_PATH")
echo "base_branch=$base_branch" >> $GITHUB_ENV
else
echo "base_branch=" >> $GITHUB_ENV
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will end up running git diff ...HEAD on anything that is not a pull request, which does nothing. If that is the intent, perhaps this action should only run on pull requests?


- name: Set deleted slides in an environment file
run: |
base_branch="${{ env.base_branch }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to spread this processing over multiple workflow steps? Couldn't this all be accomplished in a single step?

@Gourav2609
Copy link
Contributor Author

sry @djmitche for late reply ... will soon come up with changes

@randomPoison randomPoison added the waiting for author Waiting on the issue author to reply label Nov 7, 2023
@mgeisler
Copy link
Collaborator

Hi @Gourav2609, thanks for looking at this issue!

As a high-level comment, I would like code such as this to be written in Python. See https://github.com/google/comprehensive-rust/blob/main/.github/workflows/check-msgid-changes.yml which calls directly out to https://github.com/google/comprehensive-rust/blob/main/.github/workflows/check-msgid-changes.py.

We cannot maintain large amounts of Bash code, so that is why I think we should write this in a high-level language instead.

@djmitche
Copy link
Collaborator

@Gourav2609 are you able to continue working on this?

@Gourav2609
Copy link
Contributor Author

@djmitche sry.. Got a little busy with college hackathon.. Will soon start working on it

@djmitche
Copy link
Collaborator

djmitche commented Oct 3, 2024

Closing this as stale..

@djmitche djmitche closed this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for author Waiting on the issue author to reply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants