diff --git a/.github/workflows/main.c b/.github/workflows/main.c new file mode 100644 index 0000000..42b3300 --- /dev/null +++ b/.github/workflows/main.c @@ -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 + +// 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; +} diff --git a/.github/workflows/test_action.yml b/.github/workflows/test_action.yml new file mode 100644 index 0000000..8f9c85c --- /dev/null +++ b/.github/workflows/test_action.yml @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..7911982 --- /dev/null +++ b/README.md @@ -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). diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..a4a0c76 --- /dev/null +++ b/action.yml @@ -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 }}