-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
350 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
changelog: | ||
exclude: | ||
labels: | ||
- Skip-Release-Notes | ||
categories: | ||
- title: Bugfixes | ||
labels: | ||
- Bug-Fix | ||
- title: New Features | ||
labels: | ||
- New Feature | ||
- title: Enhancements | ||
labels: | ||
- Enhancement | ||
- title: Not Yet Enabled | ||
labels: | ||
- Not-Yet-Enabled | ||
- title: Other | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Check PR category and type | ||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
types: [opened, synchronize, reopened, labeled, unlabeled, edited] | ||
jobs: | ||
check_label: | ||
runs-on: ubuntu-latest | ||
name: Check PR Category and Type | ||
steps: | ||
- name: Checking for correct number of required github pr labels | ||
uses: mheap/github-action-required-labels@v2 | ||
with: | ||
mode: exactly | ||
count: 1 | ||
labels: "New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes" | ||
|
||
- name: "Checking for PR Category in PR title. Should be like '<category>: <pr title>'." | ||
run: | | ||
if [[ ! "${{ github.event.pull_request.title }}" =~ ^.{2,}\:.{2,} ]]; then | ||
echo "## PR Category is missing from PR title. Please add it like '<category>: <pr title>'." >> GITHUB_STEP_SUMMARY | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package logic | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// SourceMap provides a mapping of the source to assembled program | ||
type SourceMap struct { | ||
Version int `json:"version"` | ||
File string `json:"file,omitempty"` | ||
SourceRoot string `json:"sourceRoot,omitempty"` | ||
Sources []string `json:"sources"` | ||
Names []string `json:"names"` | ||
Mappings string `json:"mappings"` | ||
// Decoded mapping results | ||
LineToPc map[int][]int | ||
PcToLine map[int]int | ||
} | ||
|
||
func DecodeSourceMap(ism map[string]interface{}) (SourceMap, error) { | ||
sm := SourceMap{} | ||
|
||
if v, ok := ism["version"]; ok { | ||
sm.Version = int(v.(float64)) | ||
} | ||
|
||
if sm.Version != 3 { | ||
return sm, fmt.Errorf("only version 3 is supported") | ||
} | ||
|
||
if f, ok := ism["file"]; ok { | ||
sm.File = f.(string) | ||
} | ||
|
||
if sr, ok := ism["sourceRoot"]; ok { | ||
sm.SourceRoot = sr.(string) | ||
} | ||
|
||
if srcs, ok := ism["sources"]; ok { | ||
srcSlice := srcs.([]interface{}) | ||
sm.Sources = make([]string, len(srcSlice)) | ||
for idx, s := range srcSlice { | ||
sm.Sources[idx] = s.(string) | ||
} | ||
} | ||
|
||
if names, ok := ism["names"]; ok { | ||
nameSlice := names.([]interface{}) | ||
sm.Names = make([]string, len(nameSlice)) | ||
for idx, n := range nameSlice { | ||
sm.Names[idx] = n.(string) | ||
} | ||
} | ||
|
||
if m, ok := ism["mappings"]; ok { | ||
sm.Mappings = m.(string) | ||
} | ||
|
||
if sm.Mappings == "" { | ||
return sm, fmt.Errorf("no mappings defined") | ||
} | ||
|
||
sm.PcToLine = map[int]int{} | ||
sm.LineToPc = map[int][]int{} | ||
|
||
lastLine := 0 | ||
for idx, chunk := range strings.Split(sm.Mappings, ";") { | ||
vals := decodeSourceMapLine(chunk) | ||
// If the vals length >= 3 the lineDelta | ||
if len(vals) >= 3 { | ||
lastLine = lastLine + vals[2] // Add the line delta | ||
} | ||
|
||
if _, ok := sm.LineToPc[lastLine]; !ok { | ||
sm.LineToPc[lastLine] = []int{} | ||
} | ||
|
||
sm.LineToPc[lastLine] = append(sm.LineToPc[lastLine], idx) | ||
sm.PcToLine[idx] = lastLine | ||
} | ||
|
||
return sm, nil | ||
} | ||
|
||
func (s *SourceMap) GetLineForPc(pc int) (int, bool) { | ||
line, ok := s.PcToLine[pc] | ||
return line, ok | ||
} | ||
|
||
func (s *SourceMap) GetPcsForLine(line int) []int { | ||
return s.LineToPc[line] | ||
} | ||
|
||
const ( | ||
// consts used for vlq encoding/decoding | ||
b64table string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" | ||
vlqShiftSize = 5 | ||
vlqFlag = 1 << vlqShiftSize | ||
vlqMask = vlqFlag - 1 | ||
) | ||
|
||
func decodeSourceMapLine(vlq string) []int { | ||
|
||
var ( | ||
results []int | ||
value, shift int | ||
) | ||
|
||
for i := 0; i < len(vlq); i++ { | ||
digit := strings.Index(b64table, string(vlq[i])) | ||
|
||
value |= (digit & int(vlqMask)) << shift | ||
|
||
if digit&vlqFlag > 0 { | ||
shift += vlqShiftSize | ||
continue | ||
} | ||
|
||
if value&1 > 0 { | ||
value = (value >> 1) * -1 | ||
} else { | ||
value = value >> 1 | ||
} | ||
|
||
results = append(results, value) | ||
|
||
// Reset | ||
value, shift = 0, 0 | ||
} | ||
|
||
return results | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.