Skip to content

Commit 8c82521

Browse files
committed
feat: add Golang support
Fixes #19
1 parent 9104bdb commit 8c82521

File tree

7 files changed

+37
-4
lines changed

7 files changed

+37
-4
lines changed

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ go through the diff.
2525
- `ts-roots`: a list of project roots for typescript projects, one root per line.
2626
The values are given relative to the root of the repository, and should
2727
point to the directory containing the `package.json` file.
28+
- `go-roots`: a list of project roots for golang projects, one root per line.
29+
The values are given relative to the root of the repository, and should
30+
point to the directory containing the `go.mod` file.
2831
- `retention-days`: the number of days to keep the list of functions as
2932
[workflow
3033
artifacts](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#about-workflow-artifacts).
@@ -41,6 +44,7 @@ go through the diff.
4144
gh-token | yes
4245
rs-roots | no
4346
ts-roots | no
47+
go-roots | no
4448
retention-days | no
4549
am-version | no
4650

@@ -103,6 +107,10 @@ In the case of a mono repo that would look like
103107
│ ├── README.md
104108
│ │ ...
105109
│ └── Cargo.toml
110+
├── project-d
111+
│ ├── README.md
112+
│ │ ...
113+
│ └── go.mod
106114
├── project-ts
107115
│ ├── README.md
108116
│ │ ...
@@ -119,6 +127,8 @@ with:
119127
project-a
120128
project-b
121129
project-c
130+
go-roots: |
131+
project-d
122132
ts-roots: |
123133
project-ts
124134
```
@@ -133,6 +143,10 @@ Language | Support
133143
:---:|:---:
134144
[Rust](https://github.com/autometrics-dev/autometrics-rs) | ✅
135145
[Typescript](https://github.com/autometrics-dev/autometrics-ts) | ✅
136-
[Go](https://github.com/autometrics-dev/autometrics-go) |
146+
[Go](https://github.com/autometrics-dev/autometrics-go) | ⚠️[^mid]
137147
[Python](https://github.com/autometrics-dev/autometrics-py) | ❌
138148
[C#](https://github.com/autometrics-dev/autometrics-cs) | ❌
149+
150+
151+
[^mid]: Golang's version detects functions decorated with `//autometrics` directives, but
152+
does not deal with `net/http` middleware wrapper yet.

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ inputs:
1414
ts-roots:
1515
description: 'The list of typescript project roots to check. One path per line'
1616
required: false
17+
go-roots:
18+
description: 'The list of golang project roots to check. One path per line'
19+
required: false
1720
retention-days:
1821
description: 'The number of days to keep the artifacts for. Defaults to 0 (inherits the policy from the repository)'
1922
required: false

dist/index.js

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@mapbox/node-pre-gyp": "^1.0.10",
2323
"@octokit/openapi-types": "^18.0.0",
2424
"decompress": "^4.2.1",
25-
"semver": "^7.5.1",
25+
"semver": "^7.5.2",
2626
"tmp": "^0.2.1"
2727
},
2828
"devDependencies": {

src/main.ts

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {checkoutBaseState} from './gitops'
99
const TOKEN = 'gh-token'
1010
const TS_ROOTS = 'ts-roots'
1111
const RS_ROOTS = 'rust-roots'
12+
const GO_ROOTS = 'go-roots'
1213
const RETENTION = 'retention-days'
1314
const AM_VERSION = 'am-version'
1415

@@ -22,6 +23,7 @@ async function run(): Promise<void> {
2223
})
2324
const tsRoots = core.getMultilineInput(TS_ROOTS)
2425
const rsRoots = core.getMultilineInput(RS_ROOTS)
26+
const goRoots = core.getMultilineInput(GO_ROOTS)
2527
const retention = parseInt(core.getInput(RETENTION))
2628
const amVersion =
2729
core.getInput(AM_VERSION) !== '' ? core.getInput(AM_VERSION) : undefined
@@ -33,6 +35,9 @@ async function run(): Promise<void> {
3335
core.startGroup('[head] Building datasets for head branch')
3436
const newAmDatasets: DataSetMap = {}
3537

38+
for (const goRoot of goRoots) {
39+
newAmDatasets[goRoot] = await computeDataSet(amPath, goRoot, 'go')
40+
}
3641
for (const tsRoot of tsRoots) {
3742
newAmDatasets[tsRoot] = await computeDataSet(amPath, tsRoot, 'typescript')
3843
}
@@ -55,6 +60,9 @@ async function run(): Promise<void> {
5560
core.startGroup('[base] Building datasets for base state')
5661
const oldAmDatasets: DataSetMap = {}
5762

63+
for (const goRoot of goRoots) {
64+
oldAmDatasets[goRoot] = await computeDataSet(amPath, goRoot, 'go')
65+
}
5866
for (const tsRoot of tsRoots) {
5967
oldAmDatasets[tsRoot] = await computeDataSet(amPath, tsRoot, 'typescript')
6068
}

0 commit comments

Comments
 (0)