[POC] Interactive cookbooks + automated testing #1007
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: PR Build | |
on: | |
pull_request: | |
concurrency: | |
group: pr-${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
has_notebooks: ${{ steps.search-changed-files.outputs.has_notebooks }} | |
changed_cookbooks: ${{ steps.search-changed-files.outputs.changed_cookbooks }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v37 | |
- name: Find changed cookbooks | |
id: search-changed-files | |
shell: bash | |
run: | | |
CHANGED_COOKBOOKS=() | |
HAS_NOTEBOOKS=false | |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | |
if (grep -P "notebook:\s*true" $file); then | |
HAS_NOTEBOOKS=true | |
CHANGED_COOKBOOKS+=("$file") | |
fi | |
done | |
COOKBOOKS_STRING=$(echo ${CHANGED_COOKBOOKS[*]}) | |
echo "has_notebooks=$HAS_NOTEBOOKS" >> "$GITHUB_OUTPUT" | |
echo "changed_cookbooks=$COOKBOOKS_STRING" >> "$GITHUB_OUTPUT" | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
- run: | | |
cd .github/cds-snippet-checker | |
npm install | |
npm run check | |
- run: npm ci | |
- run: npm test | |
- run: npm run docs:build | |
- name: Tar build result # tar'ing is much faster than the built-in artifact zipping | |
run: tar -czf site.tgz -C .vitepress/dist/ . | |
- name: Upload build result | |
uses: actions/upload-artifact@v3 | |
with: | |
name: site | |
path: site.tgz | |
test: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: site | |
- name: Unpack Artifact | |
run: | | |
tar -xzf site.tgz -C . | |
- name: Checkout Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: zulu | |
java-version: 17 | |
- name: Set up Maven | |
uses: stCarolas/setup-maven@v4.5 | |
with: | |
maven-version: 3.8.8 | |
- name: Get CAP Notebooks | |
id: get-notebooks | |
shell: bash | |
run: | | |
NOTEBOOKS=() | |
CHANGED_COOKBOOKS=("${{ needs.build.outputs.changed_cookbooks }}") | |
while read mdfile nbfile; do | |
if [[ " ${CHANGED_COOKBOOKS[*]} " =~ " $mdfile " ]]; then | |
NOTEBOOKS+=("./notebooks/$nbfile") | |
fi | |
done < "./notebooks/generated_notebooks" | |
NOTEBOOKS_STRING="${NOTEBOOKS[*]}" | |
echo "notebooks=$NOTEBOOKS_STRING" >> "$GITHUB_OUTPUT" | |
- name: Test CAP Notebooks | |
uses: mnkiefer/notebook-runner@main | |
with: | |
notebook-files: ${{ steps.get-notebooks.outputs.notebooks }} | |
timeout: 200000 |