Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
noahp committed Jul 19, 2024
0 parents commit 40b02fe
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Stub main to generate a tiny, valid symbol file for testing upload.
// To generate the symbol file, run:
//
// clang --target=arm-none-eabi -nostdlib -Os -g1 -Wl,--entry=main,--build-id main.c -o test.elf
//
// NOTE: the above command uses "-g1" to omit macros from the .debug_str
// sections. "-g3" is always preferred for real world use cases.

#include <stdint.h>

// This is a dummy build ID symbol set to "GNU Build ID" type.
__attribute__((used)) const uint8_t g_memfault_build_id[3] = {0x2};

// Junk so we can force a new build id
__attribute__((used)) const char timedata[] = __TIME__;
__attribute__((used)) const char date[] = __DATE__;

int main() {
return 0;
}
34 changes: 34 additions & 0 deletions .github/workflows/test_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test Action
# Run on PRs targeting main, and push to main
on:
pull_request:
branches:
- main
push:
branches:
- main
# also support on workflow_dispatch
workflow_dispatch:

jobs:
test-action:
runs-on: ubuntu-latest
name: Run a test of the action
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Generate test symbol file
run: |
cd .github/workflows
clang --target=arm-none-eabi -nostdlib -Os -g1 -Wl,--entry=main,--build-id main.c -o test.elf
readelf -n test.elf
- name: Test action
id: test_action
uses: ./ # Uses an action in the root directory
with:
MEMFAULT_ORG_TOKEN: ${{ secrets.MEMFAULT_ORG_TOKEN }}
MEMFAULT_ORG_SLUG: ${{ secrets.MEMFAULT_ORG_SLUG }}
MEMFAULT_PROJECT_SLUG: ${{ secrets.MEMFAULT_PROJECT_SLUG }}
symbol_file: .github/workflows/test.elf
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Memfault Upload Symbol File GitHub Action

This action uploads a symbol file to Memfault's symbol file service.

## Inputs

> [!TIP]
>
> The `MEMFAULT_ORG_TOKEN`, `MEMFAULT_ORG_SLUG`, and `MEMFAULT_PROJECT_SLUG`
> should be set as GitHub secrets.
| Name | Description | Required | Default |
| ----------------------- | -------------------------------------------------------------------------------------------------------------- | -------- | ------- |
| `MEMFAULT_ORG_TOKEN` | Organization Auth Token. Generate one [here](https://app.memfault.com/organizations/-/settings/auth-tokens) | true | |
| `MEMFAULT_ORG_SLUG` | Memfault Org Slug | true | |
| `MEMFAULT_PROJECT_SLUG` | Memfault Project Slug | true | |
| `symbol_file` | Path to the symbol file | true | |
| `memfault_cli_version` | Memfault CLI Version | true | 1.0.11 |

Find more documentation here: [Memfault Docs](https://docs.memfault.com/docs/ci/uploading-symbols).
43 changes: 43 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'Memfault Upload Symbol Files Action'

description: 'Upload symbol files to Memfault'

inputs:
MEMFAULT_ORG_TOKEN:
description: 'Organization Auth Token. Generate one at https://app.memfault.com/organizations/-/settings/auth-tokens'
required: true
MEMFAULT_ORG_SLUG:
description: 'Memfault Org Slug'
required: true
MEMFAULT_PROJECT_SLUG:
description: 'Memfault Project Slug'
required: true

symbol_file:
description: 'Path to the symbol file'
required: true
memfault_cli_version:
description: 'Memfault CLI Version'
required: true
default: "1.0.11"

runs:
using: 'composite'
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install Dependencies
shell: bash
run: pip install memfault-cli==${{ inputs.memfault_cli_version }}

- name: Upload the symbol file
shell: bash
run: |
memfault \
--org-token ${{ inputs.MEMFAULT_ORG_TOKEN }} \
--org ${{ inputs.MEMFAULT_ORG_SLUG }} \
--project ${{ inputs.MEMFAULT_PROJECT_SLUG }} \
upload-mcu-symbols ${{ inputs.symbol_file }}

0 comments on commit 40b02fe

Please sign in to comment.