Skip to content

Commit

Permalink
[MNT] Automated generation of result examples (#434)
Browse files Browse the repository at this point in the history
* Added submodules

* Updated submodules

* Added `UpdateExamples` e2e test

* Added `Update examples` workflow

* Included the submodules in the checkout step

* Fixed typo in the file format

* Added `update-query-tool-results` job

* Fixed the open condition

* Try checking out the examples repo directly

* Fixed the oopsie

* Let's try this

* Removed commit step

* Made a few small changes

* Removed the debug step

* Added permissions

* Added pull-request permissions

* Updated a few things

* Fixed the oopsie

* Let's use the latest version

* Removed the label

* Maybe we need to configure git user idk

* A bit of cleaning up

* Updated component-test workflow

* Updated e2e-test workflow

* bumped download-artifact to v4

* Set the specPattern for cypress tests

* Bumped create-pull-request to v7

* Revert download-artifact to v3 thanks codeQL

* Revert download-artifact to v3 thanks codeQL 2nd round

* Bumped artifact version

* Try using gh cli

* Set git user

* Set the owner

* Set the committer
  • Loading branch information
rmanaem authored Jan 13, 2025
1 parent 9bd09fc commit 14e66df
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/component-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Create .env file
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Set up node env
uses: actions/setup-node@v4
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/updated_examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: update examples

on:
pull_request:
workflow_dispatch:

jobs:
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/*

update-query-tool-results:
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
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
specPattern: 'cypress/e2e/*',
experimentalStudio: true,
baseUrl: 'http://localhost:5173',
},

component: {
specPattern: 'cypress/component/*',
devServer: {
framework: 'react',
bundler: 'vite',
Expand Down
18 changes: 18 additions & 0 deletions cypress/e2e/UpdateExamples.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fapiQuerySuccess200 from '../../neurobagel_examples/api-responses/fapi_query_success_200.json';

describe('Update Examples', () => {
it('Removes a newline character from a dataset name in the downloaded dataset-level results file', () => {
cy.intercept('GET', 'query*', (req) => {
req.reply(fapiQuerySuccess200);
}).as('call');
cy.visit('/');
cy.get('[data-cy="close-auth-dialog-button"]').click();
cy.get('[data-cy="submit-query-button"]').click();
cy.wait('@call');
cy.get('[data-cy="select-all-checkbox"]').find('input').check();
cy.get('[data-cy="download-results-button"]').click();
cy.get('[data-cy="download-results-dropdown-button"]').click();
cy.contains('URIs').click();
cy.get('[data-cy="download-results-button"]').click();
});
});
1 change: 1 addition & 0 deletions neurobagel_examples
Submodule neurobagel_examples added at 5690cd
1 change: 1 addition & 0 deletions recipes
Submodule recipes added at f52d2f

0 comments on commit 14e66df

Please sign in to comment.