Skip to content
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
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @silv-io
5 changes: 3 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<!-- Why am I raising this PR? Add context such as related issues, PRs, or documentation. -->

# Motivation

<!-- What notable changes does this PR make? -->

# Changes

<!-- The following sections are optional, but can be useful!
<!-- The following sections are optional, but can be useful!

## Testing

Expand All @@ -17,4 +19,3 @@ What's left to do:
- [ ] ...
- [ ] ...
-->

8 changes: 6 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ updates:
directory: /
schedule:
interval: monthly
cooldown:
default-days: 7
groups:
actions:
patterns:
- "*"
- '*'

- package-ecosystem: npm
directory: /
schedule:
interval: monthly
cooldown:
default-days: 7
groups:
npm:
patterns:
- "*"
- '*'
83 changes: 0 additions & 83 deletions .github/linters/.eslintrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ MD029:

MD013:
line_length: 110
code_blocks: false
code_blocks: false
2 changes: 1 addition & 1 deletion .github/linters/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"compilerOptions": {
"noEmit": true
},
"include": ["../../__tests__/**/*", "../../src/**/*"],
"include": ["../../__tests__/**/*", "../../__mocks__/**/*", "../../src/**/*"],
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
}
8 changes: 5 additions & 3 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
cache: npm
Expand Down Expand Up @@ -58,7 +60,7 @@ jobs:
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
id: upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist
path: dist/
18 changes: 11 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
cache: npm
Expand All @@ -46,20 +48,22 @@ jobs:
test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest
needs:
needs:
- test-typescript
if: always()

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Test Local Action
id: test-action
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tinybird_token: ${{ secrets.TINYBIRD_CI_TOKEN }}
tinybird_datasource: "ci_workflows_test"
workflow_id: "testing-workflow-id-param"
tinybird_token: ${{ secrets.TINYBIRD_CI_TOKEN }} # zizmor: ignore[secrets-outside-env]
tinybird_datasource: 'ci_workflows_test'
workflow_id: 'testing-workflow-id-param'
23 changes: 17 additions & 6 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0
persist-credentials: false

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
cache: npm
Expand All @@ -32,15 +37,21 @@ jobs:
id: install
run: npm ci

- name: Lint (ESLint)
id: eslint
run: npm run lint

- name: Lint Codebase
id: super-linter
uses: super-linter/super-linter/slim@v5
uses: super-linter/super-linter/slim@9e863354e3ff62e0727d37183162c4a88873df41 # v8.6.0
env:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: dist/**/*
FILTER_REGEX_EXCLUDE: dist/.*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_BIOME_FORMAT: false
VALIDATE_BIOME_LINT: false
VALIDATE_JAVASCRIPT_ES: false
VALIDATE_JSCPD: false
VALIDATE_MARKDOWN: false
VALIDATE_TYPESCRIPT_ES: false
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.6.0
24
72 changes: 45 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
# Push GitHub Action workflow run attempt data to Tinybird

This GitHub action enables you to send GitHub workflow run statistics to
[Tinybird](https://www.tinybird.co/). The format in which the data is sent is as follows:
This GitHub Action enables you to send GitHub workflow run statistics to
[Tinybird](https://www.tinybird.co/). The format in which the data is sent is as
follows:

```json
{
"run_id": "The GitHub run ID as a string",
"start": "The start time of the workflow run",
"end": "The time of the execution of the action (end of the run)",
"commit": "The commit hash of the commit the workflow is executed on",
"branch": "The branch on which the workflow is executed",
"workflow": "The name of the workflow",
"repository": "The repository in the format <owner>/<repo-name>",
"attempt": "The number of the run attempt",
"outcome": "'failure' if at least one job failed, 'success' otherwise",
"workflow_url": "The URL to the workflow run attempt this payload describes"
}
{
"run_id": "The GitHub run ID as a string",
"start": "The start time of the workflow run",
"end": "The time of the execution of the action (end of the run)",
"commit": "The commit hash of the commit the workflow is executed on",
"branch": "The branch on which the workflow is executed",
"workflow": "The name of the workflow",
"repository": "The repository in the format <owner>/<repo-name>",
"attempt": "The number of the run attempt",
"outcome": "'failure' if at least one job failed, 'success' otherwise",
"workflow_url": "The URL to the workflow run attempt this payload describes"
}
```

## Usage

Add this action as the last one in your step like this:

```yaml
steps:
- name: Push to Tinybird
Expand All @@ -32,11 +35,15 @@ steps:
workflow_id: <custom-workflow-id>
```

> [!IMPORTANT]
> Make sure to set the right conditions and dependencies on the step / job.
> [!IMPORTANT] Make sure to set the right conditions and dependencies on the
> step / job.

- `if: always()` is necessary to also execute this step in case a previous step already failed (otherwise this step would be skipped and `failure` workflow data will never be sent).
- If you have this action in an explicit job, make sure to also define the `always()` condition _and_ set the all previous jobs as dependencies on for the job:
- `if: always()` is necessary to also execute this step in case a previous step
already failed (otherwise this step would be skipped and `failure` workflow
data will never be sent).
- If you have this action in an explicit job, make sure to also define the
`always()` condition _and_ set the all previous jobs as dependencies on for
the job:
```yaml
jobs:
...
Expand All @@ -50,9 +57,14 @@ steps:
```

### Usage in callable workflows
In callable workflows, the usual outcome detection might not work correctly, since the job outcome of all jobs in the composite workflow would be detected.
It also isn't possible to access the `needs` context from within the GitHub action in order to analyze only the outcome of the dependencies of this specific sub-workflow.
We introduced the `outcome` input for this usecase to manually set a outcome which should be sent to Tinybird:

In callable workflows, the usual outcome detection might not work correctly,
since the job outcome of all jobs in the composite workflow would be detected.
It also isn't possible to access the `needs` context from within the GitHub
Action in order to analyze only the outcome of the dependencies of this specific
sub-workflow. We introduced the `outcome` input for this usecase to manually set
a outcome which should be sent to Tinybird:

```yaml
steps:
- name: Push to Tinybird
Expand All @@ -63,28 +75,34 @@ steps:
tinybird_token: ${{ secrets.TINYBIRD_TOKEN }}
tinybird_datasource: <your-data-source>
workflow_id: <custom-workflow-id>
outcome: ${{ ((contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 'failure') || 'success' }}
outcome:
${{ ((contains(needs.*.result, 'failure') || contains(needs.*.result,
'cancelled')) && 'failure') || 'success' }}
```

## Inputs

### `github_token`

**Required**: This token is used to access the GitHub API to access the start time of the workflow run.
**Required**: This token is used to access the GitHub API to access the start
time of the workflow run.

### `tinybird_token`

**Required**: This token is used to authenticate with Tinybird.

### `tinybird_datasource`

**Optional**: This is the endpoint to which the workflow run data should be pushed to. (default: `ci_workflows`)
**Optional**: This is the endpoint to which the workflow run data should be
pushed to. (default: `ci_workflows`)

### `workflow_id`

**Optional**: This is the ID of the workflow sent to tinybird. (default: the output of `github.context.workflow`)
**Optional**: This is the ID of the workflow sent to tinybird. (default: the
output of `github.context.workflow`)

### `outcome`

**Optional**: Manually override the outcome reported to Tinybird.
(default: the outcome is calculated using the worst outcome of all jobs in the current workflow run attempt)
**Optional**: Manually override the outcome reported to Tinybird. (default: the
outcome is calculated using the worst outcome of all jobs in the current
workflow run attempt)
Loading