PalisadoesFoundation / talawa-api

API Backend for the Talawa Mobile App. Click on the link below to see our documentation
https://docs.talawa.io/
GNU General Public License v3.0
204 stars 671 forks source link

Feature Request : Documentation Automation: Bridging talawa-api and talawa-docs repositories #1897

Open tasneemkoushar opened 4 months ago

tasneemkoushar commented 4 months ago

The current approach to generating and synchronizing documentation between the talawa-api and talawa-docs repositories faces challenges related to branch protection rules and the specification of source and destination branches.

Current Workflow: talawa-api generates markdown files from inline tsdoc comments. These files are stored in a dedicated folder within the talawa-api repository. GitHub Actions encounters difficulties transferring these files to the talawa-docs repository, particularly due to some rules.

Challenges:

  1. Branch Protection Rules: The develop branch in talawa-api is safeguarded, impeding direct commits.
  2. Source and Destination Branch Specification: Complications arise in specifying source and destination branches for the documentation transfer.

Proposed Solution: Trigger the workflow on a schedule or in response to push events on the develop branch of talawa-api. Automate the generation of documentation files from inline comments (Already Implemented). Commit files directly to the specified branch and folder location in the talawa-docs repository.

Implementation Steps: Explore existing workflows for innovative insights and references. Fork the talawa-api and talawa-docs repository to kickstart the documentation automation. Conduct thorough local testing to validate the efficacy of the automation.

tasneemkoushar commented 4 months ago

Kindly share your strategy or solution to this problem along with the request that the issue be assigned. You may ask your doubts here in the chat. Take help from @anwersayeed

adi790uu commented 4 months ago

hey I would like to work on this

AdityaRaimec22 commented 4 months ago

Can I get assigned to the issue.

Olatade commented 4 months ago

@adi790uu @AdityaRaimec22

Kindly share your strategy or solution to this problem along with the request that the issue be assigned. You may ask your doubts here in the chat. Take help from @anwersayeed

adi790uu commented 4 months ago

Trigger the workflow on a schedule or in response to push events on the develop branch of talawa-api.

for this we can set up the workflow to be activated either by push events on the develop branch of talawa-api and we can schedule a recurring cron job.

palisadoes commented 4 months ago

cron only works on the default branch. We need this to work with any branch type and a filter for develop

adi790uu commented 4 months ago

correct me If I am wrong we need to trigger workflow only when there is a push or merge to the develop branch in talawa-api and after the workflows the docs are updated in automated-docs branch from there it has to be copied to talawa-docs repo? @anwersayeed

adi790uu commented 4 months ago

@Olatade @tasneemkoushar I have tried the whole workflow so I have a question that when we merge the code from any other branch, is workflow triggered? If not we need to implement that and somehow Copy-docs-to-talawa-docs workflow is getting success but the changes are not reflected in my forked talawa-docs repo.

anwersayeed commented 4 months ago

Hi @adi790uu @AdityaRaimec22 @adi790uu Yes, the workflow needs to be triggered either by a push event or on scheduled basis, but we do not necessarily need the automated-docs branch, the task is to send the generated docs to the talawa-docs repository. Hence, it would be better if we generate the documents and copy it directly to the talawa-docs location.

anwersayeed commented 4 months ago

@Olatade @tasneemkoushar I have tried the whole workflow so I have a question that when we merge the code from any other branch, is workflow triggered? If not we need to implement that and somehow Copy-docs-to-talawa-docs workflow is getting success but the changes are not reflected in my forked talawa-docs repo.

When copy-docs-to-talawa-docs workflow runs, you will be able to see some logs. There could be several reasons if the changes are not reflected.

  1. No changes detected (nothing to commit)
  2. You may be running the workflow in the automated-docs branch, try running the workflow in the develop or from the default branch by manually doing some changes to the documentation.
anwersayeed commented 4 months ago

We plan to not use this workflow "Copy-docs-to-talawa-docs". Either we find some alternative or write a script of our own.

anwersayeed commented 4 months ago

The workflow for the generation of the documentation files is already written, what we are looking for is a workflow or simply a script that runs with the push/ scheduled event, that copies these files from directly after generating them to the talawa-docs without committing them in between to any repositories or other branches.

palisadoes commented 4 months ago

Would this approach be viable?

  1. Generate the docs in the respective repos as we do now.
  2. Use a cron job in Docs to merge on top of the Docs default branch.
    1. We can change the default in Docs to develop and/or not use develop at all
adi790uu commented 4 months ago

@palisadoes so basically generating the docs in respective repos and then at a specific schedule get those changes from those repos?

palisadoes commented 4 months ago
  1. Possibly, especially if it can be proven to be reliable
  2. The current methodology is temperamental, however we don't know why.
adi790uu commented 4 months ago

Okay @palisadoes let me test this locally,I feel it's a good idea.

adi790uu commented 4 months ago

@Olatade can you assign me this issue.

anwersayeed commented 4 months ago

Hi @adi790uu, did you make any progress?

adi790uu commented 4 months ago

@anwersayeed I am currently working on the cron job part on talawa-docs repository, it would fetch all the latest changes in docs from respective repositories at particular schedule.

