Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug objects #15

Merged
merged 7 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ __tests__/runner/*
lib/**/*

output
target
destination
*.bin
test/fixtures/tinker/tinker.cpp
23 changes: 17 additions & 6 deletions AUTO_VERSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,22 @@ jobs:
uses: particle-iot/compile-action@main
with:
particle-platform-name: 'boron'
device-os-version: 'latest-lts'

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ steps.compile.outputs.artifact-path }}
path: |
${{ steps.compile.outputs.firmware-path }}
${{ steps.compile.outputs.target-path }}

- name: Create archive of target directory
run: |
tar -czf debug-objects.tar.gz ${{ steps.compile.outputs.target-path }}

- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: ${{ steps.compile.outputs.artifact-path }}
artifacts: ${{ steps.compile.outputs.firmware-path }},debug-objects.tar.gz
generateReleaseNotes: 'true'
name: "Firmware v${{ steps.compile.outputs.firmware-version }}"
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -108,13 +113,14 @@ jobs:
uses: particle-iot/compile-action@main
with:
particle-platform-name: 'boron'
device-os-version: 'latest-lts'
auto-version: true

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ steps.compile.outputs.artifact-path }}
path: |
${{ steps.compile.outputs.firmware-path }}
${{ steps.compile.outputs.target-path }}

- name: Commit updated version file
if: steps.compile.outputs.firmware-version-updated == 'true'
Expand All @@ -131,11 +137,16 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

- name: Create archive of target directory
if: steps.compile.outputs.firmware-version-updated == 'true'
run: |
tar -czf debug-objects.tar.gz ${{ steps.compile.outputs.target-path }}

- name: Create GitHub release
if: steps.compile.outputs.firmware-version-updated == 'true'
uses: ncipollo/release-action@v1
with:
artifacts: ${{ steps.compile.outputs.artifact-path }}
artifacts: ${{ steps.compile.outputs.firmware-path }},debug-objects.tar.gz
generateReleaseNotes: 'true'
name: "Firmware v${{ steps.compile.outputs.firmware-version }}"
tag: "v${{ steps.compile.outputs.firmware-version }}"
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ A GitHub Action to compile Particle application firmware

### Outputs

* `artifact-path`: Path to the compiled binary artifact. Example: `output/firmware-argon-2.3.1.bin`
* `firmware-path`: Path to the compiled binary artifact. Example: `firmware-argon-2.3.1.bin`
* `target-path`: Path to the folder with compiled firmware files and their associated object files. The folder includes the firmware binary, ELF, HEX, and MAP files, along with object files. Not available when particle-access-token is set (cloud compile).
* `device-os-version`: The Device OS version that was used for compilation. This may differ from the requested version if the requested version is a semver range or `latest` or `latest-lts`. Example: `2.3.1`
* `firmware-version`: The product firmware version integer. This output is undefined when sources are not a product firmware.
* `firmware-version-updated`: Boolean value indicating whether the product firmware version was updated. Can only be true with auto-version enabled.
Expand Down Expand Up @@ -79,7 +80,9 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: firmware
path: ${{ steps.compile.outputs.artifact-path }}
path: |
${{ steps.compile.outputs.firmware-path }}
${{ steps.compile.outputs.target-path }}
```

Compilation occurs inside the GitHub Action runner using the Particle [Buildpack Docker images](https://github.com/particle-iot/firmware-buildpack-builder).
Expand Down
8 changes: 5 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ inputs:
description: 'Name of the macro that contains the product firmware version.'
default: 'PRODUCT_VERSION'
outputs:
artifact-path:
description: 'Path to the compiled binary file. Example: output/firmware-argon-2.3.1.bin'
firmware-path:
description: 'Path to the compiled firmware binary file.'
target-path:
description: 'Path to the folder with compiled firmware files and their associated object files. The folder includes the firmware binary, ELF, HEX, and MAP files, along with object files. Not available when particle-access-token is set (cloud compile).'
device-os-version:
description: 'This output contains the actual Device OS version used for compilation. Example: 4.0.2'
description: 'This output contains the actual Device OS version used for compilation.'
firmware-version:
description: 'The product firmware version integer. This output is undefined when sources are not a product firmware.'
firmware-version-updated:
Expand Down
56 changes: 37 additions & 19 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 19 additions & 9 deletions src/action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getInput, info, setFailed, setOutput } from '@actions/core';
import { dockerBuildpackCompile, dockerCheck } from './docker';
import { dockerBuildpackCompile, dockerCheck, downloadTargetDirectory } from './docker';
import { particleCloudCompile, particleDownloadBinary } from './particle-api';
import { renameFile, resolveVersion, validatePlatformDeviceOsTarget, validatePlatformName, preprocessSources } from './util';
import { incrementVersion, isProductFirmware, shouldIncrementVersion } from './autoversion';
Expand All @@ -15,7 +15,8 @@ interface ActionInputs {
}

interface ActionOutputs {
artifactPath: string;
firmwareBinary: string;
targetDir: string;
deviceOsVersion: string;
firmwareVersion: number | undefined;
firmwareVersionUpdated: boolean;
Expand All @@ -39,9 +40,10 @@ async function resolveInputs(): Promise<ActionInputs> {
}

function setOutputs(
{ artifactPath, deviceOsVersion, firmwareVersion, firmwareVersionUpdated }: ActionOutputs
{ firmwareBinary, targetDir, deviceOsVersion, firmwareVersion, firmwareVersionUpdated }: ActionOutputs
): void {
setOutput('artifact-path', artifactPath);
setOutput('firmware-path', firmwareBinary);
setOutput('target-path', targetDir);
setOutput('device-os-version', deviceOsVersion);
setOutput('firmware-version', firmwareVersion);
setOutput('firmware-version-updated', firmwareVersionUpdated);
Expand Down Expand Up @@ -126,24 +128,31 @@ export async function compile(
}
): Promise<{
outputPath: string | undefined;
targetDir: string;
}> {
let outputPath: string | undefined;
let targetDir = '';
if (!auth) {
info('No access token provided, running local compilation');
await dockerCheck();
// Preprocesses .ino files into .cpp files
// The cloud compiler does this automatically
preprocessSources(sources);
outputPath = await dockerBuildpackCompile({ sources, platform, targetVersion, workingDir: process.cwd() });
const containerName = `compile-${Date.now()}`;
outputPath = await dockerBuildpackCompile({
sources, platform, targetVersion, workingDir: process.cwd(), containerName
});
targetDir = 'target';
await downloadTargetDirectory({ containerName: containerName, destination: targetDir });
} else {
info('Access token provided, running cloud compilation');
const binaryId = await particleCloudCompile({ sources, platform, targetVersion, auth });
if (!binaryId) {
throw new Error('Failed to compile code in cloud');
}
outputPath = await particleDownloadBinary({ binaryId, auth });
outputPath = await particleDownloadBinary({ binaryId, auth, platform, targetVersion });
}
return { outputPath };
return { outputPath, targetDir };
}

export async function compileAction(): Promise<void> {
Expand All @@ -155,7 +164,7 @@ export async function compileAction(): Promise<void> {
sources, gitRepo, autoVersionEnabled, versionMacroName
});

const { outputPath } = await compile(
const { outputPath, targetDir } = await compile(
{ auth, platform, sources, targetVersion }
);

Expand All @@ -167,7 +176,8 @@ export async function compileAction(): Promise<void> {
});

setOutputs({
artifactPath: artifactPath,
firmwareBinary: artifactPath,
targetDir,
deviceOsVersion: targetVersion,
firmwareVersion: version,
firmwareVersionUpdated: incremented
Expand Down
Loading