Skip to content

Commit 19aa6f2

Browse files
committed
workflow: setup basic workflow for checking PRs
* Sets up a workflow that will take care of code formatting in PRs * Create license_config.yml * Create license_check.yml * Add coding guidelines check as well taken from zephyrproject upstream Signed-off-by: Dhruva Gole <d-gole@ti.com>
1 parent 5a76d45 commit 19aa6f2

File tree

4 files changed

+138
-0
lines changed

4 files changed

+138
-0
lines changed

.github/license_config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
license:
2+
main: apache-2.0
3+
report_missing: true
4+
category: Permissive
5+
copyright:
6+
check: true
7+
exclude:
8+
extensions:
9+
- yml
10+
- yaml
11+
- html
12+
- rst
13+
- conf
14+
- cfg
15+
langs:
16+
- HTML

.github/workflows/checkpatch.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "main" branch
8+
push:
9+
branches: [ "main" ]
10+
pull_request:
11+
branches: [ "main" ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
build:
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
# Steps represent a sequence of tasks that will be executed as part of the job
24+
steps:
25+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26+
- uses: actions/checkout@v3
27+
- name: checkpatch.pl PR review
28+
uses: webispy/checkpatch-action@v8
29+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Coding Guidelines
2+
3+
on: pull_request
4+
5+
jobs:
6+
compliance_job:
7+
runs-on: ubuntu-20.04
8+
name: Run coding guidelines checks on patch series (PR)
9+
steps:
10+
- name: Checkout the code
11+
uses: actions/checkout@v2
12+
with:
13+
ref: ${{ github.event.pull_request.head.sha }}
14+
fetch-depth: 0
15+
16+
- name: cache-pip
17+
uses: actions/cache@v1
18+
with:
19+
path: ~/.cache/pip
20+
key: ${{ runner.os }}-doc-pip
21+
22+
- name: Install python dependencies
23+
run: |
24+
pip3 install unidiff
25+
pip3 install wheel
26+
pip3 install sh
27+
28+
- name: Install Packages
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install ocaml-base-nox
32+
wget https://launchpad.net/~npalix/+archive/ubuntu/coccinelle/+files/coccinelle_1.0.8~20.04npalix1_amd64.deb
33+
sudo dpkg -i coccinelle_1.0.8~20.04npalix1_amd64.deb
34+
35+
- name: Run Coding Guildeines Checks
36+
continue-on-error: true
37+
id: coding_guidelines
38+
env:
39+
BASE_REF: ${{ github.base_ref }}
40+
run: |
41+
export ZEPHYR_BASE=$PWD
42+
git config --global user.email "actions@zephyrproject.org"
43+
git config --global user.name "Github Actions"
44+
git remote -v
45+
git rebase origin/${BASE_REF}
46+
source zephyr-env.sh
47+
# debug
48+
ls -la
49+
git log --pretty=oneline | head -n 10
50+
./scripts/ci/guideline_check.py --output output.txt -c origin/${BASE_REF}..
51+
52+
- name: check-warns
53+
run: |
54+
if [[ -s "output.txt" ]]; then
55+
errors=$(cat output.txt)
56+
errors="${errors//'%'/'%25'}"
57+
errors="${errors//$'\n'/'%0A'}"
58+
errors="${errors//$'\r'/'%0D'}"
59+
echo "::error file=output.txt::$errors"
60+
exit 1;
61+
fi

.github/workflows/license_check.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Scancode
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
scancode_job:
7+
runs-on: ubuntu-20.04
8+
name: Scan code for licenses
9+
steps:
10+
- name: Checkout the code
11+
uses: actions/checkout@v1
12+
- name: Scan the code
13+
id: scancode
14+
uses: zephyrproject-rtos/action_scancode@v4
15+
with:
16+
directory-to-scan: 'scan/'
17+
- name: Artifact Upload
18+
uses: actions/upload-artifact@v1
19+
with:
20+
name: scancode
21+
path: ./artifacts
22+
23+
- name: Verify
24+
run: |
25+
if [ -s ./artifacts/report.txt ]; then
26+
report=$(cat ./artifacts/report.txt)
27+
report="${report//'%'/'%25'}"
28+
report="${report//$'\n'/'%0A'}"
29+
report="${report//$'\r'/'%0D'}"
30+
echo "::error file=./artifacts/report.txt::$report"
31+
exit 1
32+
fi

0 commit comments

Comments
 (0)