-
Notifications
You must be signed in to change notification settings - Fork 3
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
[MNT] Automated generation of result examples #434
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request introduces a new GitHub Actions workflow to automatically update the Sequence diagram for automated example generation workflowsequenceDiagram
participant GH as GitHub Actions
participant CT as Cypress Tests
participant API as Mock FAPI
participant Art as Artifacts
participant Ex as neurobagel_examples repo
GH->>CT: Run e2e tests
CT->>API: Mock API request
API-->>CT: Return mock response
CT->>Art: Save result files as artifacts
GH->>Art: Download artifacts
GH->>Ex: Create PR with updated files
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
✅ Deploy Preview for neurobagel-query ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
run: npm install && npm run build | ||
|
||
- name: Run end to end tests | ||
uses: cypress-io/github-action@v6 |
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium
Uses Step
|
||
- name: Create Pull Request | ||
id: create_pr | ||
uses: peter-evans/create-pull-request@v7 |
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium
Uses Step: create_pr
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Set up node env | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Create .env file | ||
run: | | ||
echo -e "NB_API_QUERY_URL=https://federate.neurobagel.org/\nNB_ENABLE_AUTH=true\nNB_QUERY_CLIENT_ID=mockclientid" > .env | ||
- name: build | ||
run: npm install && npm run build | ||
|
||
- name: Run end to end tests | ||
uses: cypress-io/github-action@v6 | ||
with: | ||
wait-on: http://localhost:5173 | ||
start: npm run preview | ||
spec: cypress/e2e/UpdateExamples.cy.ts | ||
component: false | ||
|
||
- name: Upload test artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: query-tool-results | ||
path: cypress/downloads/* | ||
|
||
update-query-tool-results: |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
runs-on: ubuntu-latest | ||
needs: generate-example-files | ||
steps: | ||
- name: Generate a token | ||
id: generate-token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ vars.NB_BOT_ID }} | ||
private-key: ${{ secrets.NB_BOT_KEY }} | ||
owner: ${{ github.repository_owner }} | ||
|
||
- name: Checkout neurobagel_examples repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: neurobagel/neurobagel_examples | ||
token: ${{ steps.generate-token.outputs.token }} | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: query-tool-results | ||
path: neurobagel_examples/query-tool-results | ||
|
||
- name: Create Pull Request | ||
id: create_pr | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
token: ${{ steps.generate-token.outputs.token }} | ||
commit-message: Update `query-tool-results` files | ||
title: Update `query-tool-results` files | ||
body: "This PR updates the `query-tool-results` files with the latest changes." | ||
base: main | ||
branch: update-query-tool-results | ||
committer: NeuroBagel Bot <neurobagel-bot[bot]@users.noreply.github.com> | ||
labels: _bot |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rmanaem for fixing this! Very cool workflow.
I left one idea comment, and one request to change before merging (about comment in the test). Take a look, but I'll approve now already
🧑🍳
generate-example-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Set up node env | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Create .env file | ||
run: | | ||
echo -e "NB_API_QUERY_URL=https://federate.neurobagel.org/\nNB_ENABLE_AUTH=true\nNB_QUERY_CLIENT_ID=mockclientid" > .env | ||
- name: build | ||
run: npm install && npm run build | ||
|
||
- name: Run end to end tests | ||
uses: cypress-io/github-action@v6 | ||
with: | ||
wait-on: http://localhost:5173 | ||
start: npm run preview | ||
spec: cypress/e2e/UpdateExamples.cy.ts | ||
component: false | ||
|
||
- name: Upload test artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: query-tool-results | ||
path: cypress/downloads/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could just skip this whole job and instead make the existing e2e test workflow upload this artefact. There is a nice mechanism for this available: https://github.com/github/docs/blob/main/content/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows.md#using-data-from-the-triggering-workflow
But cypress/e2e/UpdateExamples.cy.ts
isn't a test, but just a way to use cypress to make the example files. So maybe it's more confusing to use the e2e test outputs. In either case, that would be a change for a future PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, the main reason I kept it separate from the other workflow is because we generate the result files with different content in other tests and if I'm not mistaken cypress overwrites them so depending on which test runs first we might end up with the wrong examples in the neurobage_examples repo.
@@ -3,11 +3,13 @@ import { defineConfig } from 'cypress'; | |||
|
|||
export default defineConfig({ | |||
e2e: { | |||
specPattern: 'cypress/e2e/*', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of interest: what does this do and why is it needed?
Changes proposed in this pull request:
neurobagel_examples
repoNOTE: If this pull request is to be released, the release label must be applied once the review process is done to avoid the local and remote from going out of sync as a consequence of the
bump version
workflow runChecklist
This section is for the PR reviewer
[ENH]
,[FIX]
,[REF]
,[TST]
,[CI]
,[MNT]
,[INF]
,[MODEL]
,[DOC]
) (see our Contributing Guidelines for more info)skip-release
(to be applied by maintainers only)Closes #XXXX
query-tool-results
files in the neurobagel_examples repo have been regeneratedFor new features:
For bug fixes:
Summary by Sourcery
Add a workflow to automatically update the query-tool-results example files in the neurobagel_examples repository.
CI:
Tests: