Skip to content

Commit d09f29d

Browse files
committed
[tailscale] add .github
Updates #47
1 parent 81ee091 commit d09f29d

File tree

4 files changed

+203
-19
lines changed

4 files changed

+203
-19
lines changed

.github/ISSUE_TEMPLATE/03-gopls.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ body:
66
- type: markdown
77
attributes:
88
value: "Please answer these questions before submitting your issue. Thanks!"
9-
- type: textarea
9+
- type: input
1010
id: gopls-version
1111
attributes:
1212
label: "gopls version"
+56-18
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,68 @@
11
name: Go Telemetry Proposals
2-
description: Changes to the telemetry upload configuration
2+
description: New telemetry counter or update on an existing one
33
title: "x/telemetry/config: proposal title"
44
labels: ["Telemetry-Proposal"]
55
projects: ["golang/29"]
66
body:
77
- type: textarea
88
attributes:
9-
label: Summary
10-
description: >
11-
What change are you proposing to the upload configuration, and why?
12-
For new upload configuration, which new counters will be collected, what
13-
do they measure, and why is it important to collect them?
14-
Note that uploaded data must not carry sensitive user information.
15-
See [go.dev/doc/telemetry#proposals](https://go.dev/doc/telemetry#proposals)
16-
for more details on telemetry proposals.
9+
label: Counter names
10+
description: Names of counters to add or update.
1711
validations:
1812
required: true
19-
- type: input
13+
- type: textarea
14+
attributes:
15+
label: Description
16+
description: What do these counters measure?
17+
validations:
18+
required: true
19+
- type: textarea
20+
attributes:
21+
label: Rationale
22+
description: |
23+
Why is the counter important?
24+
For example, what new insights will it provide, and how will that information be used?
25+
If this is about updating existing counters, why is the change necessary?
26+
validations:
27+
required: true
28+
- type: textarea
2029
attributes:
21-
label: Proposed Config Change
22-
description: >
23-
A CL containing proposed changes to the
24-
[config.txt](https://go.googlesource.com/telemetry/+/master/internal/chartconfig/config.txt)
25-
chart configuration.
26-
See the [chartconfig](https://pkg.go.dev/golang.org/x/telemetry/internal/chartconfig)
27-
package for an explanation of the chart config format.
28-
For an example change, see [CL 564619](https://go.dev/cl/564619).
30+
label: Do the counters carry sensitive user information?
2931
validations:
3032
required: true
33+
- type: textarea
34+
attributes:
35+
label: How?
36+
description: |
37+
How do we plan to compute the info?
38+
If available, include the code location or cl that uses the golang.org/x/telemetry/counter API.
39+
validations:
40+
required: true
41+
- type: textarea
42+
attributes:
43+
label: Proposed Graph Config
44+
description: |
45+
Approved telemetry counters are maintained as [Go Telemetry Graph Config](https://golang.org/x/telemetry/internal/graphconfig) records.
46+
Please draft the record entry for your proposal here.
47+
If multiple records need to be included, separate them with `---` lines.
48+
You can check the list of the approved counters and their current configuration in [config.txt](https://go.googlesource.com/telemetry/+/master/internal/configgen/config.txt).
49+
render: Text
50+
value: |
51+
counter: gopls/bug
52+
title: Gopls bug reports
53+
description: Stacks of bugs encountered on the gopls server.
54+
type: partition, histogram, stack # choose only one.
55+
program: golang.org/x/tools/gopls
56+
counter: gopls/bug
57+
depth: 16 # only if type is stack.
58+
version: v0.13.0 # the first binary version containing this counter.
59+
validations:
60+
required: true
61+
- type: dropdown
62+
attributes:
63+
label: New or Update
64+
description: Is this a new counter? See [config.txt](https://go.googlesource.com/telemetry/+/master/internal/configgen/config.txt) for the list of approved counters.
65+
options:
66+
- New
67+
- Update
68+
default: 0

.github/workflows/build.yml

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Build toolchain
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
branches:
9+
- tailscale
10+
- 'tailscale.go1.23'
11+
pull_request:
12+
branches:
13+
- '*'
14+
workflow_dispatch:
15+
inputs:
16+
ref:
17+
description: Branch, commit or tag to build from
18+
required: true
19+
default: 'tailscale.go1.23'
20+
21+
jobs:
22+
test:
23+
runs-on: ubuntu-20.04
24+
steps:
25+
- name: checkout
26+
uses: actions/checkout@v3
27+
with:
28+
ref: ${{ inputs.ref || github.ref }}
29+
- name: test
30+
run: cd src && ./all.bash
31+
32+
build_release:
33+
strategy:
34+
matrix:
35+
GOOS: ["linux", "darwin"]
36+
GOARCH: ["amd64", "arm64"]
37+
runs-on: ubuntu-20.04
38+
if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
39+
steps:
40+
- name: checkout
41+
uses: actions/checkout@v3
42+
with:
43+
ref: ${{ inputs.ref || github.ref }}
44+
- name: build
45+
run: cd src && ./make.bash
46+
env:
47+
GOOS: "${{ matrix.GOOS }}"
48+
GOARCH: "${{ matrix.GOARCH }}"
49+
CGO_ENABLED: "0"
50+
- name: trim unnecessary bits
51+
run: |
52+
rm -rf pkg/*_*
53+
mv pkg/tool/${{ matrix.GOOS }}_${{ matrix.GOARCH }} pkg
54+
rm -rf pkg/tool/*_*
55+
mv -f bin/${{ matrix.GOOS }}_${{ matrix.GOARCH }}/* bin/ || true
56+
rm -rf bin/${{ matrix.GOOS }}_${{ matrix.GOARCH }}
57+
mv pkg/${{ matrix.GOOS }}_${{ matrix.GOARCH }} pkg/tool
58+
find . -type d -name 'testdata' -print0 | xargs -0 rm -rf
59+
find . -name '*_test.go' -delete
60+
- name: archive
61+
run: cd .. && tar --exclude-vcs -zcf ${{ matrix.GOOS }}-${{ matrix.GOARCH }}.tar.gz go
62+
- name: save
63+
uses: actions/upload-artifact@v1
64+
with:
65+
name: ${{ matrix.GOOS }}-${{ matrix.GOARCH }}
66+
path: ../${{ matrix.GOOS }}-${{ matrix.GOARCH }}.tar.gz
67+
68+
create_release:
69+
runs-on: ubuntu-20.04
70+
if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
71+
needs: [test, build_release]
72+
outputs:
73+
url: ${{ steps.create_release.outputs.upload_url }}
74+
steps:
75+
- name: create release
76+
id: create_release
77+
uses: actions/create-release@v1
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
with:
81+
# Release name can't be the same as tag name, sigh
82+
tag_name: build-${{ inputs.ref || github.sha }}
83+
release_name: ${{ inputs.ref || github.sha }}
84+
draft: false
85+
prerelease: true
86+
87+
upload_release:
88+
strategy:
89+
matrix:
90+
GOOS: ["linux", "darwin"]
91+
GOARCH: ["amd64", "arm64"]
92+
runs-on: ubuntu-20.04
93+
if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
94+
needs: [create_release]
95+
steps:
96+
- name: download artifact
97+
uses: actions/download-artifact@v1
98+
with:
99+
name: ${{ matrix.GOOS }}-${{ matrix.GOARCH }}
100+
- name: upload artifact
101+
uses: actions/upload-release-asset@v1
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
with:
105+
upload_url: ${{ needs.create_release.outputs.url }}
106+
asset_path: ${{ matrix.GOOS }}-${{ matrix.GOARCH }}/${{ matrix.GOOS }}-${{ matrix.GOARCH }}.tar.gz
107+
asset_name: ${{ matrix.GOOS }}-${{ matrix.GOARCH }}.tar.gz
108+
asset_content_type: application/gzip
109+
110+
clean_old:
111+
runs-on: ubuntu-20.04
112+
# Do not clean up old builds on workflow_dispatch to allow temporarily
113+
# re-creating old releases for backports.
114+
if: github.event_name == 'push'
115+
needs: [upload_release]
116+
steps:
117+
- name: checkout
118+
uses: actions/checkout@v3
119+
with:
120+
ref: ${{ inputs.ref || github.ref }}
121+
- name: Delete older builds
122+
run: ./.github/workflows/prune_old_builds.sh "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/prune_old_builds.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
KEEP=10
6+
GITHUB_TOKEN=$1
7+
8+
delete_release() {
9+
release_id=$1
10+
tag_name=$2
11+
set -x
12+
curl -X DELETE --header "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/tailscale/go/releases/$release_id"
13+
curl -X DELETE --header "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/tailscale/go/git/refs/tags/$tag_name"
14+
set +x
15+
}
16+
17+
curl https://api.github.com/repos/tailscale/go/releases 2>/dev/null |\
18+
jq -r '.[] | "\(.published_at) \(.id) \(.tag_name)"' |\
19+
egrep '[^ ]+ [^ ]+ build-[0-9a-f]{40}' |\
20+
sort |\
21+
head --lines=-${KEEP}|\
22+
while read date release_id tag_name; do
23+
delete_release "$release_id" "$tag_name"
24+
done

0 commit comments

Comments
 (0)