fix errors found in nightly #2354
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate Notebooks Metadata | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- 'notebooks/**/*.ipynb' | |
concurrency: | |
group: ${{ github.head_ref || github.ref_name }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
validate_notebooks_metadata: | |
runs-on: ubuntu-20.04 | |
name: Validate notebooks metadata | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
with: | |
node-version: 18 | |
- name: Get changed notebook files | |
id: get_changed_notebook_files | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
script: | | |
const { execSync } = require('child_process'); | |
const { commits } = context.payload.pull_request; | |
const gitDiffCommand = `git diff --name-only --relative=notebooks --diff-filter=d HEAD~${commits} -- *.ipynb ':!notebooks/utils'`; | |
const changedNotebooks = execSync(gitDiffCommand).toString().split('\n').filter(Boolean); | |
core.exportVariable('CHANGED_NOTEBOOKS', JSON.stringify(changedNotebooks)); | |
- name: Install Node.js dependencies | |
working-directory: ./selector | |
shell: bash | |
run: npm ci | |
- name: Validate changed notebooks metadata | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
script: | | |
const { NotebookMetadataHandler } = await import('${{ github.workspace }}/selector/src/notebook-metadata/notebook-metadata-handler.js'); | |
const changedNotebooks = JSON.parse(process.env.CHANGED_NOTEBOOKS); | |
const [error, metadataMarkdowns] = NotebookMetadataHandler.validateNotebooks(changedNotebooks); | |
core.summary.addHeading(`Modified Notebooks (${metadataMarkdowns.length})`, '2'); | |
core.summary.addRaw(metadataMarkdowns.join('\n\n')); | |
core.summary.write(); | |
if (error) { | |
core.setFailed(error); | |
} |