Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quantum-kittens
GitHub Repository: quantum-kittens/platypus
Path: blob/main/scripts/content_checks/missing_nb_check.sh
3855 views
1
#!/usr/bin/env bash
2
3
# this script creates a `notebooks.txt` containing list of notebooks that
4
# are present in qiskit-community/qiskit-textbook but are not in
5
# Qiskit/platypus.
6
#
7
# this script is run from the `Check for Textbook notebooks` GitHub action
8
# which should contain a copy of the qiskit-textbook and platypus repos
9
10
11
# diff the notebooks directory of the two repos and add all notebooks found
12
# in qiskit-textbook but not found in platypus into a `notebooks.txt` file
13
diff -aqr platypus/notebooks qiskit-textbook/content | sort | grep 'Only in qiskit-textbook' | grep -E '\.ipynb$' > notebooks.txt
14
15
# count the number of lines (notebooks found) in qiskit-textbook but not in
16
# platypus
17
NUM_NB=$(cat notebooks.txt | wc -l)
18
19
echo 'found $NUM_NB new notebooks'
20
21
# set GitHub action variable to be checked by next step/task to determine
22
# if an issue should be created
23
echo '::set-output name=NUM_NB::$NUM_NB'
24
25
# replace all newline characters with `\n` so the list used in a JSON object
26
NB_LIST=$(sed -e :a -e '$!N;s/\n/\\n/;ta' notebooks.txt)
27
28
# create the JSON that will be used as payload for the create issue REST API
29
echo '{' > issue.txt
30
echo ' "title": "Missing notebooks",' >> issue.txt
31
echo ' "labels": ["bug"],' >> issue.txt
32
echo ' "assignees": ["vabarbosa", "frankharkins"],' >> issue.txt
33
echo ' "body": "'$NB_LIST'"' >> issue.txt
34
echo '}' >> issue.txt
35
36
exit 0
37
38