Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: generate schemas and documentation #8

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,37 @@ jobs:
make -j$(($(nproc)+1)) -C $(pwd)/build all
sudo make -C $(pwd)/build install

- name: Install Python dependencies for YAML schemas
run: |
sudo apt-get install python3-setuptools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@ynezz ynezz Apr 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that hard to check that the documentation is wrong. Who reads the documentation? :-) FYI real error I've tried to fix by that line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reported upstream, strange that they messed this up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it seems like they document and install python-setuptools for Python2, whereas I'm installing setuptools for Python3.

python3 -m pip install -U pip
python3 -m pip install -r requirements.txt

- name: Generate JSON schemas and documentation
run: ./generate.sh

- name: Run ucode based tests
run: ./run_tests.sh

- name: Generate abbreviated commit hash
run: echo "abbrev_commit=$(echo ${{ github.sha }} | cut -b1-8)" >> $GITHUB_ENV

- name: Upload documentation artifacts
uses: actions/upload-artifact@v2
with:
if-no-files-found: error
name: ucentral-schema-docs-${{ env.abbrev_commit }}
path: docs

- name: Create index.html for GitHub pages
run: |
cp docs/ucentral-schema.html docs/index.html
sed -i "s/Schema Docs/OpenWrt uCentral Schema Docs (${{ env.abbrev_commit }})/" docs/index.html
sed -i "s;Generated using;Generated from <a href=\"https://github.com/${{ github.repository }}/commit/${{ env.abbrev_commit}}\">${{ github.repository }}@${{ env.abbrev_commit }}</a> using;" docs/index.html

- name: Publish documentation
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ the datamodel and rendering incoming cfg json into uci batch sequences.
In order to run the test cases you will need the following tools
* [ucode](https://github.com/jow-/ucode)
* [ucentral-jsonschema](https://github.com/blogic/ucentral-jsonschema)
* jsonlint-php
* pip3 install jsonschema2md
* pip3 install json-schema-for-humans
* pip3 install python-json2yaml
* pip3 install -r requirements.txt

### Unit testing
```sh
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pyyaml>=5.3
json-schema-for-humans>=0.31.0
jsonschema2md>=0.1.1
python-json2yaml>=0.1.1
setuptools>=39.0.1