diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000000..a59c7723c7a2a2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,10 @@ +--- +Language: Cpp +BasedOnStyle: WebKit +--- +Language: C +BasedOnStyle: WebKit +--- +Language: ObjC +BasedOnStyle: WebKit +... diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml new file mode 100644 index 00000000000000..af18abf9371a37 --- /dev/null +++ b/.github/workflows/build-main.yml @@ -0,0 +1,13 @@ +name: World Build + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + # - name: Run Build + # run: make diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml new file mode 100644 index 00000000000000..b0127869ca4810 --- /dev/null +++ b/.github/workflows/clang-tidy.yml @@ -0,0 +1,23 @@ +name: Tidy + +on: [pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Get changed files + id: get-changed-files + uses: futuratrepadeira/changed-files@v3.0.0 + with: + repo-token: ${{ github.token }} + - name: clang-tidy + uses: ./actions/clang-tidy + id: clang-tidy + env: + GITHUB_TOKEN: ${{ github.token }} + CLANG_ARGUMENTS: "-checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus* -- -Isrc/includes" + FILES_MODIFIED: ${{ steps.get-changed-files.outputs.files_updated }} + FILES_ADDED: ${{ steps.get-changed-files.outputs.files_created }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000000..9a3d73f98da86b --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# VS Code Configs +*.vscode diff --git a/.restyled.yml b/.restyled.yml new file mode 100644 index 00000000000000..e809d479191731 --- /dev/null +++ b/.restyled.yml @@ -0,0 +1,24 @@ +--- +image: restyled/restyler-clang-format:v9.0.0 +command: + - clang-format + - "-i" +arguments: [] +include: + - "**/*.c" + - "**/*.cc" + - "**/*.cpp" + - "**/*.cxx" + - "**/*.c++" + - "**/*.C" + - "**/*.cs" + - "**/*.h" + - "**/*.hh" + - "**/*.hpp" + - "**/*.hxx" + - "**/*.h++" + - "**/*.H" + - "**/*.java" + - "**/*.js" + - "**/*.m" +interpreters: [] diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 00000000000000..4a8a6b5c04501f --- /dev/null +++ b/BUILDING.md @@ -0,0 +1 @@ +## Build Documentation diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000000..9447d914a4f1c3 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,77 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to make participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when +an individual is representing the project or its community in public spaces. +Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting +as an appointed representative at an online or offline event. Representation of +a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [INSERT EMAIL ADDRESS]. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000000..438e4f56c3cf56 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,192 @@ +Contributing to CHIP +======================== + +Want to contribute? Great! First, read this page (including the small +print at the end). +By submitting a pull request, you represent that you have the right to license your contribution to Zigbee and the +community, and agree by submitting the patch that your contributions are licensed under the +[Apache 2.0 license](./LICENSE.md). + +Before submitting the pull request, please make sure you have tested your changes and that they follow the project +[guidelines for contributing code](./docs/contribution_guidelines.md). + + +## Bugs + +If you find a bug in the source code, you can help us by [submitting a GitHub Issue](https://github.com/project-chip/connectedhomeip/issues/new). The best bug reports provide a detailed description of the issue and step-by-step instructions for predictably reproducing the issue. Even better, you can [submit a Pull Request](#submitting-a-pull-request) with a fix. + +## New Features + +You can request a new feature by [submitting a GitHub Issue](https://github.com/project-chip/connectedhomeip/issues/new). + +If you would like to implement a new feature, please consider the scope of the new feature: + +* *Large feature*: first [submit a GitHub + Issue](https://github.com/project-chip/connectedhomeip/issues/new) and communicate + your proposal so that the community can review and provide feedback. Getting + early feedback will help ensure your implementation work is accepted by the + community. This will also allow us to better coordinate our efforts and + minimize duplicated effort. + +* *Small feature*: can be implemented and directly [submitted as a Pull + Request](#submitting-a-pull-request). + +## Contributing Code + +CHIP follows the "Fork-and-Pull" model for accepting contributions. + +### Initial Setup + +Setup your GitHub fork and continuous-integration services: + +1. Fork the [CHIP + repository](https://github.com/project-chip/connectedhomeip) by clicking "Fork" + on the web UI. + +2. All contributions must pass all checks and reviews to be accepted. + +Setup your local development environment: + +```bash +# Clone your fork +git clone git@github.com:/connectedhomeip.git + +# Configure upstream alias +git remote add upstream git@github.com:project-chip/connectedhomeip.git +``` + +### Submitting a Pull Request + +#### Branch + +For each new feature, create a working branch: + +```bash +# Create a working branch for your new feature +git branch --track origin/master + +# Checkout the branch +git checkout +``` + +#### Create Commits + +```bash +# Add each modified file you'd like to include in the commit +git add + +# Create a commit +git commit +``` + +This will open up a text editor where you can craft your commit message. + +#### Upstream Sync and Clean Up + +Prior to submitting your pull request, you might want to do a few things to +clean up your branch and make it as simple as possible for the original +repository's maintainer to test, accept, and merge your work. + +If any commits have been made to the upstream master branch, you should rebase +your development branch so that merging it will be a simple fast-forward that +won't require any conflict resolution work. + +```bash +# Fetch upstream master and merge with your repository's master branch +git checkout master +git pull upstream master + +# If there were any new commits, rebase your development branch +git checkout +git rebase master +``` + +Now, it may be desirable to squash some of your smaller commits down into a +small number of larger more cohesive commits. You can do this with an +interactive rebase: + +```bash +# Rebase all commits on your development branch +git checkout +git rebase -i master +``` + +This will open up a text editor where you can specify which commits to squash. + + +#### Push and Test + +```bash +# Checkout your branch +git checkout + +# Push to your GitHub fork: +git push origin +``` + +This will trigger the continuous-integration checks. You +can view the results in the respective services. Note that the integration +checks will report failures on occasion. + +#### Pull Request Requirements + +CHIP considers there to be a few different types of pull requests: +- Trivial bug fix +- - Decription 1 +- - Decription 2 +- Small Bug fix +- - Decription 1 +- - Decription 2 +- Bug Fix +- - Decription 1 +- - Decription 2 +- Significiant Change +- - Decription 1 +- - Decription 2 +- Feature +- - Decription 1 +- - Decription 2 +- Architecture Change +- - Decription 1 +- - Decription 2 + +### Prior to review, all changes require: +- [GitHub Workflows](../.github/workflows) pass +- [Certification Tests](tests/certification/README.md) pass +- [Unit Tests](tests/unit/README.md) pass +- [Fuzz Tests](tests/fuzz/README.md) pass +- [Integration Tests](tests/integration/README.md) pass +- Linting passes +- Code style passes + +Each type of change has unique additional requirements, here's a table of those: +| Type | Reviewer Requirements | New Unit Tests | New Certification Tests | New Fuzz Tests | New Integration Tests | +|----|----|----|----|----|----| +| Trivial bug fix | | | | | | +| Small Bug fix | | | | | | | +| Bug Fix | | | | | | | +| Significiant Change | | | | | | | +| Feature | | | | | | | +| Architecture Change | | | | | | | + + + +#### Submit Pull Request + +Once you've validated the CI results, go to the page for +your fork on GitHub, select your development branch, and click the pull request +button. If you need to make any adjustments to your pull request, just push the +updates to GitHub. Your pull request will automatically track the changes on +your development branch and update. + +#### Code reviews + +All submissions, including submissions by project members, require review. + +### Documentation + +Documentation undergoes the same review process as code + +See the [Documentation Style Guide][doc-style] for more information on +how to author and format documentation for contribution. + diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000000000..7bd768e9a09562 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +The following organizations and individuals have contributed to the CHIP SDK: +* Apple Inc +* Google Inc diff --git a/README.md b/README.md new file mode 100644 index 00000000000000..60415eeb0c113d --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# Connected Home over IP + +![C/C++ CI](https://github.com/SalixSepulcralis/connectedhomeip/workflows/World%20Build/badge.svg) + + +# Getting started with CHIP + +All documentation is inside of the [docs section](./docs/README.md) + +Additional build information can also be found in [BUILDING.md](./BUILDING.md). + +# Need help? + +There are numerous avenues for CHIP support: +* Bugs and feature requests — [submit to the Issue Tracker](https://github.com/project-chip/connectedhomeip/issues) +* Stack Overflow — [post questions using the chip tag](http://stackoverflow.com/questions/tagged/chip) + +# Directory Structure + +The CHIP repository is structured as follows: + +| File / Folder | Contents | +|----|----| +| `actions/` | GitHub Actions related to this project | +| `build/` | Build system support content | +| `BUILDING.md` | More detailed information on configuring and building CHIP for different targets | +| `CODE_OF_CONDUCT.md` | Code of Conduct for CHIP, and contributions to it | +| `CONTRIBUTING.md` | Guidelines for contributing to CHIP | +| `CONTRIBUTORS.md` | Contributors to CHIP | +| `docs/` | Documentation | +| `images/` | Images | +| `LICENSE` | CHIP License file (Apache 2.0) | +| `README.md` | This file | +| `src/` | Implementation of CHIP| +| `tests/` | Tests for CHIP | +| `tools/` | Tools needed to work with the CHIP repo, as well as develop in the repository | + +# Contributing + +We would love for you to contribute to CHIP and help make it even +better than it is today! See the [CONTRIBUTING.md](./CONTRIBUTING.md) +file for more information. + + +# License + +CHIP is released under the [Apache 2.0 license](./LICENSE) Please read more details therein diff --git a/actions/clang-tidy/Dockerfile b/actions/clang-tidy/Dockerfile new file mode 100644 index 00000000000000..4b847fed367af7 --- /dev/null +++ b/actions/clang-tidy/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:xenial + +COPY run_clang.sh /run_clang.sh +RUN chmod +x /run_clang.sh +RUN apt update +RUN apt-get install -fy clang clang-format clang-tidy wget curl jq + +ENTRYPOINT ["/run_clang.sh"] diff --git a/actions/clang-tidy/action.yml b/actions/clang-tidy/action.yml new file mode 100644 index 00000000000000..071e6667edd8bf --- /dev/null +++ b/actions/clang-tidy/action.yml @@ -0,0 +1,21 @@ +name: "Clang Pull Request Tidy" +description: "clang-lint" +inputs: + files_added: + description: "JSON list of files added" + required: false + files_modified: + description: "JSON list of files modified" + required: false + clang_arguments: + description: "Additional arguments to clang-tidy" + required: false +outputs: + clang-result: + description: "Clang results path" +runs: + using: "docker" + image: "Dockerfile" +branding: + color: "blue" + icon: "shield" diff --git a/actions/clang-tidy/run_clang.sh b/actions/clang-tidy/run_clang.sh new file mode 100644 index 00000000000000..f29c1d46f8337d --- /dev/null +++ b/actions/clang-tidy/run_clang.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +cd $GITHUB_WORKSPACE + +echo "clang arguments: $CLANG_ARGUMENTS" +echo "files modified: $FILES_MODIFIED" +echo "files added: $FILES_ADDED" + +read -r -a MODIFIED_FILES <<< "$FILES_MODIFIED" +read -r -a ADDED_FILES <<< "$FILES_ADDED" + +clang_arguments="" + +for element in "${MODIFIED_FILES[@]}" +do + clang_arguments+="$element " +done +for element in "${ADDED_FILES[@]}" +do + clang_arguments+="$element " +done + +clang_arguments+=" -export-fixes=fixes.yml" + +clang_arguments+=" $CLANG_ARGUMENTS " + + +echo "final clang arguments: $clang_arguments" + +# Run clang-tidy for real +clang-tidy $clang_arguments > clang_output.txt + +if [ $? -eq 0 ]; then + echo "Clang passed! Good job!" + echo ::set-output name=clang-result::"" +else + CLANG_OUTPUT=`cat clang_output.txt` + FIXES_OUTPUT=`cat fixes.yml` + LINES_OF_FIXES=$(echo $FIXES_OUTPUT | wc -l) + + # Cleanup the files we don't need + rm clang_output.txt + rm fixes.yml + + PULL_REQUEST_COMMENT="" + PULL_REQUEST_COMMENT+=$'### Automated clang-tidy Review\n' + + PULL_REQUEST_COMMENT+=$'#### Clang Warnings & Errors\n' + PULL_REQUEST_COMMENT+=$'\n```\n' + PULL_REQUEST_COMMENT+="$CLANG_OUTPUT" + PULL_REQUEST_COMMENT+=$'\n```\n' + + PULL_REQUEST_COMMENT+=$'#### Recommended Fixes\n' + PULL_REQUEST_COMMENT+=$'\n```\n' + PULL_REQUEST_COMMENT+="$FIXES_OUTPUT" + PULL_REQUEST_COMMENT+=$'\n```\n' + + PULL_REQUEST_COMMENT_URL=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.comments_url) + + echo ::set-output name=clang-result::$CLANG_OUTPUT + + if [ ! -z "$PULL_REQUEST_COMMENT_URL" -a "$str"!="" -a "$str"!="null" ]; then + echo "Posting to comment URL: $PULL_REQUEST_COMMENT_URL" + + REQUEST_DATA=$(echo '{}' | jq --arg body "$PULL_REQUEST_COMMENT" '.body = $body') + curl -s -S -H "Authorization: token $GITHUB_TOKEN" --header "Content-Type: application/vnd.github.VERSION.text+json" --data "$REQUEST_DATA" "$PULL_REQUEST_COMMENT_URL" + fi +fi diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000000000..25f8d456418b55 --- /dev/null +++ b/docs/README.md @@ -0,0 +1 @@ +# Documentation diff --git a/docs/STYLE_GUIDE.md b/docs/STYLE_GUIDE.md new file mode 100644 index 00000000000000..0316dba0ea2316 --- /dev/null +++ b/docs/STYLE_GUIDE.md @@ -0,0 +1,126 @@ +# CHIP Documentation Style Guide + +CHIP documentation lives here: + +* **GitHub** — All guides and tutorials across the complete [Project-CHIP organization](https://github/project-chip). + +See [CONTRIBUTING.md](../CONTRIBUTING.md) for general information on contributing to this project. + +## Location + +Place all documentation contributions in the appropriate location in the [`/docs`](./) directory. Most contributions should go into the `/docs/guides` subdirectory, which covers conceptual and usage content. + +Current documentation structure: + +Directory | Description +----|---- +`/actions` | Custom GitHub actions +`/docs/guides` | Conceptual or usage content that doesn't fit within a subdirectory, and high-level tutorials +`/docs/guides/images` | All images included in guide content +`/docs/guides/profiles` | Content describing or illustrating use of CHIP profiles +`/docs/guides/test` | Content related to testing CHIP +`/docs/guides/tools` | Content describing or illustrating use of CHIP tools +`/docs/guides/primer` | CHIP Primer content +`/docs/presentations` | PDF presentations on CHIP features +`/docs/specs` | PDFs of CHIP specifications +`/images` | Top-level CHIP images, such as logos + +If you are unsure of the best location for your contribution, create an Issue and ask, or let us know in your Pull Request. + + +## Style + +Style to come + +## Links + +For consistency, all document links should point to the content on GitHub. + +The text of a link should be descriptive, so it's clear what the link is for: + +> For more information, see the [CHIP Style Guide](./STYLE_GUIDE.md). + +## Markdown guidelines + +Use standard Markdown when authoring CHIP documentation. While HTML may be used for more complex content such as tables, use Markdown as much as possible. + +> Note: Edit this file to see the Markdown behind the examples. + +### Headers + +The document title should be an h1 header (#) and in title case (all words are capitalized). All section headers should be h2 (##) or lower and in sentence case (only the first word and proper nouns are capitalized). + +The best practice for document clarity is to not go lower than h3, but h4 is fine on occasion. Try to avoid using h4 often, or going lower than h4. If this happens, the document should be reorganized or broken up to ensure it stays at h3 with the occasional h4. + +### Command line examples + +Feel free to use either `$` or `%` to preface command line examples, but be consistent within the same doc or set of docs: + +``` +$ git clone https://github.com/project-chip/connectedhomeip.git +% git clone https://github.com/project-chip/connectedhomeip.git +``` + +### Terminal prompts + +If you need use a full terminal prompt with username and hostname, use the format of `root@{hostname}{special-characters}#`. + +For example, when logged into a Docker container, you might have a prompt like this: +``` +root@c0f3912a74ff:/# +``` + + +### Commands and output + +All example commands and output should be in code blocks with backticks: + +``` +code in backticks +``` + +...unless the code is within a step list. In a step list, indent the code blocks: + + code indented + +### Code blocks in step lists + +When writing procedures that feature code blocks, indent the content for the code blocks: + +1. Step one: + + $ git clone https://github.com/project-chip/connectedhomeip.git + $ cd connectedhomeip + +1. Step two, do something else: + + $ ./configure + +For clarity in instructions, avoid putting additional step commands after a code sample +within a step item. Instead rewrite the instruction so this is not necessary. + +For example, avoid this: + +1. Step three, do this now: + + $ ./configure + + And then you will see that thing. + +Instead, do this: + +1. Step three, do this now, and you will see that thing: + + $ ./configure + +### Inline code + +Use backticks for `inline code`. This includes file paths and file or binary names. + + + +Supported keywords: + +Keyword | Description +----|---- +alarm | Alarm diff --git a/docs/guides/README.md b/docs/guides/README.md new file mode 100644 index 00000000000000..0a2f8b496158e4 --- /dev/null +++ b/docs/guides/README.md @@ -0,0 +1 @@ +## Guides diff --git a/docs/presentations/README.md b/docs/presentations/README.md new file mode 100644 index 00000000000000..f54e83aefff8cb --- /dev/null +++ b/docs/presentations/README.md @@ -0,0 +1 @@ +## Presentations diff --git a/images/logo.svg b/images/logo.svg new file mode 100644 index 00000000000000..dcd92e9857a564 --- /dev/null +++ b/images/logo.svg @@ -0,0 +1,15 @@ + + + + Zigbee_logo + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/src/README.md b/src/README.md new file mode 100644 index 00000000000000..d1d49fdeab345a --- /dev/null +++ b/src/README.md @@ -0,0 +1 @@ +## Source Code diff --git a/src/include/README.md b/src/include/README.md new file mode 100644 index 00000000000000..f082527434bf50 --- /dev/null +++ b/src/include/README.md @@ -0,0 +1 @@ +# Base Headers diff --git a/tests/certification/README.md b/tests/certification/README.md new file mode 100644 index 00000000000000..d587360fa6c165 --- /dev/null +++ b/tests/certification/README.md @@ -0,0 +1 @@ +## Certification Test Suites diff --git a/tests/docs/README.md b/tests/docs/README.md new file mode 100644 index 00000000000000..2212576b76ee3f --- /dev/null +++ b/tests/docs/README.md @@ -0,0 +1 @@ +# Test Documentation diff --git a/tests/fuzz/README.md b/tests/fuzz/README.md new file mode 100644 index 00000000000000..f7799ef976df08 --- /dev/null +++ b/tests/fuzz/README.md @@ -0,0 +1 @@ +## Fuzz Test Suites diff --git a/tests/integration/README.md b/tests/integration/README.md new file mode 100644 index 00000000000000..c7476fac126abd --- /dev/null +++ b/tests/integration/README.md @@ -0,0 +1 @@ +## Integration Test Suites diff --git a/tests/unit/README.md b/tests/unit/README.md new file mode 100644 index 00000000000000..7aae3033dfa602 --- /dev/null +++ b/tests/unit/README.md @@ -0,0 +1 @@ +## Unit Test Suites diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 00000000000000..a109accf3ed6eb --- /dev/null +++ b/tools/README.md @@ -0,0 +1 @@ +## Tools