Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
8 changes: 8 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"all": true,
"include": ["src/**/*.js"],
"exclude": ["src/**/*.test.ts", "src/**/*.types.d.ts"],
"reporter": ["text", "text-summary", "html", "lcovonly", "json-summary"],
"reports-dir": "coverage",
"check-coverage": false
}
11 changes: 9 additions & 2 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ runs:
using: 'composite'
steps:
- uses: actions/setup-node@v4
id: setup-node
with:
node-version-file: 'package.json'
cache: 'npm'
- name: 'Cache node_modules'
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ steps.setup-node.outputs.node-version }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: 'Install Node.js dependencies'
run: npm ci
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --prefer-offline --no-audit --no-fund
shell: bash
31 changes: 31 additions & 0 deletions .github/workflows/code-coverage-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Cleanup Code coverage

on:
pull_request:
types:
- closed
branches-ignore:
- 'release-please--**'

env:
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_BUCKET: ${{ vars.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_BUCKET }}
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_KEY_ID: ${{ secrets.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_KEY_ID }}
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_SECRET_KEY: ${{ secrets.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_SECRET_KEY }}

jobs:
cleanup:
name: 'Cleanup code coverage'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- name: 'Delete code coverage report'
run: ./scripts/code-coverage.js delete ${{ github.event.pull_request.head.ref }}
- name: 'Update PR comment'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: 'Code coverage'
message: '📊 The code coverage report has been automatically deleted.'
31 changes: 31 additions & 0 deletions .github/workflows/code-coverage-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish master code coverage

on:
push:
branches:
- master
paths-ignore:
- '**/*.md'

concurrency:
group: code-coverage-master
cancel-in-progress: true

env:
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_BUCKET: ${{ vars.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_BUCKET }}
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_KEY_ID: ${{ secrets.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_KEY_ID }}
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_SECRET_KEY: ${{ secrets.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_SECRET_KEY }}

jobs:
code-coverage:
name: 'Publish master code coverage'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- name: 'Run tests with coverage'
run: npm run test:coverage
- name: 'Publish master code coverage report'
run: ./scripts/code-coverage.js publish master
47 changes: 47 additions & 0 deletions .github/workflows/code-coverage-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish code coverage

on:
pull_request:
types:
- opened
- reopened
- synchronize
paths-ignore:
- '**/*.md'
branches-ignore:
- 'release-please--**'

concurrency:
group: code-coverage-${{ github.event.pull_request.number }}
cancel-in-progress: true

env:
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_BUCKET: ${{ vars.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_BUCKET }}
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_KEY_ID: ${{ secrets.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_KEY_ID }}
CC_CLEVER_TOOLS_PREVIEWS_CELLAR_SECRET_KEY: ${{ secrets.CC_CLEVER_TOOLS_PREVIEWS_CELLAR_SECRET_KEY }}

jobs:
code-coverage:
name: 'Publish code coverage'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- name: 'Run tests with coverage'
run: npm run test:coverage
- name: 'Publish code coverage report'
run: ./scripts/code-coverage.js publish ${{ github.event.pull_request.head.ref }}
- name: 'Prepare PR comment'
id: coverage-comment
run: |
echo "body<<EOF" >> $GITHUB_OUTPUT
./scripts/code-coverage.js pr-comment ${{ github.event.pull_request.head.ref }} >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: 'Add code coverage comment to PR'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: 'Code coverage'
message: ${{ steps.coverage-comment.outputs.body }}
71 changes: 71 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Tests

on:
pull_request:
types:
- opened
- reopened
- synchronize
paths-ignore:
- '**/*.md'
branches-ignore:
- 'release-please--**'

concurrency:
group: tests-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
build:
uses: ./.github/workflows/build.yml
with:
version: ${{ github.event.pull_request.head.ref }}
isPreview: true

tests:
needs: build
name: 'Tests (${{ matrix.os }})'
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
runner: ubuntu-latest
artifact: build-linux-archive
- os: macos
runner: macos-14
artifact: build-macos-archive
- os: win
runner: windows-2025
artifact: build-win-archive
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/download-artifacts
with:
pattern: ${{ matrix.artifact }}
- name: 'Extract built CLI and set CLEVER_BIN'
shell: bash
run: |
set -euo pipefail
mkdir -p cli-under-test
archive=$(find build -type f \( -name "clever-tools-*_${{ matrix.os }}.tar.gz" -o -name "clever-tools-*_${{ matrix.os }}.zip" \) | head -n1)
if [ -z "$archive" ]; then
echo "No archive found for ${{ matrix.os }} under build/"; exit 1
fi
case "$archive" in
*.zip) powershell -NoProfile -Command "Expand-Archive -Path '$archive' -DestinationPath cli-under-test" ;;
*.tar.gz) tar -xzf "$archive" -C cli-under-test ;;
esac
binary=$(find cli-under-test -type f \( -name clever -o -name clever.exe \) | head -n1)
if [ -z "$binary" ]; then
echo "Could not locate clever binary after extraction"; find cli-under-test; exit 1
fi
abs_binary=$(node -e "process.stdout.write(require('path').resolve(process.argv[1]))" "$binary")
echo "CLEVER_BIN=$abs_binary" >> "$GITHUB_ENV"
echo "Using CLI binary: $abs_binary"
"$abs_binary" version
- name: 'Run tests against built CLI'
shell: bash
run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
.clever.json
build/
coverage/
.idea/
.s3cfg*
*.gpg.key
Expand Down
Loading
Loading