-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yaml
More file actions
80 lines (75 loc) · 2.99 KB
/
Copy pathaction.yaml
File metadata and controls
80 lines (75 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: 'Go Beautiful HTML Coverage'
description: 'A GitHub Action to track code coverage in your pull requests, with a beautiful HTML preview, for free.'
author: 'Kilian Ciuffolo'
branding:
icon: 'bar-chart'
color: 'green'
inputs:
repository:
description: 'Repository name with owner. For example, actions/checkout'
default: ${{ github.repository }}
branch:
default: cover
description: The branch to checkout or create and push coverage to.
token:
description: The token to use for pushing to the repository.
default: ${{ github.token }}
path:
description: The relative path of your go project. Useful for monorepos and custom folder structures.
default: './'
threshold:
description: The minimum % of coverage required.
default: '0'
runs:
using: composite
steps:
- name: Checkout Coverage Branch
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
path: go-cover
token: ${{ inputs.token }}
- id : 'normalize-path'
name: Normalize Input Path
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const script = require(`${process.env.GITHUB_ACTION_PATH}/src/normalize-path.js`)
return script('${{ inputs.path }}')
- name: Checkout Coverage Branch
shell: bash
run: |
export INPUTS_BRANCH="${{ inputs.branch }}"
export INPUTS_PATH="${{ steps.normalize-path.outputs.result }}"
${GITHUB_ACTION_PATH}/scripts/pull.sh
- name: Push Coverage
shell: bash
run: |
export REVISION="${{ github.event.pull_request.head.sha || github.sha }}"
export INPUTS_PATH="${{ steps.normalize-path.outputs.result }}"
export INPUTS_BRANCH="${{ inputs.branch }}"
export REF_NAME="${{ github.ref_name }}"
${GITHUB_ACTION_PATH}/scripts/push.sh
- name: Post Code Coverage Comment
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ inputs.token }}
script: |
const script = require(`${process.env.GITHUB_ACTION_PATH}/src/update-comment.js`)
const revision = '${{ github.event.pull_request.head.sha || github.sha }}'
const threshold = parseFloat('${{ inputs.threshold }}', 10)
const path = '${{ steps.normalize-path.outputs.result }}'
await script({ context, github, path, revision, threshold })
- name: Check Coverage Threshold
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ inputs.token }}
script: |
const script = require(`${process.env.GITHUB_ACTION_PATH}/src/check-threshold.js`)
const revision = '${{ github.event.pull_request.head.sha || github.sha }}'
const threshold = parseFloat('${{ inputs.threshold }}', 10)
const path = '${{ steps.normalize-path.outputs.result }}'
await script({ threshold, path, revision })