generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 104
94 lines (90 loc) · 2.81 KB
/
PR.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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