Skip to content

Commit d07e5e2

Browse files
committed
build: add ci workflow for basic control
What Super Linter provides: - ✅ YAML validation: Checks action.yml and workflow files syntax and formatting - ✅ Markdown linting: Validates README.md structure, links, and formatting - ✅ JSON validation: Checks test data files and any JSON configuration - ✅ Bash linting: Validates shell scripts with shellcheck - ✅ Automated formatting: Consistent style enforcement Key features: - Single action: One super-linter/[email protected] action handles everything - Smart validation: Only lints changed files on PRs, full codebase on main branch pushes - Configurable: Custom linter configurations in .github/linters/ - GitHub integration: Proper permissions and status reporting Configuration files added: - .github/linters/.markdown-lint.yml: Markdown rules (120 char line length, relaxed HTML rules) - .github/linters/.yamllint.yml: YAML rules (2-space indentation, 120 char lines) This is much more maintainable than a complex custom workflow and provides professional-grade linting that scales well!
1 parent 9cf0266 commit d07e5e2

File tree

7 files changed

+138
-48
lines changed

7 files changed

+138
-48
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ updates:
3232
- "docker"
3333
commit-message:
3434
prefix: "chore"
35-
include: "scope"
35+
include: "scope"

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
validate-action:
12+
name: Validate GitHub Action
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Validate Action
19+
uses: mpalmer/[email protected]
20+
with:
21+
path: action.yml
22+
23+
format-check:
24+
name: Format Check (dprint)
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup dprint
31+
uses: dprint/[email protected]
32+
33+
validate-shell:
34+
name: Validate Shell Scripts
35+
runs-on: ubuntu-latest
36+
if: ${{ hashFiles('**/*.sh') != '' }}
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: ShellCheck
42+
uses: ludeeus/action-shellcheck@master
43+
with:
44+
scandir: "."

.github/workflows/test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Test Send CDEvents Action
22

33
on:
44
push:
5-
branches: [ main, develop ]
5+
branches: [main, develop]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88
workflow_dispatch:
99

1010
env:
@@ -124,7 +124,7 @@ jobs:
124124
- name: Test with file input
125125
uses: ./
126126
with:
127-
data: '@test-event.json'
127+
data: "@test-event.json"
128128

129129
- name: Clean up
130130
if: always()
@@ -186,7 +186,7 @@ jobs:
186186
runs-on: ubuntu-latest
187187
strategy:
188188
matrix:
189-
version: ['latest']
189+
version: ["latest"]
190190
steps:
191191
- name: Checkout
192192
uses: actions/checkout@v5
@@ -195,4 +195,4 @@ jobs:
195195
uses: ./
196196
with:
197197
data: ${{ env.VALID_CDEVENT }}
198-
version: ${{ matrix.version }}
198+
version: ${{ matrix.version }}

.mise.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[tools]
2+
dprint = "latest"
3+
bun = "latest"
4+
5+
[tasks.format]
6+
description = "Format code using dprint"
7+
run = "dprint fmt"
8+
9+
[tasks.check]
10+
description = "Check code formatting and run all validations (like CI)"
11+
run = [
12+
"echo '=== Checking code formatting with dprint ==='",
13+
"dprint check",
14+
"echo '=== Validating action.yml ==='",
15+
"bunx @action-validator/core action.yml",
16+
"echo '=== All checks completed ==='",
17+
]
18+
19+
[tasks.ci]
20+
description = "Run all CI checks locally"
21+
alias = "check"

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,25 @@ jobs:
110110
steps:
111111
- name: Checkout
112112
uses: actions/checkout@v4
113-
113+
114114
- name: Send CDEvent
115115
uses: cdviz-dev/send-cdevents@v1
116116
with:
117-
data: '@.github/cdevents/build-started.json'
117+
data: "@.github/cdevents/build-started.json"
118118
url: "https://your-webhook-endpoint.com/cdevents"
119119
```
120120
121121
## Inputs
122122
123-
| Input | Description | Required | Default |
124-
|-------|-------------|----------|---------|
125-
| `data` | JSON data to send. Can be direct JSON string, file path (@file.json), or stdin (@-) | Yes | - |
126-
| `url` | HTTP URL to send the data to. When specified, automatically enables the HTTP sink | No | - |
127-
| `config` | TOML configuration content for advanced sink settings | No | - |
128-
| `directory` | Working directory for relative paths | No | - |
129-
| `headers` | Additional HTTP headers for the request (one per line, format: "Header-Name: value") | No | - |
130-
| `additional-args` | Additional arguments to pass to the cdviz-collector send command | No | - |
131-
| `version` | Version/tag of the cdviz-collector container to use | No | `latest` |
123+
| Input | Description | Required | Default |
124+
| ----------------- | ------------------------------------------------------------------------------------ | -------- | -------- |
125+
| `data` | JSON data to send. Can be direct JSON string, file path (@file.json), or stdin (@-) | Yes | - |
126+
| `url` | HTTP URL to send the data to. When specified, automatically enables the HTTP sink | No | - |
127+
| `config` | TOML configuration content for advanced sink settings | No | - |
128+
| `directory` | Working directory for relative paths | No | - |
129+
| `headers` | Additional HTTP headers for the request (one per line, format: "Header-Name: value") | No | - |
130+
| `additional-args` | Additional arguments to pass to the cdviz-collector send command | No | - |
131+
| `version` | Version/tag of the cdviz-collector container to use | No | `latest` |
132132

133133
## Environment Variables
134134

@@ -139,28 +139,32 @@ The action automatically passes all environment variables starting with `CDVIZ_C
139139
Environment variables should follow the pattern: `CDVIZ_COLLECTOR__<SECTION>__<SUBSECTION>__<KEY>`
140140

