From 252c9bf47e776ba02e0ae47c95cce43acc862765 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 8 Aug 2022 15:08:01 -0700 Subject: [PATCH 1/7] Configure Dependabot to check for outdated actions used in workflows Dependabot will periodically check the versions of all actions used in the repository's workflows. If any are found to be outdated, it will submit a pull request to update them. NOTE: Dependabot's PRs will occasionally propose to pin to the patch version of the action (e.g., updating `uses: foo/bar@v1` to `uses: foo/bar@v2.3.4`). When the action author has provided a major version ref, use that instead (e.g., `uses: foo/bar@v2`). Dependabot will automatically close its PR once the workflow has been updated. More information: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot --- .github/dependabot.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fd7388a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file +version: 2 + +updates: + # Configure check for outdated GitHub Actions actions in workflows. + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md + # See: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot + - package-ecosystem: github-actions + directory: / # Check the repository's workflows under /.github/workflows/ + schedule: + interval: daily + labels: + - "topic: infrastructure" From 85a210bb3640f41ba1b26d2ebbe3d571834d6577 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 8 Aug 2022 15:12:04 -0700 Subject: [PATCH 2/7] Add CI workflow to check for commonly misspelled words On every push, pull request, and periodically, use the codespell-project/actions-codespell action to check for commonly misspelled words. In the event of a false positive, the problematic word should be added, in all lowercase, to the ignore-words-list field of ./.codespellrc. Regardless of the case of the word in the false positive, it must be in all lowercase in the ignore list. The ignore list is comma-separated with no spaces. --- .codespellrc | 9 +++++++++ .github/workflows/spell-check.yml | 25 +++++++++++++++++++++++++ README.md | 3 +++ 3 files changed, 37 insertions(+) create mode 100644 .codespellrc create mode 100644 .github/workflows/spell-check.yml create mode 100644 README.md diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..a8608a4 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,9 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: +ignore-words-list = , +skip = ./.git,./.licenses,__pycache__,node_modules,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock +builtin = clear,informal,en-GB_to_en-US +check-filenames = +check-hidden = diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 0000000..be559af --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,25 @@ +name: Spell Check + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +permissions: + contents: read + +jobs: + spellcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Spell check + uses: codespell-project/actions-codespell@master diff --git a/README.md b/README.md new file mode 100644 index 0000000..a13e590 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Arduino_PF1550 + +[![Spell Check status](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/spell-check.yml) From d4b7f8c84ba4c8d3cbdd38053c2908a11018eb0d Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 8 Aug 2022 15:23:43 -0700 Subject: [PATCH 3/7] Correct typos in documentation --- examples/BasicUsage/BasicUsage.ino | 2 +- src/PF1550/PF1550_Control.cpp | 2 +- src/PF1550/PF1550_Register.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/BasicUsage/BasicUsage.ino b/examples/BasicUsage/BasicUsage.ino index 1e68738..4f126d0 100644 --- a/examples/BasicUsage/BasicUsage.ino +++ b/examples/BasicUsage/BasicUsage.ino @@ -20,7 +20,7 @@ void setup() { IEndOfCharge::I_5_mA, IInputCurrentLimit::I_100_mA); - /* TODO: Clarify if a interrupt event is generated by a rising or falling edge, + /* TODO: Clarify if an interrupt event is generated by a rising or falling edge, * according to schematic/datasheet it's a open-drain output with a pull-up resistor. * Probably we need to do the registering with a ISR handler internally in the future * since the PMIC_INT pin PK0 will not be exposed externally. diff --git a/src/PF1550/PF1550_Control.cpp b/src/PF1550/PF1550_Control.cpp index fba05dd..a8d6e93 100644 --- a/src/PF1550/PF1550_Control.cpp +++ b/src/PF1550/PF1550_Control.cpp @@ -211,7 +211,7 @@ void PF1550_Control::onPMICEvent() uint8_t int_category; _io.readRegister(Register::PMIC_INT_CATEGORY, &int_category); - /* Call the appopriate event handler */ + /* Call the appropriate event handler */ if(isBitSet(int_category, REG_INT_CATEGORY_CHG_INT_bp )) onChargerEvent (); if(isBitSet(int_category, REG_INT_CATEGORY_SW1_INT_bp )) onSwitch1Event (); if(isBitSet(int_category, REG_INT_CATEGORY_SW2_INT_bp )) onSwitch2Event (); diff --git a/src/PF1550/PF1550_Register.h b/src/PF1550/PF1550_Register.h index 503e4ac..71979a1 100644 --- a/src/PF1550/PF1550_Register.h +++ b/src/PF1550/PF1550_Register.h @@ -31,7 +31,7 @@ enum class Register : uint8_t { - /* PMIC Register Adresses */ + /* PMIC Register Addresses */ PMIC_DEVICE_ID = 0x00, PMIC_OTP_FLAVOR = 0x01, PMIC_SILICON_REV = 0x02, @@ -96,7 +96,7 @@ enum class Register : uint8_t PMIC_I2C_ADDR = 0x68, PMIC_RC_16MHZ = 0x6B, PMIC_KEY1 = 0x6B, - /* Charger Register Adresses */ + /* Charger Register Addresses */ CHARGER_CHG_INT = 0x80 + 0x00, CHARGER_CHG_INT_MASK = 0x80 + 0x02, CHARGER_CHG_INT_OK = 0x80 + 0x04, From 368e748b06e26dada28ce943a2248072ba9179a4 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 8 Aug 2022 15:13:52 -0700 Subject: [PATCH 4/7] Add CI workflow to do Arduino project-specific linting On every push, pull request, and periodically, run Arduino Lint to check for common problems not related to the project code. --- .github/workflows/check-arduino.yml | 31 +++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 32 insertions(+) create mode 100644 .github/workflows/check-arduino.yml diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml new file mode 100644 index 0000000..dfcac2e --- /dev/null +++ b/.github/workflows/check-arduino.yml @@ -0,0 +1,31 @@ +name: Check Arduino + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Arduino Lint + uses: arduino/arduino-lint-action@v1 + with: + compliance: strict + # Change this to "update" once the library is added to the index. + library-manager: submit + # Always use this setting for official repositories. Remove for 3rd party projects. + official: true diff --git a/README.md b/README.md index a13e590..d857921 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # Arduino_PF1550 +[![Check Arduino status](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/check-arduino.yml) [![Spell Check status](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/spell-check.yml) From 916d890c7b833321e8c9d4be5374197247a5acb0 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 8 Aug 2022 15:29:18 -0700 Subject: [PATCH 5/7] Add "smoke test" examples compilation CI workflow On every push or pull request that affects library source or example files, and periodically, compile all example sketches for the specified boards. --- .github/workflows/compile-examples.yml | 63 ++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/compile-examples.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 0000000..14ca9f7 --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,63 @@ +name: Compile Examples + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-examples.ya?ml" + - "library.properties" + - "examples/**" + - "src/**" + pull_request: + paths: + - ".github/workflows/compile-examples.ya?ml" + - "library.properties" + - "examples/**" + - "src/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +permissions: + contents: read + +jobs: + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:mbed_nicla:nicla_vision + # See: https://github.com/arduino/compile-sketches#platforms + platforms: | + - name: arduino:mbed_nicla + - fqbn: arduino:mbed_portenta:envie_m4 + platforms: | + - name: arduino:mbed_portenta + - fqbn: arduino:mbed_portenta:envie_m7 + platforms: | + - name: arduino:mbed_portenta + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Compile examples + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + # Install the library from the local path. + - source-path: ./ + # Additional library dependencies can be listed here. + # See: https://github.com/arduino/compile-sketches#libraries + sketch-paths: | + - examples diff --git a/README.md b/README.md index d857921..f0a194c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Arduino_PF1550 [![Check Arduino status](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/check-arduino.yml) +[![Compile Examples status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/compile-examples.yml) [![Spell Check status](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PF1550/actions/workflows/spell-check.yml) From facf192e837501c30a02ebec407886237073f049 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 8 Aug 2022 15:31:06 -0700 Subject: [PATCH 6/7] Report changes in memory usage that would result from merging a PR On creation or commit to a pull request, a report of the resulting change in memory usage of the examples will be commented to the PR thread. --- .github/workflows/compile-examples.yml | 12 +++++++++++ .github/workflows/report-size-deltas.yml | 27 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/report-size-deltas.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 14ca9f7..cc19b1f 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -28,6 +28,9 @@ jobs: name: ${{ matrix.board.fqbn }} runs-on: ubuntu-latest + env: + SKETCHES_REPORTS_PATH: sketches-reports + strategy: fail-fast: false @@ -61,3 +64,12 @@ jobs: # See: https://github.com/arduino/compile-sketches#libraries sketch-paths: | - examples + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v3 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..32122aa --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,27 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.ya?ml" + schedule: + # Run at the minimum interval allowed by GitHub Actions. + # Note: GitHub Actions periodically has outages which result in workflow failures. + # In this event, the workflows will start passing again once the service recovers. + - cron: "*/5 * * * *" + workflow_dispatch: + repository_dispatch: + +permissions: + pull-requests: write + +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@v1 + with: + # The name of the workflow artifact created by the sketch compilation workflow + sketches-reports-source: sketches-reports From 6592b503f3b3766eaf39ed0d42b2dfc49779a83f Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 8 Aug 2022 15:32:19 -0700 Subject: [PATCH 7/7] Add GitHub Actions workflow to synchronize with shared repository labels On every push that changes relevant files, and periodically, configure the repository's issue and pull request labels according to the universal, shared, and local label configuration files. --- .github/workflows/sync-labels.yml | 138 ++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 .github/workflows/sync-labels.yml diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..3a330c1 --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,138 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md +name: Sync Labels + +# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + pull_request: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + schedule: + # Run daily at 8 AM UTC to sync with changes to shared label configurations. + - cron: "0 8 * * *" + workflow_dispatch: + repository_dispatch: + +env: + CONFIGURATIONS_FOLDER: .github/label-configuration-files + CONFIGURATIONS_ARTIFACT: label-configuration-files + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Download JSON schema for labels configuration file + id: download-schema + uses: carlosperate/download-file-action@v1 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json + location: ${{ runner.temp }}/label-configuration-schema + + - name: Install JSON schema validator + run: | + sudo npm install \ + --global \ + ajv-cli \ + ajv-formats + + - name: Validate local labels configuration + run: | + # See: https://github.com/ajv-validator/ajv-cli#readme + ajv validate \ + --all-errors \ + -c ajv-formats \ + -s "${{ steps.download-schema.outputs.file-path }}" \ + -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" + + download: + needs: check + runs-on: ubuntu-latest + + strategy: + matrix: + filename: + # Filenames of the shared configurations to apply to the repository in addition to the local configuration. + # https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels + - universal.yml + + steps: + - name: Download + uses: carlosperate/download-file-action@v1 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} + + - name: Pass configuration files to next job via workflow artifact + uses: actions/upload-artifact@v3 + with: + path: | + *.yaml + *.yml + if-no-files-found: error + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + sync: + needs: download + runs-on: ubuntu-latest + + steps: + - name: Set environment variables + run: | + # See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable + echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" + + - name: Determine whether to dry run + id: dry-run + if: > + github.event_name == 'pull_request' || + ( + ( + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' + ) && + github.ref != format('refs/heads/{0}', github.event.repository.default_branch) + ) + run: | + # Use of this flag in the github-label-sync command will cause it to only check the validity of the + # configuration. + echo "::set-output name=flag::--dry-run" + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Download configuration files artifact + uses: actions/download-artifact@v3 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + path: ${{ env.CONFIGURATIONS_FOLDER }} + + - name: Remove unneeded artifact + uses: geekyeggo/delete-artifact@v1 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + - name: Merge label configuration files + run: | + # Merge all configuration files + shopt -s extglob + cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" + + - name: Install github-label-sync + run: sudo npm install --global github-label-sync + + - name: Sync labels + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # See: https://github.com/Financial-Times/github-label-sync + github-label-sync \ + --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ + ${{ steps.dry-run.outputs.flag }} \ + ${{ github.repository }}