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
16 changes: 15 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,23 @@ jobs:
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build
run: npm run build

- name: Publish Delta Coverage
id: render-delta-coverage
uses: gw-kit/delta-coverage-action@v1
uses: ./
with:
summary-report-base-path: 'test/data/'

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.idea
node_modules/
coverage/
.DS_Store
157 changes: 3 additions & 154 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,159 +33,8 @@ inputs:
outputs:
badges-dir:
description: 'Directory with generated badges.'
value: ${{ steps.generate-badges.outputs.badges-dir }}
value: 'badges/'

runs:
using: "composite"

steps:

- name: Build All Summaries
id: all-summaries
uses: actions/github-script@v7
with:
github-token: ${{ inputs.github-token }}
script: |
const readSummaries = require('${{ github.action_path }}/src/read-summaries.js');
const summariesBaseDir = `${{ inputs.summary-report-base-path }}`;
const deltaSummariesFile = await readSummaries({
isFullCoverageMode: false,
baseSummariesPath: summariesBaseDir,
});
const fullCovSummariesFile = await readSummaries({
isFullCoverageMode: true,
baseSummariesPath: summariesBaseDir,
});
core.setOutput('delta', deltaSummariesFile);
core.setOutput('full', fullCovSummariesFile);

- name: Install Badge Dependencies
continue-on-error: true
shell: bash
run: |
npm install gradient-badge
mv ./node_modules "${{ github.action_path }}/src/"

- name: Generate Badges
id: generate-badges
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
const generateBadges = require('${{ github.action_path }}/src/generate-badges.js');
await generateBadges({
summariesFile: '${{ steps.all-summaries.outputs.full }}',
core: core
});

- name: Fetch PR Labels
id: fetch-labels
if: ${{ github.event_name == 'pull_request' }}
shell: 'bash'
env:
GH_TOKEN: ${{ inputs.github-token }}
PR_ENDPOINT: "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}"
run: |
LABELS=$(gh api ${PR_ENDPOINT} --jq '.labels[].name' || echo "")
LABELS_CLEAN=$(echo "$LABELS" | tr '\n' ',' | sed 's/,$//')
echo "labels=$LABELS_CLEAN" >> $GITHUB_OUTPUT

- name: Check for Suppression
id: check-suppress
uses: actions/github-script@v7
with:
script: |
const labels = '${{ steps.fetch-labels.outputs.labels }}';
const suppressedByLabel = labels.includes('suppress-coverage');
const suppressedByInput = '${{ inputs.suppress-check-failures }}' === 'true';
const resolution = suppressedByLabel || suppressedByInput;
core.info(`Is suppress=${resolution} : by label=${suppressedByLabel}, by input=${suppressedByInput}`);
core.setOutput('suppress', resolution);

- name: Create Check Run
id: create-check-runs
uses: actions/github-script@v7
with:
github-token: ${{ inputs.github-token }}
script: |
const createCheckRuns = require('${{ github.action_path }}/src/create-check-runs.js');
const extraRenderScript = (view) => {
const script = ${{ inputs.check-run-extra-render-script || '(v) => ""' }};
try { return script(view) } catch(e) {
return `Error in custom script: ${e}`
};
};
const checkRuns = await createCheckRuns({
summaryReportPath: `${{ steps.all-summaries.outputs.delta }}`,
ignoreCoverageFailure: ${{ steps.check-suppress.outputs.suppress }},
core: core,
context: context,
github: github,
headSha: `${{ github.event.pull_request.head.sha || github.sha }}`,
externalId: `${{ inputs.external-id }}`,
summaryExtraFun: extraRenderScript
});
core.setOutput('check-runs', checkRuns);

- name: Create Comment Marker
id: comment-marker
if: ${{ inputs.title != '' }}
shell: bash
run: echo 'result=${{ format('<!-- marker={0} -->', inputs.title) }}' >> $GITHUB_OUTPUT

- name: Find Existing Comment In PR
id: find-comment
if: ${{ steps.comment-marker.outputs.result && github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ inputs.github-token }}
script: |
const response = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
const comment = response.data.find(it =>
it.body.includes('${{ steps.comment-marker.outputs.result }}')
)
if (comment) {
console.log(`Comment found: ${comment.id}`);
return comment.id
}

- id: build-message
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ inputs.github-token }}
script: |
const createCommentMsg = require('${{ github.action_path }}/src/build-comment-body.js');
return createCommentMsg({
checkRunsContent: `${{ steps.create-check-runs.outputs.check-runs }}`,
commentTitle: '${{ inputs.title }}',
commentMarker: `${{ steps.comment-marker.outputs.result }}`,
core: core
});

- name: Update or Create Comment
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
with:
github-token: ${{ inputs.github-token }}
script: |
if ('${{ steps.find-comment.outputs.result }}') {
github.rest.issues.updateComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: '${{ steps.find-comment.outputs.result }}',
body: ${{ steps.build-message.outputs.result }}
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ${{ steps.build-message.outputs.result }}
})
}
using: 'node20'
main: 'dist/index.js'
Loading
Loading