Skip to content

Commit

Permalink
feat: initial commit of action
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma11hewThomas committed Jan 14, 2025
1 parent 2a34a61 commit 5d9e01d
Show file tree
Hide file tree
Showing 33 changed files with 60,065 additions and 20 deletions.
41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "GitHub Actions (TypeScript)",
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
"postCreateCommand": "npm install",
"customizations": {
"codespaces": {
"openFiles": ["README.md"]
},
"vscode": {
"extensions": [
"bierner.markdown-preview-github-styles",
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"github.copilot",
"github.copilot-chat",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"me-dutour-mathieu.vscode-github-actions",
"redhat.vscode-yaml",
"rvest.vs-code-prettier-eslint",
"yzhang.markdown-all-in-one"
],
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"editor.formatOnSave": true,
"markdown.extension.list.indentationSize": "adaptive",
"markdown.extension.italic.indicator": "_",
"markdown.extension.orderedList.marker": "one"
}
}
},
"remoteEnv": {
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers-contrib/features/prettier:1": {}
}
}
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf

dist/** -diff linguist-generated=true
58 changes: 58 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 'action'

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
test-action:
runs-on: ubuntu-latest

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

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Run Test Reports Action Locally
id: test-action
uses: ./
with:
ctrf-report-path: './ctrf-reports/ctrf-report.json'
template-path: './templates/custom-summary.hbs'
summary-report: true
failed-report: true
flaky-report: true
flaky-rate-report: true
fail-rate-report: true
previous-results-report: true
ai-report: true
failed-folded-report: false
suite-folded-report: true
suite-list-report: true
# custom-report: true # Enable if using a custom template

# Behavior Options
# title: 'My Custom Tests'
# use-suite-name: true
# pull-request: true
# previous-results-max: 10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Print Output Summary
run: echo "${{ steps.test-action.outputs.summary }}"

- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: ctrf-report
path: ctrf-reports/ctrf-report.json
if: always()
105 changes: 104 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,108 @@
dist
node_modules
./ctrf
/ctrf
/coverage

# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*

# IDE files
.idea
.vscode
*.code-workspace
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.6.2
167 changes: 167 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: 'tbc'
description:
'A GitHub Action to build test reports and publish to job summaries and pull
requests.'
author: 'ctrf-io'

branding:
icon: 'file'
color: 'blue'

inputs:
# Core Configuration
report-path:
description: 'Path to the CTRF report JSON file.'
required: true
template-path:
description:
'Path to the Handlebars template for customizing markdown output.'
required: false
title:
description:
'Title to display in the GitHub Actions summary or pull request comment.'
required: false

# Report Options
summary-report:
description: 'Include the summary report.'
required: false
default: false
test-report:
description: 'Include the tests table report.'
required: false
default: false
test-list-report:
description: 'Include the tests list report.'
required: false
default: false
failed-report:
description: 'Include the failed tests report.'
required: false
default: false
fail-rate-report:
description: 'Include the fail rate report.'
required: false
default: false
flaky-report:
description: 'Include the flaky tests report.'
required: false
default: false
flaky-rate-report:
description: 'Include the flaky rate report.'
required: false
default: false
failed-folded-report:
description: 'Include the failed folded report.'
required: false
default: false
previous-results-report:
description: 'Include the previous results report.'
required: false
default: false
ai-report:
description: 'Include the AI analysis report.'
required: false
default: false
skipped-report:
description: 'Include the skipped report.'
required: false
default: false
suite-folded-report:
description: 'Include the suite folded report.'
required: false
default: false
suite-list-report:
description: 'Include the suite list report.'
required: false
default: false
pull-request-report:
description: 'Include the pull request report.'
required: false
default: false
custom-report:
description: >
Include a custom report using a Handlebars template. To group tests in the
custom report, use the 'group-by' or 'always-group-by' input.
required: false
default: false

# Behavior Options
summary:
description: 'Post generated markdown to the GitHub Actions summary.'
required: false
default: true
pull-request:
description: 'Add a comment to the pull request with the generated report.'
required: false
default: false
annotate:
description: 'Add annotations to failed tests in the GitHub Actions UI.'
required: false
default: true
on-fail-only:
description: 'Add a pull request comment only if tests fail.'
required: false
default: false
exit-on-fail:
description: 'Exit the workflow with a failure status if any tests fail.'
required: false
default: false
use-suite-name:
description: 'Prefix test names with the suite name for better grouping.'
required: false
default: false
updateComment:
description: 'Update existing Pull Request comment.'
required: false
default: false
overwriteComment:
description: 'Overwrite existing Pull Request comment.'
required: false
default: false
commentTag:
description: 'Tag to match Pull Request comment'
required: false
default: false

# Advanced Options
artifact-name:
description: 'Name of the artifact containing test reports.'
required: false
default: 'ctrf-report'
previous-results-max:
description:
'Maximum number of previous test results to display in the report.'
required: false
default: 10
fetch-previous-results:
description:
'Always fetch previous workflow runs when using custom templates.'
required: false
default: false
group-by:
description: >
Specify grouping for applicable reports (e.g., suite or file path).
Options: - 'suite': Group tests by their suite property. - 'filePath':
Group tests by their file path. Default is 'filePath'. Use this for
built-in or custom reports where grouping is needed.
required: false
default: 'filePath'
always-group-by:
description:
Force grouping by suite or file path for all reports, overriding default
behavior
required: false
default: false
debug:
description: 'Enable debug mode for verbose logging.'
required: false
default: false

outputs:
summary:
description: 'The markdown summary generated from the test report.'

runs:
using: 'node20'
main: dist/index.js
1 change: 1 addition & 0 deletions badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5d9e01d

Please sign in to comment.