Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

permissions:
contents: read
checks: write
pull-requests: write

steps:
- uses: actions/checkout@v4
Expand All @@ -33,6 +35,29 @@
run: npm test
working-directory: create-github-app-token

- name: Publish Test Results
uses: dorny/test-reporter@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3
if: success() || failure() # run this step even if tests failed
with:
name: Jest Tests
path: create-github-app-token/test-results/junit.xml
reporter: jest-junit
fail-on-error: true
use-actions-summary: true

- name: Publish Code Coverage Results
uses: 5monkeys/cobertura-action@master
if: success() || failure() # run this step even if tests failed
with:
path: create-github-app-token/coverage/cobertura-coverage.xml
repo_token: ${{ secrets.GITHUB_TOKEN }}
minimum_coverage: 80
fail_below_threshold: false
show_line: true
show_branch: true
show_class_names: true
only_changed_files: false

- name: Build
run: npm run build
working-directory: create-github-app-token
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ lib
*.pem
.taskkey

coverage/
coverage/

# Test results
test-results/
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,25 @@ For comprehensive guidance, refer to the [official Microsoft documentation on cr

Both GitHub Actions as well as Azure Pipelines are provided to execute continuous integration. (they are triggered by either a pull request or a push against the `main` branch).

The CI Action packages the extension and uploads it as an artifact, the extension is packaged as `ENTER YOUR PUBLISHER HERE` publisher. You should use your own publisher by setting a variable with the name `PUBLISHER` on the CI pipeline.
The CI workflows include the following features:

- **Build and Test**: Compile TypeScript, run unit tests, and package the extension
- **Unit Test Results**: Both CI systems are configured to publish unit test results:
- **GitHub Actions**: Uses `dorny/test-reporter` to publish test results as pull request comments with detailed test summaries
- **Azure Pipelines**: Uses `PublishTestResults@2` task to display test results in the pipeline run with integrated reporting
- **Code Coverage Results**: Both CI systems are configured to publish code coverage reports:
- **GitHub Actions**: Uses `5monkeys/cobertura-action` to publish coverage results as pull request comments with coverage summaries and line-by-line coverage information
- **Azure Pipelines**: Uses `PublishCodeCoverageResults@1` task to display coverage results in the pipeline run with detailed coverage reports
- **Test and Coverage Configuration**: Jest is configured with:
- JUnit XML reporting (`jest-junit`) for standardized test result files
- Multiple coverage formats including Cobertura XML for CI integration and HTML reports for local viewing
- Coverage thresholds set at 80% for branches, functions, lines, and statements
- **Artifact Publishing**: The extension is packaged and uploaded as an artifact

The extension is packaged as `ENTER YOUR PUBLISHER HERE` publisher. You should use your own publisher by setting a variable with the name `PUBLISHER` on the CI pipeline.

> [!NOTE]
> Test results and code coverage reports are published even if tests fail, providing visibility into both test outcomes and coverage metrics for successful and failing builds.

## Contributing

Expand Down
24 changes: 21 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,27 @@ steps:
displayName: 'Install dependencies'
workingDirectory: create-github-app-token

- script: npm test
displayName: 'Run unit tests'
workingDirectory: create-github-app-token
- script: npm test
displayName: 'Run unit tests'
workingDirectory: create-github-app-token

- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed() # publish results even if tests failed
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'create-github-app-token/test-results/junit.xml'
testRunTitle: 'Jest Unit Tests'
publishRunAttachments: true

- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage Results'
condition: succeededOrFailed() # publish results even if tests failed
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: 'create-github-app-token/coverage/cobertura-coverage.xml'
reportDirectory: 'create-github-app-token/coverage/lcov-report'
failIfCoverageEmpty: false

- script: |
npm run clean
Expand Down
16 changes: 15 additions & 1 deletion create-github-app-token/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@ module.exports = {
'!**/node_modules/**'
],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'text-summary', 'lcov', 'html', 'json'],
coverageReporters: ['text', 'text-summary', 'lcov', 'html', 'json', 'cobertura'],

// JUnit XML reporting for CI systems
reporters: [
'default',
['jest-junit', {
outputDirectory: 'test-results',
outputName: 'junit.xml',
ancestorSeparator: ' › ',
uniqueOutputName: 'false',
suiteNameTemplate: '{filepath}',
classNameTemplate: '{classname}',
titleTemplate: '{title}'
}]
],
coveragePathIgnorePatterns: [
'/node_modules/',
'/test/',
Expand Down
47 changes: 47 additions & 0 deletions create-github-app-token/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion create-github-app-token/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^18.*",
"@types/nock": "^11.1.0",
"@types/node": "^18.*",
"@types/q": "^1.5.8",
"@vercel/ncc": "^0.38.3",
"jest": "^29.7.0",
"jest-environment-node": "^29.7.0",
"jest-junit": "^16.0.0",
"nock": "^13.5.1",
"ts-jest": "^29.1.1",
"typescript": "^5.8.2"
Expand Down