Skip to content

Commit

Permalink
prep release v2.0.0 (#142)
Browse files Browse the repository at this point in the history
Co-authored-by: brookesargent <brookesargent01@gmail.com>
  • Loading branch information
mjayaram and brookesargent authored Sep 16, 2022
1 parent 628b7cd commit 966d556
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 10 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# gha-buildevents changelog

## v2.0.0 [2022-09-16]

### Breaking Change and Enhancement

- Support and allow for traces to be Workflow scoped rather than only per Job (#140) | [@brookesargent](https://github.com/brookesargent)

### Maintenance

- Bump @actions/core from 1.2.7 to 1.9.1 (#131) [@mjayaram](https://github.com/mjayaram)
- Upgrade action runtime from node12 to node16 (#141) [@mjayaram](https://github.com/mjayaram)

## v1.0.7 [2022-07-14]

### Maintenance
Expand Down
96 changes: 87 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@

This GitHub Action instruments your workflows using [Honeycomb's buildevents tool](https://github.com/honeycombio/buildevents). It populates the trace with metadata from the GitHub Actions environment and will always send a trace for the build, even if the build failed.

`gha-buildevents` has to be added to every job that should be instrumented. Every job will create a separate trace.
`gha-buildevents` has to be added to every job that should be instrumented.

### ⚠️ Limitations

- this action only works on Linux hosts (though technically support could be added for other platforms)

- if downloading or executing buildevents fails, the entire job will fail

### 📣 Adopting version 2.0.0

- The required input field `job-status` has been renamed to `status`. This was done because status now can be job's or the workflow's.
We still support job-status but will give a warning that it is deprecated and encourage the switch to the status field.


- Each Job MUST include unique STEP IDs to ensure each job's spans are properly organized together.
- An example of adopting these changes is in the [Integration Worflow](.github/workflows/integration.yaml) of this repo. Here is the corresponding trace:
![Integration Workflow Trace](images/integration-worflow.png)

## How to use it

Put the action at the start of each job:
### Single Job Workflow

```yaml
- uses: honeycombio/gha-buildevents@v1
Expand All @@ -27,9 +37,10 @@ Put the action at the start of each job:
# Required: the Honeycomb dataset to send traces to.
dataset: gha-buildevents_integration

# Required: the job status, this will be used in the post section and sent
# as status of the trace. Must always be ${{ job.status }}.
job-status: ${{ job.status }}
# Optional: status, this will be used in the post section and sent
# as status of the trace. Set on the final job of a workflow to signal for the trace to # end
# job-status has been deprecated
status: ${{ job.status }}

# Optional: this should only be used in combination with matrix builds. Set
# this to a value uniquely describing each matrix configuration.
Expand All @@ -40,6 +51,73 @@ Put the action at the start of each job:
# gha-buildevents will automatically run as a post action and execute 'buildevents build'
```

### Multi Job Workflow

In the **FIRST JOB**

Note: The step to start the workflow's trace should run first (before other jobs too)

```yaml
the-job-that-runs-first:
runs-on: ubuntu-latest

steps:
- name: Set trace-start
id: set-trace-start
run: |
echo ::set-output name=trace-start::$(date +%s)
- uses: honeycombio/gha-buildevents@v1
with:
# Required: a Honeycomb API key - needed to send traces.
apikey: ${{ secrets.BUILDEVENTS_APIKEY }}

# Required: the Honeycomb dataset to send traces to.
dataset: gha-buildevents_integration

# Optional: this should only be used in combination with matrix builds. Set
# this to a value uniquely describing each matrix configuration.
matrix-key: ${{ matrix.value }}

# ... the rest of your job ...
outputs:
trace-start: ${{ steps.set-trace-start.outputs.trace-start }}

# ... Job 2 ...
```

Then add the **new** **LAST JOB**

```yaml
end-trace:
runs-on: ubuntu-latest
needs: [the-job-that-runs-first, job2]
if: ${{ always() }}
steps:
- uses: technote-space/workflow-conclusion-action@v3
- uses: honeycombio/gha-buildevents@v1
with:
# Required: a Honeycomb API key - needed to send traces.
apikey: ${{ secrets.BUILDEVENTS_APIKEY }}

# Required: the Honeycomb dataset to send traces to.
dataset: gha-buildevents_integration

# Optional: status, this will be used in the post section and sent
# as status of the trace. Set on the final job of a workflow to signal for the trace # to end
# job-status has been deprecated
status: ${{ env.WORKFLOW_CONCLUSION }}

# Optional: trace-start, this will be used in the post section and sent
# to calculate duration of the trace. In multi job workflows, set on the final job of a workflow. Not necessary for single job workflows
trace-start: ${{ needs.build.outputs.trace-start}}

# Optional: this should only be used in combination with matrix builds. Set
# this to a value uniquely describing each matrix configuration.
matrix-key: ${{ matrix.value }}

# gha-buildevents will automatically run as a post action and execute 'buildevents build'
```

`gha-buildevents` is a _wrapping action_. This means it has a post section which will run at the end of the build, after all other steps. In this final step the trace is finalized using `buildevents build`. Since this step runs always, even if the job failed, you don't have to worry about traces not being sent.

### Inputs
Expand All @@ -48,7 +126,7 @@ Name | Required | Description |
-------------|----------|------------------------------------------------------|-------
`apikey` | yes | API key used to communicate with the Honeycomb API. | string
`dataset` | yes | Honeycomb dataset to use. | string
`job-status` | yes | The job status, must be set to `${{ job.status }}`. | string
`status` | yes | The job or workflow status | string
`matrix-key` | no | Set this to a key unique for this matrix cell. | string

Additionally, the following environment variable will be read:
Expand All @@ -60,11 +138,11 @@ When setting this environment variable, is recommended to set this [at the begin

No outputs are set, but the following environment variables are set:

`TRACE_ID`: the trace ID is a combination of the repository, the workflow, the job name, the run number, optionally a matrix key and a random string. This trace ID will be unique across re-runs of the workflow. The format:
`TRACE_ID`: the trace ID is a combination of the repository, the workflow, the job name, the run number, the run attempt, and optionally a matrix key. This trace ID will be unique across re-runs of the workflow. The format:
```
<owner>/<repo>-<workflow>-<job>-<run number>-<random number>
<owner>/<repo>-<workflow>-<job>-<run number>-<run attempt>
```
For example: `honeycombio/gha-buildevents-Integration-smoke-test-20144-1738717406`.
For example: `honeycombio/gha-buildevents-Integration-smoke-test-20144-1`.

## Example

Expand Down
Binary file added images/integration-worflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gha-buildevents",
"version": "1.0.7",
"version": "2.0.0",
"description": "GitHub Actions to integrate Honeycomb's buidlevents tool into your workflows",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 966d556

Please sign in to comment.