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

use snapshots when initiating github sync #2273

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

midigofrank
Copy link
Collaborator

@midigofrank midigofrank commented Jul 9, 2024

Validation Steps

You'll need these envs:

  • GITHUB_APP_ID
  • GITHUB_APP_NAME
  • GITHUB_APP_CLIENT_ID
  • GITHUB_APP_CLIENT_SECRET
  • GITHUB_CERT

You also need a github repo. I would advise that you create an empty repo in your account with just the README. I have one just like that for testing these github work: https://github.com/midigofrank/openfn

If you're testing this locally, you'll need a tunnelling tool. I always use https://ngrok.com/docs/getting-started/ .
Assuming you're using ngrok, run the command below and copy the URL generated.
Replace call to LightningWeb.Endpoint.url() using that URL in this line https://github.com/OpenFn/lightning/blob/main/lib/lightning/version_control/version_control.ex#L548
Please remember to undo this change once you're done

ngrok http 4000

How to validate
The aim is to initiate a sync and modify our workflow before the github action runs. We can achieve this by cancelling/stopping the github action and then later retry it.

  1. Open the Sync to Github tab under project settings page
  2. Click to connect your github account if you haven't already
  3. Have your github repo open in another tab
  4. Start the process, select your repo, branch, and chose the option to Sync to Github (OpenFn -> Github)
  5. Click save and rush to your github repo, under the actions tab, wait for the action .github/workflows/openfn-pull.yml and cancel it.
  6. Now go back to lightning and update your workflow name, or any job name and save
  7. Go back to your github repo actions and retry the action you cancelled in step 5
  8. Once the action completes, we expect that the yaml committed in your github repo NOT to contain the changes you did in Step 6. It should have the original workflow and job names

Notes for the reviewer

  • Send workflow snapshot ids to github when initiating github sync.
  • Optimize creating snapshots for workflows without one. I need some eyes here
  • Update priv/github/pull.yaml to handle the snapshot input sent
  • Handle pulling of state.json and project.yaml with snapshots. It expects the user to hit the endpoint with ?snapshots[]=uuid1&snapshots[]=uuid2&snapshots[]=uuid3.
    The logic for getting this data in the contexts has been modified to accept nil or list
  • Modify the cli-pull-action to use the snapshots. Here is the PR: Add flag for snapshots incase they're provided cli-pull-action#2.
    Notice that it adds the --snapshots flag only if the snapshots are provided.
    Also notice that priv/github/pull.yaml has been modified to use midigofrank/cli-pull-action. PLEASE REMEMBER TO REMOVE IT ONCE THE PR IN THE ORIGINAL REPO HAS BEEN MERGED AND A RELEASE PUBLISHED. The only reason I've used my fork is because I didn't want to litter the original repo with test releases
  • Update the cli pull command to accept the --snapshots option: CLI: add an option to pull that targets given snapshots kit#729

Related issue

Fixes #1827

Review checklist

  • I have performed a self-review of my code
  • I have verified that all appropriate authorization policies (:owner, :admin, :editor, :viewer) have been implemented and tested
  • If needed, I have updated the changelog
  • Product has QA'd this feature (TD approved after discussion with frank on slack. to be tested further on staging.)

@midigofrank midigofrank self-assigned this Jul 9, 2024
Copy link

codecov bot commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.86%. Comparing base (effd182) to head (f32f86b).
Report is 1 commits behind head on main.

Files Patch % Lines
lib/lightning/export_utils.ex 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2273      +/-   ##
==========================================
+ Coverage   89.85%   89.86%   +0.01%     
==========================================
  Files         299      299              
  Lines       10171    10195      +24     
==========================================
+ Hits         9139     9162      +23     
- Misses       1032     1033       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@christad92
Copy link

@midigofrank

@midigofrank midigofrank force-pushed the use-snapshots-for-github-sync branch from f87e580 to a633b23 Compare July 29, 2024 08:56
@midigofrank midigofrank marked this pull request as ready for review July 29, 2024 09:08
@stuartc stuartc removed the request for review from elias-ba July 30, 2024 08:05
@taylordowns2000 taylordowns2000 merged commit dbc9527 into main Jul 30, 2024
8 checks passed
@taylordowns2000 taylordowns2000 deleted the use-snapshots-for-github-sync branch July 30, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Make "Initiate Github Sync" take the latest snapshots at the time of initiation
4 participants