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
36 changes: 36 additions & 0 deletions .github/workflows/ci-node18.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI - Node 18

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: TypeScript type checking
run: npm run type-check

- name: Lint
run: npm run lint

- name: Run tests
env:
CI: true
NODE_ENV: test
run: npm test

- name: Build package
run: npm run build
36 changes: 36 additions & 0 deletions .github/workflows/ci-node20.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI - Node 20

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: TypeScript type checking
run: npm run type-check

- name: Lint
run: npm run lint

- name: Run tests
env:
CI: true
NODE_ENV: test
run: npm test

- name: Build package
run: npm run build
44 changes: 44 additions & 0 deletions .github/workflows/ci-node22.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI - Node 22

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: TypeScript type checking
run: npm run type-check

- name: Lint
run: npm run lint

- name: Run tests with coverage
env:
CI: true
NODE_ENV: test
run: npm run coverage

- name: Build package
run: npm run build

- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage
name: coverage
fail_ci_if_error: false
123 changes: 12 additions & 111 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,118 +11,19 @@ permissions:
pull-requests: write

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20, 22]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: TypeScript type checking
run: npm run lint

- name: Format check
run: npm run format:check

- name: Run tests with coverage
env:
CI: true
NODE_ENV: test
run: npm run coverage

- name: Build package
run: npm run build

- name: Upload coverage reports
if: matrix.node-version == 22
uses: codecov/codecov-action@v4
with:
directory: ./coverage
name: coverage
fail_ci_if_error: false

# Auto-format job (only runs on Node 22, separate from matrix)
format:
runs-on: ubuntu-latest
needs: test
if: failure() == false

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Format code with Prettier
run: npm run format

- name: Check for formatting changes
id: verify-changed-files
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi

- name: Check if fork PR
id: check-fork
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "is_fork=true" >> $GITHUB_OUTPUT
else
echo "is_fork=false" >> $GITHUB_OUTPUT
fi

- name: Warn about fork PRs
if: steps.verify-changed-files.outputs.changed == 'true' && steps.check-fork.outputs.is_fork == 'true'
run: |
echo "::warning::Formatting changes detected in fork PR. Please run 'npm run format' locally and push the changes."
uses: ./.github/workflows/format.yml
secrets: inherit

- name: Commit formatting changes
if: steps.verify-changed-files.outputs.changed == 'true' && steps.check-fork.outputs.is_fork == 'false'
env:
BRANCH_NAME: ${{ github.head_ref }}
REF_NAME: ${{ github.ref_name }}
run: |
set -e
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Auto-format code with Prettier
test-node18:
needs: format
uses: ./.github/workflows/ci-node18.yml

This commit was automatically generated by GitHub Actions
to ensure consistent code formatting across the project."
test-node20:
needs: format
uses: ./.github/workflows/ci-node20.yml

if [ "${{ github.event_name }}" == "pull_request" ]; then
git push origin HEAD:"$BRANCH_NAME"
else
git push origin HEAD:"$REF_NAME"
fi
test-node22:
needs: format
uses: ./.github/workflows/ci-node22.yml
secrets: inherit
78 changes: 78 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Format

on:
workflow_call:

permissions:
contents: write
pull-requests: write

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Format code with Prettier
run: npm run format

- name: Check for formatting changes
id: verify-changed-files
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi

- name: Check if fork PR
id: check-fork
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "is_fork=true" >> $GITHUB_OUTPUT
else
echo "is_fork=false" >> $GITHUB_OUTPUT
fi

- name: Warn about fork PRs
if: steps.verify-changed-files.outputs.changed == 'true' && steps.check-fork.outputs.is_fork == 'true'
run: |
echo "::warning::Formatting changes detected in fork PR. Please run 'npm run format' locally and push the changes."
exit 1

- name: Commit formatting changes
if: steps.verify-changed-files.outputs.changed == 'true' && steps.check-fork.outputs.is_fork == 'false'
env:
BRANCH_NAME: ${{ github.head_ref }}
REF_NAME: ${{ github.ref_name }}
run: |
set -e
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Auto-format code with Prettier

This commit was automatically generated by GitHub Actions
to ensure consistent code formatting across the project."

if [ "${{ github.event_name }}" == "pull_request" ]; then
git push origin HEAD:"$BRANCH_NAME"
else
git push origin HEAD:"$REF_NAME"
fi
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @jackmisner/utm-toolkit

[![CI](https://github.com/jackmisner/utm-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/jackmisner/utm-toolkit/actions/workflows/ci.yml)

A comprehensive TypeScript library for capturing, storing, and appending UTM tracking parameters. Framework-agnostic core with optional React integration.

## Features
Expand Down
Loading