diff --git a/.github/workflows/main.c b/.github/workflows/main.c new file mode 100644 index 0000000..a489b6f --- /dev/null +++ b/.github/workflows/main.c @@ -0,0 +1,11 @@ +// Stub main to generate a tiny, valid symbol file for testing upload. +// To generate the symbol file, run: +// +// arm-none-eabi-gcc -Os -g1 -mcpu=cortex-m4 -ffreestanding -nostdlib -Wl,--entry=main 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. + +int main() { + return 0; +} diff --git a/.github/workflows/test.elf b/.github/workflows/test.elf new file mode 100755 index 0000000..23fb9c1 Binary files /dev/null and b/.github/workflows/test.elf differ diff --git a/.github/workflows/test_action.yml b/.github/workflows/test_action.yml new file mode 100644 index 0000000..db4fc8c --- /dev/null +++ b/.github/workflows/test_action.yml @@ -0,0 +1,28 @@ +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: 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 }}