Skip to content

Commit 43086a6

Browse files
Add CI to run daily from scancode develop
* Use https for git clone * Add github actions to build licenseDB from scancode develop daily and push to repository Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 0f8852e commit 43086a6

File tree

5 files changed

+53
-17
lines changed

5 files changed

+53
-17
lines changed

.github/workflows/daily-update.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Update LicenseDB with latest updates from scancode-toolkit develop daily
2+
on:
3+
schedule:
4+
- cron: '0 16 * * 0-6'
5+
6+
jobs:
7+
update_licenseDB:
8+
name: Daily LicenseDB Update
9+
runs-on: ubuntu-latest
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: 3.8
22+
23+
- name: Give execute access to the script
24+
run: chmod u+x ./etc/scripts/check_commit_run_update.sh
25+
26+
- name: Run script
27+
run: ./etc/scripts/check_commit_run_update.sh
28+
29+
- name: Commit and Push to Publish
30+
run: |
31+
git config --global user.name 'LicenseDB Update GitHub Action'
32+
git config --global user.email '[email protected]'
33+
git commit -am "Automated LicenseDB update with latest from scancode-toolkit develop"
34+
git push

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ BLACK_ARGS=--exclude="docs" .
3636
conf:
3737
@echo "-> Configure the Python venv, clone and install scancode-toolkit"
3838
${PYTHON_EXE} -m venv venv
39-
@git clone git@github.com:nexB/scancode-toolkit.git
39+
@git clone https://github.com/nexB/scancode-toolkit.git
4040
@venv/bin/pip install --upgrade pip
4141
@venv/bin/pip install -e ./scancode-toolkit/
4242

4343
restore:
44-
# Restores the repository to a clean state
44+
@echo "-> Restoring the repository to a clean state"
4545
git clean -fd
4646
rm -rf scancode-toolkit/
4747
git restore --worktree docs/
@@ -54,15 +54,15 @@ clean:
5454

5555
html:
5656
@echo "-> Generate the HTML content"
57-
@venv/bin/scancode --dump-license-data docs/
57+
@venv/bin/scancode-license-data --path docs/
5858
@echo "Available at docs/index.html"
5959

6060
build: conf html
6161

6262
publish:
6363
@echo "-> Add changes to git"
6464
@git add .
65-
git commit -m "Upgrade ScanCode-toolkit to latest version"
65+
git commit -m "Upgrade with latest updates from ScanCode-toolkit develop"
6666
@echo "-> Push changes to main repo"
6767
@git push
6868

README.rst

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Browse
2828
The web site is published at: https://scancode-licensedb.aboutcode.org/
2929
You can search the licenses by name, key and other attributes.
3030

31+
This is updated daily by a GitHub action with updates from scancode-toolkit
32+
develop, if any.
33+
3134

3235
API
3336
------
@@ -51,7 +54,9 @@ license details and texts using this license key as an identifier:
5154

5255

5356
This index and the static website is also available offline with ScanCode Toolkit as a
54-
command line option `--get-license-data`.
57+
console script available at configure/install. Sample command::
58+
59+
scancode-license-data --path PATH
5560

5661

5762
Git
@@ -82,16 +87,7 @@ Build
8287

8388
To re/generate the HTML and API content use this command::
8489

85-
$ make build
86-
87-
88-
Upgrade
89-
-------
90-
91-
To upgrade to the latest scancode-toolkit and generate the HTML and API content
92-
run this command::
93-
94-
$ make clean upgrade build publish
90+
$ make restore conf html
9591

9692

9793
License

etc/scripts/check_commit.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ def cli(commit):
5050
data_commit_old = load_json(path=path)
5151
commit_old = data_commit_old["commit_hash"]
5252

53+
msg = (
54+
f"There are no new commits in scancode-toolkit develop after {commit_old}."
55+
"Aborting LicenseDB update."
56+
)
57+
5358
if commit == commit_old:
54-
raise NoNewCommitException("There are no new commits in scancode-toolkit develop")
59+
raise NoNewCommitException(msg)
5560
else:
61+
click.secho(f" -> There are new commits in scancode-toolkit develop, updating last commit to {commit}.")
5662
data_commit_old["commit_hash"] = commit
5763
write_json(data=data_commit_old, path=path)
5864

etc/scripts/check_commit_run_update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cd ../
1616
# Check if scancode develop has new commits
1717
# if yes, update latest commit and continue
1818
# if no, fail here
19-
python3 ./etc/scripts/check_commit.py --commit "$COMMIT_LATEST"
19+
venv/bin/python ./etc/scripts/check_commit.py --commit "$COMMIT_LATEST"
2020

2121
# build docs
2222
make html

0 commit comments

Comments
 (0)