adi790uu commented 4 months ago

What's your opinion on this approach?

anwersayeed commented 4 months ago

@adi790uu Yeah, a centralised point to fetch all docs seems fine to me. Can you prepare a demo with dummy files and repositories?

adi790uu commented 4 months ago

@anwersayeed do you want me create an entirely new project and test as I was doing the testing and integration in talawa-docs repo.

adi790uu commented 4 months ago

@anwersayeed here is the script : #!/bin/bash

git clone --depth=1 --branch automated-docs https://github.com/adi790uu/talawa-api.git

mkdir -p docs/talawa-api-docs

cp -r talawa-api/talawa-api-docs/* docs/talawa-api-docs/

rm -rf talawa-api

ls

git config --global user.email "adi37068@gmail.com" git config --global user.name "adi790uu"

git add .

git commit -m "Pull changes from Talawa API automated-docs branch"

git push origin develop

adi790uu commented 4 months ago

@anwersayeed here is the script : #!/bin/bash

git clone --depth=1 --branch automated-docs https://github.com/adi790uu/talawa-api.git

mkdir -p docs/talawa-api-docs

cp -r talawa-api/talawa-api-docs/* docs/talawa-api-docs/

rm -rf talawa-api

ls

git config --global user.email "adi37068@gmail.com" git config --global user.name "adi790uu"

git add .

git commit -m "Pull changes from Talawa API automated-docs branch"

git push origin develop

basically will use this in a workflow and run a cron job each time the talawa-api-docs folder in talawa-docs will be replaced by latest available docs from automated-docs branch. Is this the right approach for solving this issue?

adi790uu commented 4 months ago

we can extend this for talawa-admin as well.

anwersayeed commented 4 months ago

@adi790uu Not necessarily a new project, this is fine. Complete your script, test it, and ping me.

adi790uu commented 4 months ago

@anwersayeed

Screenshot 2024-03-02 at 4 07 14 PM Screenshot 2024-03-02 at 4 07 23 PM

the workflow is working in case there are changes in talawa-api-docs and pushing it to develop branch in talawa-docs

adi790uu commented 4 months ago

this is the version of script used :

!/bin/bash

git clone --depth=1 --branch automated-docs https://github.com/adi790uu/talawa-api.git

mkdir -p docs/talawa-api-docs

cp -r talawa-api/talawa-api-docs/* docs/talawa-api-docs/

rm -rf talawa-api

git config --global user.email "adi37068@gmail.com" git config --global user.name "adi790uu"

git add .

git commit -m "Pull changes from Talawa API automated-docs branch"

git push origin develop

adi790uu commented 4 months ago

what change need to made here as I am using my credentials:

git config --global user.email "adi37068@gmail.com" git config --global user.name "adi790uu"

adi790uu commented 4 months ago

similarly we can clone mobile and admin repos add the doc folders to talawa-doc and push them to develop.

adi790uu commented 4 months ago

@anwersayeed I need your review on above so that I can proceed further with this.

adi790uu commented 4 months ago

@anwersayeed sorry for bothering you but can you please review above, I have to proceed with the complete implementation and testing.

anwersayeed commented 4 months ago

@adi790uu Please find me on the Slack channel. We may need to connect tomorrow for above changes.

adi790uu commented 4 months ago

@adi790uu Please find me on the Slack channel. We may need to connect tomorrow for above changes.

Okay @anwersayeed will ping you on slack

palisadoes commented 4 months ago

How's progress on this?

adi790uu commented 4 months ago

@palisadoes this will be completed soon, after @anwersayeed approve the latest changes I will create a PR.

adi790uu commented 3 months ago

@palisadoes I have created a PR in docs repo this is for api-docs only mobile-docs and admin-docs will have different Pr's as suggested by @anwersayeed

palisadoes commented 3 months ago

Please work with @anwersayeed and @tasneemkoushar to review and merge them

adi790uu commented 3 months ago

Okay @palisadoes

anwersayeed commented 3 months ago

I have provided some review comments, please address them. @adi790uu

adi790uu commented 3 months ago

@anwersayeed I had to create a new PR as somehow the previous PR got closed, I have implemented the suggested changes in new PR.

palisadoes commented 3 months ago

The documentation workflow isn't functioning. We really need it activated. Any news?

adi790uu commented 3 months ago

@palisadoes yeah I am aware of the issue and in contact with @anwersayeed we are discussing about this.

github-actions[bot] commented 3 months ago

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

github-actions[bot] commented 2 months ago

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

github-actions[bot] commented 2 months ago

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

palisadoes commented 1 month ago

unassigning, inactive

gautam-divyanshu commented 1 month ago

@anwersayeed Please help

anwersayeed commented 4 weeks ago

@gautam-divyanshu Hi, kindly text @tasneemkoushar on slack.

gautam-divyanshu commented 3 weeks ago

@palisadoes @anwersayeed @tasneemkoushar

Progress-

  1. Push workflow runs when a PR is merged to develop branch
  2. when PR is merged to develop then it creates a empty commit to automated-docs branch
  3. then after empty commit copy-docs-to-talawa-docs workflow runs

it's working locally on my forked repo.

image

image

image

image