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

[MNT] Automated generation of result examples #434

Merged
merged 34 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e1dadc0
Added submodules
rmanaem Jan 9, 2025
a8f2a19
Updated submodules
rmanaem Jan 9, 2025
7b9b3b3
Added `UpdateExamples` e2e test
rmanaem Jan 9, 2025
74fd965
Added `Update examples` workflow
rmanaem Jan 9, 2025
c3c371a
Included the submodules in the checkout step
rmanaem Jan 9, 2025
52e4eac
Fixed typo in the file format
rmanaem Jan 9, 2025
7fc8a96
Added `update-query-tool-results` job
rmanaem Jan 10, 2025
577b742
Fixed the open condition
rmanaem Jan 10, 2025
983055b
Try checking out the examples repo directly
rmanaem Jan 10, 2025
e677e46
Fixed the oopsie
rmanaem Jan 10, 2025
7106d84
Let's try this
rmanaem Jan 10, 2025
1482317
Removed commit step
rmanaem Jan 10, 2025
2a1298a
Made a few small changes
rmanaem Jan 10, 2025
8d91c9e
Removed the debug step
rmanaem Jan 10, 2025
fd0603a
Added permissions
rmanaem Jan 10, 2025
934188c
Added pull-request permissions
rmanaem Jan 10, 2025
f4b8320
Updated a few things
rmanaem Jan 10, 2025
2398d37
Fixed the oopsie
rmanaem Jan 10, 2025
b690993
Let's use the latest version
rmanaem Jan 10, 2025
f130eb3
Removed the label
rmanaem Jan 10, 2025
1af7929
Maybe we need to configure git user idk
rmanaem Jan 10, 2025
04dcc94
A bit of cleaning up
rmanaem Jan 10, 2025
0ce4d33
Updated component-test workflow
rmanaem Jan 10, 2025
1172d21
Updated e2e-test workflow
rmanaem Jan 10, 2025
c2611c2
bumped download-artifact to v4
rmanaem Jan 10, 2025
e0020f1
Set the specPattern for cypress tests
rmanaem Jan 10, 2025
e2dfc93
Bumped create-pull-request to v7
rmanaem Jan 10, 2025
40a647a
Revert download-artifact to v3 thanks codeQL
rmanaem Jan 10, 2025
8d2d4a5
Revert download-artifact to v3 thanks codeQL 2nd round
rmanaem Jan 10, 2025
09bd896
Bumped artifact version
rmanaem Jan 10, 2025
4e185a9
Try using gh cli
rmanaem Jan 10, 2025
ccadfd1
Set git user
rmanaem Jan 10, 2025
c974014
Set the owner
rmanaem Jan 10, 2025
f319b21
Set the committer
rmanaem Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
rmanaem marked this conversation as resolved.
Show resolved Hide resolved

- 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

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'update examples' step
Uses Step
uses 'cypress-io/github-action' with ref 'v6', not a pinned commit hash
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/*
rmanaem marked this conversation as resolved.
Show resolved Hide resolved

update-query-tool-results:
Comment on lines +9 to +42

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions Job or Workflow does not set permissions
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

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'update examples' step
Uses Step: create_pr
uses 'peter-evans/create-pull-request' with ref 'v7', not a pinned commit hash
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
Comment on lines +43 to +77

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions Job or Workflow does not set permissions
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/*',
rmanaem marked this conversation as resolved.
Show resolved Hide resolved
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', () => {
rmanaem marked this conversation as resolved.
Show resolved Hide resolved
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
Loading