Skip to content

Commit

Permalink
gh actions: add more checks
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Remmert <[email protected]>
  • Loading branch information
jonas-rem committed Nov 1, 2024
1 parent 56aebee commit 768faef
Show file tree
Hide file tree
Showing 7 changed files with 1,381 additions and 112 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build

on: pull_request

jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.27.4
env:
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-0.17.0
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: waterlevel_monitor
fetch-depth: 0 # Fetch all history including tags

- name: Initialize
working-directory: waterlevel_monitor
run: |
pip3 install -U west
west init -l .
west update --narrow
pip3 install -r ../zephyr/scripts/requirements-base.txt
- name: Twister Tests for fw_tests
working-directory: waterlevel_monitor
shell: bash
run: |
west twister -T fw_test -v --inline-logs --integration
78 changes: 54 additions & 24 deletions .github/workflows/compliance.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
name: Build Sphinx Doc
name: Compliance Checks

on:
pull_request:
on: pull_request

jobs:
build-doc:
check_compliance:
runs-on: ubuntu-latest
steps:
- name: Update PATH for west
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Checkout the code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Checkout
uses: actions/checkout@v4
- name: cache-pip
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-doc-pip

- name: Install Packages
- name: Install python dependencies
run: |
sudo apt-get update
sudo apt-get install plantuml tox python3-pip -y
pip3 install setuptools
pip3 install wheel
pip3 install python-magic junitparser gitlint pylint pykwalify
- name: Build static site with Tox
- name: Run Compliance Tests
continue-on-error: true
id: compliance
env:
BASE_REF: ${{ github.base_ref }}
run: |
cd doc
tox -e py3-html
# debug
ls -la
git log --pretty=oneline | head -n 10
./ci/check_compliance.py -m checkpatch -m Gitlint -c origin/${BASE_REF}..
- name: Deploy Preview
uses: peaceiris/actions-gh-pages@v4
- name: upload-results
uses: actions/upload-artifact@v3
continue-on-error: True
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: doc/build/html
destination_dir: 'previews/${{ github.event.number }}'
name: compliance.xml
path: compliance.xml

- name: Create status check with preview link
- name: check-warns
run: |
PREVIEW_URL="https://flownexus-lwm2m.github.io/waterlevel_monitor/previews/${{ github.event.number }}"
PAYLOAD=$(echo '{}' | jq --arg name 'Documentation Preview' --arg url "${PREVIEW_URL}" '{"name": $name, "head_sha": "${{ github.event.pull_request.head.sha }}", "details_url": $url, "status": "completed", "conclusion": "success", "output": {"title": $name, "summary": "Preview available at", "text": $url}}')
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-X POST -d "${PAYLOAD}" \
"https://api.github.com/repos/${{ github.repository }}/check-runs"
if [[ ! -s "compliance.xml" ]]; then
exit 1;
fi
for file in Nits.txt checkpatch.txt Identity.txt Gitlint.txt pylint.txt Devicetree.txt Kconfig.txt; do
if [[ -s $file ]]; then
errors=$(cat $file)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=${file}::$errors"
exit=1
fi
done
if [ "${exit}" == "1" ]; then
exit 1;
fi
38 changes: 38 additions & 0 deletions .github/workflows/doc_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build Sphinx Doc

on:
pull_request:

jobs:
build-doc:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Install Packages
run: |
sudo apt-get update
sudo apt-get install plantuml tox python3-pip -y
- name: Build static site with Tox
run: |
cd doc
tox -e py3-html
- name: Deploy Preview
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: doc/build/html
destination_dir: 'previews/${{ github.event.number }}'

- name: Create status check with preview link
run: |
PREVIEW_URL="https://flownexus-lwm2m.github.io/waterlevel_monitor/previews/${{ github.event.number }}"
PAYLOAD=$(echo '{}' | jq --arg name 'Documentation Preview' --arg url "${PREVIEW_URL}" '{"name": $name, "head_sha": "${{ github.event.pull_request.head.sha }}", "details_url": $url, "status": "completed", "conclusion": "success", "output": {"title": $name, "summary": "Preview available at", "text": $url}}')
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-X POST -d "${PAYLOAD}" \
"https://api.github.com/repos/${{ github.repository }}/check-runs"
Loading

0 comments on commit 768faef

Please sign in to comment.