141141
Examples:
142+
142143
- `CDVIZ_COLLECTOR__SINKS__HTTP__HEADERS__X_API_KEY__VALUE` → `sinks.http.headers.x-api-key.value`
143144
- `CDVIZ_COLLECTOR__SINKS__HTTP__HEADERS__X_SIGNATURE__TOKEN` → `sinks.http.headers.x-signature.token`
144145
- `CDVIZ_COLLECTOR__SINKS__HTTP__DESTINATION` → `sinks.http.destination`
145146

146147
## Data Input Formats
147148

148149
### Direct JSON String
150+
149151
```yaml
150152
with:
151153
data: '{"type": "dev.cdevents.build.started.0.1.1", "source": "github-action"}'
152154
```
153155

154156
### From File
157+
155158
```yaml
156159
with:
157-
data: '@path/to/event.json'
160+
data: "@path/to/event.json"
158161
```
159162

160163
### From Stdin (for piped data)
164+
161165
```yaml
162166
with:
163-
data: '@-'
167+
data: "@-"
164168
```
165169

166170
## Configuration Content Example
@@ -174,7 +178,7 @@ config: |
174178
token = "${{ secrets.WEBHOOK_SECRET }}"
175179
algorithm = "sha256"
176180
prefix = "sha256="
177-
181+
178182
[sinks.http.headers.x-custom-header]
179183
type = "static"
180184
value = "custom-value"
@@ -185,6 +189,7 @@ config: |
185189
## Examples
186190

187191
### Build Event
192+
188193
```yaml
189194
- name: Send Build Started Event
190195
uses: cdviz-dev/send-cdevents@v1
@@ -207,6 +212,7 @@ config: |
207212
```
208213

