Giter VIP home page Giter VIP logo

report-size-deltas's Introduction

arduino/report-size-deltas action

Tests Integration Tests Spell Check codecov

This action comments on the pull request with a report on the resulting change in memory usage of the Arduino sketches compiled by the arduino/compile-sketches action. This should be run from a scheduled workflow.

sample report

Table of contents

Inputs

sketches-reports-source

Default: "sketches-reports"

The action can be used in two ways:

Recommended for public repositories.

The use of a scheduled workflow is necessary in order for the action to have the write permissions required to comment on pull requests submitted from forks.

In this usage, the sketches-reports-source defines the name of the workflow artifact that contains the memory usage data, as specified to the actions/upload-artifact action via its name input.

Run from the same workflow as the arduino/compile-sketches action

Recommended for private repositories.

If configured to trigger on a short interval, the scheduled workflow method can use a lot of GitHub Actions minutes, quickly using up the limited allotment provided by GitHub for private repositories (public repositories get unlimited free minutes). For this reason, it may be preferable to only run the action as needed.

In order to get reports for pull requests from forks, the "Send write tokens to workflows from fork pull requests" setting must be enabled.

If the "Send write tokens to workflows from fork pull requests" setting is not enabled but the "Run workflows from fork pull requests" setting is enabled, the workflow should be configured to only run the action when the pull request is not from a fork (if: github.event.pull_request.head.repo.full_name == github.repository). This will prevent workflow job failures that would otherwise be caused when the report creation failed due to not having the necessary write permissions.

In this usage, the sketches-reports-source defines the path to the folder containing the memory usage data, as specified to the actions/download-artifact action via its path input.

github-token

GitHub access token used to comment the memory usage comparison results to the PR thread.

Default: GITHUB_TOKEN

Example usage

Scheduled workflow

on:
  schedule:
    - cron:  '*/5 * * * *'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: arduino/report-size-deltas@v1

This must be used in conjunction with a workflow that runs the arduino/compile-sketches action and uploads the resulting sketches report to a workflow artifact:

on: [push, pull_request]
jobs:
  compile:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: arduino/compile-sketches@v1
        with:
          enable-deltas-report: true
      - uses: actions/upload-artifact@v2
        with:
          name: sketches-reports
          path: sketches-reports

Workflow triggered by pull_request event

on: [push, pull_request]
env:
  # It's convenient to set variables for values used multiple times in the workflow
  SKETCHES_REPORTS_PATH: sketches-reports
  SKETCHES_REPORTS_ARTIFACT_NAME: sketches-reports
jobs:
  compile:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        fqbn:
          - "arduino:avr:uno"
          - "arduino:samd:mkrzero"
    steps:
      - uses: actions/checkout@v2

      - uses: arduino/compile-sketches@v1
        with:
          fqbn: ${{ matrix.fqbn }}
          enable-deltas-report: true
          sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}

      # This step is needed to pass the size data to the report job 
      - name: Upload sketches report to workflow artifact
        uses: actions/upload-artifact@v2
        with:
          name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
          path: ${{ env.SKETCHES_REPORTS_PATH }}

  # When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report
  report:
    needs: compile  # Wait for the compile job to finish to get the data for the report
    if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request
    runs-on: ubuntu-latest
    steps:
      # This step is needed to get the size data produced by the compile jobs
      - name: Download sketches reports artifact
        uses: actions/download-artifact@v2
        with:
          name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
          path: ${{ env.SKETCHES_REPORTS_PATH }}

      - uses: arduino/report-size-deltas@v1
        with:
          sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}

report-size-deltas's People

Contributors

aentinger avatar dependabot[bot] avatar giulcioffi avatar p-r-o-c-h-y avatar per1234 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.