Skip to content

Commit 1a47993

Browse files
authored
ci: Add some ci workflows (#7)
1 parent 8bf31f5 commit 1a47993

File tree

12 files changed

+427
-0
lines changed

12 files changed

+427
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Setup Environment
2+
description: Setup Bun and install dependencies with caching
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup Bun
8+
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
9+
10+
- name: Restore dependences cache
11+
uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
12+
id: restore-bun-dependences-cache
13+
with:
14+
path: node_modules
15+
key: ${{ runner.os }}-bun-dependences-${{ hashFiles('**/bun.lock') }}
16+
17+
- name: Install dependencies
18+
# Install only if cache is not matched.
19+
if: ${{ !contains(steps.restore-bun-dependences-cache.outputs.cache-matched-key, steps.restore-bun-dependences-cache.outputs.cache-primary-key) }}
20+
run: bun install --frozen-lockfile
21+
shell: bash
22+
23+
- name: Save dependences cache
24+
# Execute cache by default branch only.
25+
if: ${{ github.ref_name == github.event.repository.default_branch && !contains(steps.restore-bun-dependences-cache.outputs.cache-matched-key, steps.restore-bun-dependences-cache.outputs.cache-primary-key) }}
26+
uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
27+
id: save-dependences-cache
28+
with:
29+
path: node_modules
30+
key: ${{ runner.os }}-bun-dependences-${{ hashFiles('**/bun.lock') }}

.github/codecov.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Codecov configuration for safe-formdata
2+
# This project requires 100% test coverage
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "100...100"
8+
9+
status:
10+
project:
11+
default:
12+
target: 100%
13+
threshold: 0%
14+
if_ci_failed: error
15+
16+
patch:
17+
default:
18+
target: 100%
19+
threshold: 0%
20+
if_ci_failed: error
21+
22+
comment:
23+
layout: "header, diff, flags, components"
24+
behavior: default
25+
require_changes: false
26+
require_base: false
27+
require_head: true
28+
29+
github_checks:
30+
annotations: true

.github/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- "ignore for release"
5+
6+
categories:
7+
- title: Security Fixes
8+
labels: ["Type: Security", "security"]
9+
- title: Breaking Changes
10+
labels: ["Type: Breaking Change"]
11+
- title: Features
12+
labels: ["Type: Feature"]
13+
- title: Bug Fixes
14+
labels: ["Type: Bug"]
15+
- title: Documentation
16+
labels: ["Type: Documentation"]
17+
- title: CI
18+
labels: ["Type: CI"]
19+
- title: Dependency Updates
20+
labels: ["Type: Dependencies", "dependencies"]
21+
- title: Other Changes
22+
labels: ["*"]

.github/workflows/assign.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Auto Assign
2+
run-name: "${{ github.workflow }} (${{ github.ref_name }}): ${{ github.event.pull_request.title }}"
3+
4+
on:
5+
pull_request:
6+
types: [opened, reopened, ready_for_review]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
assign:
18+
runs-on: ubuntu-slim
19+
timeout-minutes: 2
20+
permissions:
21+
pull-requests: write
22+
steps:
23+
- name: Assign PR to author if no assignees
24+
if: ${{ github.event.pull_request.user.type != 'Bot' && toJSON(github.event.pull_request.assignees) == '[]' }}
25+
run: gh pr edit $NUMBER --add-assignee $ASSIGNEE
26+
env:
27+
GH_TOKEN: ${{ github.token }}
28+
GH_REPO: ${{ github.repository }}
29+
NUMBER: ${{ github.event.pull_request.number }}
30+
ASSIGNEE: ${{ github.event.pull_request.user.login }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Dependency Review (workflow_call)
2+
run-name: "${{ github.workflow }} (${{ github.ref_name }}): ${{ github.event.pull_request.title }}"
3+
4+
on: workflow_call
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
dependency-review:
16+
name: Review Dependencies
17+
runs-on: ubuntu-slim
18+
timeout-minutes: 2
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
22+
with:
23+
persist-credentials: false
24+
25+
- name: Dependency Review
26+
uses: actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2
27+
with:
28+
deny-licenses: GPL-2.0, GPL-3.0
29+
fail-on-severity: moderate
30+
comment-summary-in-pr: always
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Export Validation (workflow_call)
2+
run-name: "${{ github.workflow }} (${{ github.ref_name }}): ${{ github.event.pull_request.title }}"
3+
4+
on: workflow_call
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
export-validation:
12+
name: Export Validation
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
18+
with:
19+
persist-credentials: false
20+
21+
- name: Initialize
22+
uses: ./.github/actions/setup-environment
23+
24+
- name: Build package
25+
run: bun run build
26+
27+
- name: Verify build outputs
28+
run: |
29+
test -f dist/index.js || (echo "dist/index.js not found" && exit 1)
30+
test -f dist/index.js.map || (echo "dist/index.js.map not found" && exit 1)
31+
test -f dist/index.d.ts || (echo "dist/index.d.ts not found" && exit 1)
32+
echo "Build verification successful"
33+
34+
- name: Validate exports
35+
run: bun run check:package
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint & Format Check (workflow_call)
2+
run-name: "${{ github.workflow }} (${{ github.ref_name }}): ${{ github.event.pull_request.title }}"
3+
4+
on: workflow_call
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
lint-format:
12+
name: Lint & Format Check
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
18+
with:
19+
persist-credentials: false
20+
21+
- name: Initialize
22+
uses: ./.github/actions/setup-environment
23+
24+
- name: Run Lint & Format Check
25+
run: bun run check:source

.github/workflows/call-test.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test (workflow_call)
2+
run-name: "${{ github.workflow }} (${{ github.ref_name }}): ${{ github.event.pull_request.title }}"
3+
4+
on:
5+
workflow_call:
6+
secrets:
7+
CODECOV_TOKEN:
8+
description: Token for Codecov upload
9+
required: true
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
test:
17+
name: Test
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 5
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
23+
with:
24+
persist-credentials: false
25+
26+
- name: Initialize
27+
uses: ./.github/actions/setup-environment
28+
29+
- name: Run tests with coverage
30+
run: bun run test:coverage
31+
32+
- name: Upload coverage to Codecov
33+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
34+
with:
35+
token: ${{ secrets.CODECOV_TOKEN }}
36+
fail_ci_if_error: true
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Type Check (workflow_call)
2+
run-name: "${{ github.workflow }} (${{ github.ref_name }}): ${{ github.event.pull_request.title }}"
3+
4+
on: workflow_call
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
type-check:
12+
name: TypeScript Type Check
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
18+
with:
19+
persist-credentials: false
20+
21+
- name: Initialize
22+
uses: ./.github/actions/setup-environment
23+
24+
- name: Run type check
25+
run: bun run check:type

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI
2+
run-name: "${{ github.workflow }} (${{ github.ref_name }}): ${{ github.event.pull_request.title }}"
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
types: [opened, synchronize, reopened, ready_for_review]
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
# This workflow contains core CI jobs that run on push/pull_request events.
20+
# For additional jobs, create separate workflow_call files (e.g., call-*.yml)
21+
# and invoke them from this workflow. See .github/workflows/call-dependency-review.yml for reference.
22+
jobs:
23+
setup:
24+
name: Setup
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 5
27+
permissions:
28+
pull-requests: read
29+
if: ${{ !github.event.pull_request.draft }}
30+
outputs:
31+
dependencies: ${{ steps.filter.outputs.dependencies }}
32+
typescript: ${{ steps.filter.outputs.typescript }}
33+
steps:
34+
- name: Checkout Repository
35+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
36+
with:
37+
persist-credentials: false
38+
39+
- name: Initialize
40+
uses: ./.github/actions/setup-environment
41+
42+
- name: Check diff targets by path filters
43+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
44+
id: filter
45+
with:
46+
filters: |
47+
dependencies:
48+
- 'bun.lock'
49+
typescript:
50+
- 'bun.lock'
51+
- '**/tsconfig*.json'
52+
- '**/*.ts'
53+
- '**/*.tsx'
54+
55+
lint-format:
56+
needs: [setup]
57+
uses: ./.github/workflows/call-lint-format.yml
58+
59+
type-check:
60+
needs: [setup]
61+
if: ${{ needs.setup.outputs.typescript == 'true' }}
62+
uses: ./.github/workflows/call-type-check.yml
63+
64+
test:
65+
needs: [setup]
66+
uses: ./.github/workflows/call-test.yml
67+
secrets:
68+
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
69+
70+
export-validation:
71+
needs: [setup, lint-format, type-check, test]
72+
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
73+
uses: ./.github/workflows/call-export-validation.yml
74+
75+
status-check:
76+
name: Status Check
77+
runs-on: ubuntu-slim
78+
timeout-minutes: 1
79+
needs: [setup, lint-format, type-check, test, export-validation]
80+
if: always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
81+
steps:
82+
- run: exit 1

0 commit comments

Comments
 (0)