-
Notifications
You must be signed in to change notification settings - Fork 28
workflow: compliance: Use additional compliance checks #410
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
Merged
+104
−76
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,133 +1,115 @@ | ||
| name: Compliance | ||
|
|
||
| # Controls when the workflow will run | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| on: pull_request | ||
|
|
||
| # Allows you to run this workflow manually from the Actions tab | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: read | ||
|
|
||
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
| jobs: | ||
| # This workflow contains a single job called "build" | ||
| compliance_job: | ||
| # The type of runner that the job will run on | ||
| runs-on: ubuntu-latest | ||
| runs-on: ubuntu-24.04 | ||
| name: Run compliance checks on patch series (PR) | ||
|
|
||
| # Steps represent a sequence of tasks that will be executed as part of the job | ||
| steps: | ||
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
| - name: Checkout the code | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
| - name: Update PATH for west | ||
| run: | | ||
| echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Checkout sources | ||
| uses: nrfconnect/action-checkout-west-update@main | ||
| with: | ||
| path: nrf-bm | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
| fetch-depth: 0 | ||
| git-fetch-depth: 0 | ||
| git-ref: ${{ github.event.pull_request.head.sha }} | ||
| rebase: true | ||
| path: ncs/nrf-bm | ||
|
|
||
| - name: cache-pip | ||
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4 | ||
| uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-doc-pip | ||
|
|
||
| - name: Install python prerequisites | ||
| working-directory: nrf-bm | ||
| run: | | ||
| export PATH="$HOME/.local/bin:$PATH" | ||
| pip3 install -U -r scripts/requirements.txt | ||
| pip3 show -f west | ||
|
|
||
| - name: West init and update | ||
| env: | ||
| BASE_REF: ${{ github.base_ref }} | ||
| working-directory: nrf-bm | ||
| run: | | ||
| git config --global user.email "[email protected]" | ||
| git config --global user.name "Your Name" | ||
| git remote -v | ||
| # Ensure there's no merge commits in the PR | ||
| #[[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ | ||
| #(echo "::error ::Merge commits not allowed, rebase instead";false) | ||
| git rebase origin/${BASE_REF} | ||
| # debug | ||
| git log --pretty=oneline | head -n 10 | ||
| west init -l . || true | ||
| west config manifest.group-filter -- +ci,-optional | ||
| west update -o=--depth=1 -n 2>&1 1> west.update.log || west update -o=--depth=1 -n 2>&1 1> west.update2.log | ||
|
|
||
| - name: Install python dependencies | ||
| working-directory: nrf | ||
| working-directory: ncs/nrf | ||
| run: | | ||
| pip3 install -U pip | ||
| pip3 install -U wheel | ||
| grep -E "^setuptools" scripts/requirements-fixed.txt | cut -d ' ' -f '1' | xargs pip3 install -U | ||
| grep -E "^python-magic=|^junitparser|^lxml|^gitlint|^pylint|^python-dotenv|^tabulate|^pykwalify|^yamllint|^unidiff" scripts/requirements-fixed.txt | cut -d ' ' -f '1' | xargs pip3 install -U | ||
| grep -E "^python-magic=|^junitparser|^lxml|^gitlint|^pylint|^pykwalify|^yamllint|^unidiff|^vermin|^python-dotenv|^tabulate" scripts/requirements-fixed.txt | cut -d ' ' -f '1' | xargs pip3 install -U | ||
| grep -E "^west" scripts/requirements-fixed.txt | cut -d ' ' -f '1' | xargs pip3 install -U | ||
| pip3 show -f west | ||
|
|
||
| - name: Run merge commits test | ||
| env: | ||
| BASE_REF: ${{ github.base_ref }} | ||
| working-directory: ncs/nrf-bm | ||
| run: | | ||
| # Ensure there's no merge commits in the PR | ||
| [[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ | ||
| (echo "::error ::Merge commits not allowed, rebase instead";false) | ||
|
|
||
| - name: Run CODEOWNERS test | ||
| id: codeowners | ||
| env: | ||
| BASE_REF: ${{ github.base_ref }} | ||
| working-directory: nrf-bm | ||
| working-directory: ncs/nrf-bm | ||
| if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true | ||
| run: | | ||
| ../nrf/scripts/ci/codeowners.py -c origin/${BASE_REF}.. | ||
|
|
||
| - name: Get NCS modules needed for compliance tests to run | ||
| working-directory: ncs/nrf-bm | ||
| run: | | ||
| patch -p1 < scripts/ci/ci-compliance.diff | ||
| west update | ||
|
|
||
| - name: Run Compliance Tests | ||
| continue-on-error: true | ||
| id: compliance | ||
| env: | ||
| BASE_REF: ${{ github.base_ref }} | ||
| working-directory: nrf-bm | ||
| working-directory: ncs/nrf-bm | ||
| if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true | ||
| run: | | ||
| export PATH="$HOME/.local/bin:$PATH" | ||
| export PATH="$HOME/bin:$PATH" | ||
| export ZEPHYR_BASE="$(dirname "$(pwd)")/zephyr" | ||
| # debug | ||
| ls -la | ||
| git log --pretty=oneline | head -n 10 | ||
| exec 2> compliance_errors.txt | ||
| $ZEPHYR_BASE/scripts/ci/check_compliance.py -m Codeowners -m Devicetree -m Identity -m Nits -m Gitlint -m pylint -c origin/${BASE_REF}.. | ||
| if [[ $? -ne 0 ]]; then | ||
| echo "$?" >&2 | ||
| fi | ||
| $ZEPHYR_BASE/scripts/ci/check_compliance.py --annotate \ | ||
| -e KconfigBasicNoModules -e ClangFormat \ | ||
| -e SysbuildKconfigBasicNoModules \ | ||
| -c origin/${BASE_REF}.. | ||
|
|
||
| - name: upload-results | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| continue-on-error: True | ||
| uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4 | ||
| continue-on-error: true | ||
| if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true | ||
| with: | ||
| name: compliance.xml | ||
| path: nrf-bm/compliance.xml | ||
| path: ncs/nrf-bm/compliance.xml | ||
| overwrite: true | ||
|
|
||
| - name: check-warns | ||
| working-directory: nrf-bm | ||
| working-directory: ncs/nrf-bm | ||
| if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true | ||
| run: | | ||
| if [[ -s 'compliance_errors.txt' ]]; then | ||
| echo "ERRORS FOUND! Exiting" | ||
| echo "$(<compliance_errors.txt )" | ||
| exit 1; | ||
| export ZEPHYR_BASE="$(dirname "$(pwd)")/zephyr" | ||
| if [[ ! -s "compliance.xml" ]]; then | ||
| exit 1; | ||
| fi | ||
|
|
||
| - name: check-warns | ||
| working-directory: nrf-bm | ||
| run: | | ||
| for file in Codeowners.txt Devicetree.txt Gitlint.txt Identity.txt Nits.txt pylint.txt | ||
| do | ||
| if [[ -s $file ]]; then | ||
| errors=$(cat $file) | ||
| files=($($ZEPHYR_BASE/scripts/ci/check_compliance.py -l)) | ||
| for file in "${files[@]}"; do | ||
| f="${file}.txt" | ||
| if [[ -s $f ]]; then | ||
| errors=$(cat $f) | ||
| errors="${errors//'%'/'%25'}" | ||
| errors="${errors//$'\n'/'%0A'}" | ||
| errors="${errors//$'\r'/'%0D'}" | ||
| echo "::error file=${file}::$errors" | ||
| echo "::error file=${f}::$errors" | ||
| exit=1 | ||
| fi | ||
| done | ||
|
|
||
| if [[ $exit == 1 ]]; then | ||
| exit 1 | ||
| if [ "${exit}" == "1" ]; then | ||
| exit 1; | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| diff --git a/west.yml b/west.yml | ||
| index 14a19d9..156cee6 100644 | ||
| --- a/west.yml | ||
| +++ b/west.yml | ||
| @@ -32,6 +32,13 @@ manifest: | ||
| - zephyr | ||
| - cmock | ||
| - zcbor | ||
| + # For compliance CI testing only | ||
| + - matter | ||
| + - openthread | ||
| + - azure-sdk-for-c | ||
| + - trusted-firmware-m | ||
| + - memfault-firmware-sdk | ||
| + - cjson | ||
| - name: sdk-nrf-bm-internal | ||
| path: nrf-bm-internal | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.