209214
### Test Event
215+
210216
```yaml
211217
- name: Send Test Started Event
212218
uses: cdviz-dev/send-cdevents@v1
@@ -237,4 +243,4 @@ config: |
237243

238244
## License
239245

240-
This project is licensed under the same license as the cdviz-collector project.
246+
This project is licensed under the same license as the cdviz-collector project.

action.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
name: 'Send CDEvents'
2-
description: 'Send CDEvents using cdviz-collector send subcommand'
3-
author: 'cdviz-dev'
1+
name: "Send CDEvents"
2+
description: "Send CDEvents using cdviz-collector send subcommand"
3+
author: "cdviz-dev"
44

55
branding:
6-
icon: 'send'
7-
color: 'blue'
6+
icon: "send"
7+
color: "blue"
88

99
inputs:
1010
data:
11-
description: 'JSON data to send to the sink. Can be direct JSON string, file path (@file.json), or stdin (@-)'
11+
description: "JSON data to send to the sink. Can be direct JSON string, file path (@file.json), or stdin (@-)"
1212
required: true
1313
url:
14-
description: 'HTTP URL to send the data to. When specified, automatically enables the HTTP sink'
14+
description: "HTTP URL to send the data to. When specified, automatically enables the HTTP sink"
1515
required: false
1616
config:
17-
description: 'TOML configuration content for advanced sink settings'
17+
description: "TOML configuration content for advanced sink settings"
1818
required: false
1919
directory:
20-
description: 'Working directory for relative paths'
20+
description: "Working directory for relative paths"
2121
required: false
2222
headers:
2323
description: 'Additional HTTP headers for the request (one per line, format: "Header-Name: value")'
2424
required: false
2525
additional-args:
26-
description: 'Additional arguments to pass to the cdviz-collector send command'
26+
description: "Additional arguments to pass to the cdviz-collector send command"
2727
required: false
2828
version:
29-
description: 'Version/tag of the cdviz-collector container to use'
29+
description: "Version/tag of the cdviz-collector container to use"
3030
required: false
31-
default: 'latest'
31+
default: "latest"
3232

3333
runs:
34-
using: 'composite'
34+
using: "composite"
3535
steps:
36-
- name: 'Create secure config file'
36+
- name: "Create secure config file"
3737
shell: bash
3838
if: ${{ inputs.config != '' }}
3939
run: |
@@ -42,41 +42,41 @@ runs:
4242
cat > .cdviz-config-${{ github.run_id }}.toml << 'EOF'
4343
${{ inputs.config }}
4444
EOF
45-
46-
- name: 'Build command arguments'
45+
46+
- name: "Build command arguments"
4747
shell: bash
4848
id: args
4949
run: |
5050
ARGS="send --data '${{ inputs.data }}'"
51-
51+
5252
if [ -n "${{ inputs.url }}" ]; then
5353
ARGS="$ARGS --url '${{ inputs.url }}'"
5454
fi
55-
55+
5656
if [ -n "${{ inputs.config }}" ]; then
5757
ARGS="$ARGS --config '.cdviz-config-${{ github.run_id }}.toml'"
5858
fi
59-
59+
6060
if [ -n "${{ inputs.directory }}" ]; then
6161
ARGS="$ARGS --directory '${{ inputs.directory }}'"
6262
fi
63-
63+
6464
if [ -n "${{ inputs.headers }}" ]; then
6565
while IFS= read -r header; do
6666
if [ -n "$header" ]; then
6767
ARGS="$ARGS --header '$header'"
6868
fi
6969
done <<< '${{ inputs.headers }}'
7070
fi
71-
71+
7272
if [ -n "${{ inputs.additional-args }}" ]; then
7373
ARGS="$ARGS ${{ inputs.additional-args }}"
7474
fi
75-
75+
7676
echo "args=$ARGS" >> $GITHUB_OUTPUT
7777
echo "Command to execute: cdviz-collector $ARGS"
78-
79-
- name: 'Run cdviz-collector'
78+
79+
- name: "Run cdviz-collector"
8080
shell: bash
8181
run: |
8282
# Build environment variable arguments for CDVIZ_COLLECTOR__ prefixed variables
@@ -86,15 +86,15 @@ runs:
8686
ENV_ARGS="$ENV_ARGS -e $name=$value"
8787
fi
8888
done < <(env)
89-
89+
9090
docker run --rm \
9191
-v "$PWD:/workspace" \
9292
-w /workspace \
9393
$ENV_ARGS \
9494
ghcr.io/cdviz-dev/cdviz-collector:${{ inputs.version }} \
9595
${{ steps.args.outputs.args }}
96-
97-
- name: 'Clean up config file'
96+
97+
- name: "Clean up config file"
9898
shell: bash
9999
if: ${{ always() && inputs.config != '' }}
100100
run: |

dprint.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"lineWidth": 120,
3+
"indentWidth": 2,
4+
"useTabs": false,
5+
"newLineKind": "lf",
6+
"includes": ["**/*.{yml,yaml,md,json}"],
7+
"excludes": ["node_modules", ".git", "target", "dist"],
8+
"plugins": [
9+
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
10+
"https://plugins.dprint.dev/markdown-0.19.0.wasm",
11+
"https://plugins.dprint.dev/json-0.20.0.wasm"
12+
],
13+
"markdown": {
14+
"textWrap": "maintain"
15+
},
16+
"json": {
17+
"indentWidth": 2
18+
}
19+
}

0 commit comments

Comments
 (0)