diff --git a/.github/ISSUE_TEMPLATE/03-gopls.yml b/.github/ISSUE_TEMPLATE/03-gopls.yml index 8ba9712af3087e..5db1315f27e1d3 100644 --- a/.github/ISSUE_TEMPLATE/03-gopls.yml +++ b/.github/ISSUE_TEMPLATE/03-gopls.yml @@ -6,7 +6,7 @@ body: - type: markdown attributes: value: "Please answer these questions before submitting your issue. Thanks!" - - type: textarea + - type: input id: gopls-version attributes: label: "gopls version" diff --git a/.github/ISSUE_TEMPLATE/12-telemetry.yml b/.github/ISSUE_TEMPLATE/12-telemetry.yml index e072df260aaf63..4215abfa99012b 100644 --- a/.github/ISSUE_TEMPLATE/12-telemetry.yml +++ b/.github/ISSUE_TEMPLATE/12-telemetry.yml @@ -1,30 +1,68 @@ name: Go Telemetry Proposals -description: Changes to the telemetry upload configuration +description: New telemetry counter or update on an existing one title: "x/telemetry/config: proposal title" labels: ["Telemetry-Proposal"] projects: ["golang/29"] body: - type: textarea attributes: - label: Summary - description: > - What change are you proposing to the upload configuration, and why? - For new upload configuration, which new counters will be collected, what - do they measure, and why is it important to collect them? - Note that uploaded data must not carry sensitive user information. - See [go.dev/doc/telemetry#proposals](https://go.dev/doc/telemetry#proposals) - for more details on telemetry proposals. + label: Counter names + description: Names of counters to add or update. validations: required: true -- type: input +- type: textarea + attributes: + label: Description + description: What do these counters measure? + validations: + required: true +- type: textarea + attributes: + label: Rationale + description: | + Why is the counter important? + For example, what new insights will it provide, and how will that information be used? + If this is about updating existing counters, why is the change necessary? + validations: + required: true +- type: textarea attributes: - label: Proposed Config Change - description: > - A CL containing proposed changes to the - [config.txt](https://go.googlesource.com/telemetry/+/master/internal/chartconfig/config.txt) - chart configuration. - See the [chartconfig](https://pkg.go.dev/golang.org/x/telemetry/internal/chartconfig) - package for an explanation of the chart config format. - For an example change, see [CL 564619](https://go.dev/cl/564619). + label: Do the counters carry sensitive user information? validations: required: true +- type: textarea + attributes: + label: How? + description: | + How do we plan to compute the info? + If available, include the code location or cl that uses the golang.org/x/telemetry/counter API. + validations: + required: true +- type: textarea + attributes: + label: Proposed Graph Config + description: | + Approved telemetry counters are maintained as [Go Telemetry Graph Config](https://golang.org/x/telemetry/internal/graphconfig) records. + Please draft the record entry for your proposal here. + If multiple records need to be included, separate them with `---` lines. + 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). + render: Text + value: | + counter: gopls/bug + title: Gopls bug reports + description: Stacks of bugs encountered on the gopls server. + type: partition, histogram, stack # choose only one. + program: golang.org/x/tools/gopls + counter: gopls/bug + depth: 16 # only if type is stack. + version: v0.13.0 # the first binary version containing this counter. + validations: + required: true +- type: dropdown + attributes: + label: New or Update + 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. + options: + - New + - Update + default: 0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000000000..5dae30833e0c03 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,122 @@ +name: Build toolchain + +permissions: + contents: write + +on: + push: + branches: + - tailscale + - 'tailscale.go1.23' + pull_request: + branches: + - '*' + workflow_dispatch: + inputs: + ref: + description: Branch, commit or tag to build from + required: true + default: 'tailscale.go1.23' + +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - name: checkout + uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref || github.ref }} + - name: test + run: cd src && ./all.bash + + build_release: + strategy: + matrix: + GOOS: ["linux", "darwin"] + GOARCH: ["amd64", "arm64"] + runs-on: ubuntu-20.04 + if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) + steps: + - name: checkout + uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref || github.ref }} + - name: build + run: cd src && ./make.bash + env: + GOOS: "${{ matrix.GOOS }}" + GOARCH: "${{ matrix.GOARCH }}" + CGO_ENABLED: "0" + - name: trim unnecessary bits + run: | + rm -rf pkg/*_* + mv pkg/tool/${{ matrix.GOOS }}_${{ matrix.GOARCH }} pkg + rm -rf pkg/tool/*_* + mv -f bin/${{ matrix.GOOS }}_${{ matrix.GOARCH }}/* bin/ || true + rm -rf bin/${{ matrix.GOOS }}_${{ matrix.GOARCH }} + mv pkg/${{ matrix.GOOS }}_${{ matrix.GOARCH }} pkg/tool + find . -type d -name 'testdata' -print0 | xargs -0 rm -rf + find . -name '*_test.go' -delete + - name: archive + run: cd .. && tar --exclude-vcs -zcf ${{ matrix.GOOS }}-${{ matrix.GOARCH }}.tar.gz go + - name: save + uses: actions/upload-artifact@v1 + with: + name: ${{ matrix.GOOS }}-${{ matrix.GOARCH }} + path: ../${{ matrix.GOOS }}-${{ matrix.GOARCH }}.tar.gz + + create_release: + runs-on: ubuntu-20.04 + if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) + needs: [test, build_release] + outputs: + url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # Release name can't be the same as tag name, sigh + tag_name: build-${{ inputs.ref || github.sha }} + release_name: ${{ inputs.ref || github.sha }} + draft: false + prerelease: true + + upload_release: + strategy: + matrix: + GOOS: ["linux", "darwin"] + GOARCH: ["amd64", "arm64"] + runs-on: ubuntu-20.04 + if: contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) + needs: [create_release] + steps: + - name: download artifact + uses: actions/download-artifact@v1 + with: + name: ${{ matrix.GOOS }}-${{ matrix.GOARCH }} + - name: upload artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.url }} + asset_path: ${{ matrix.GOOS }}-${{ matrix.GOARCH }}/${{ matrix.GOOS }}-${{ matrix.GOARCH }}.tar.gz + asset_name: ${{ matrix.GOOS }}-${{ matrix.GOARCH }}.tar.gz + asset_content_type: application/gzip + + clean_old: + runs-on: ubuntu-20.04 + # Do not clean up old builds on workflow_dispatch to allow temporarily + # re-creating old releases for backports. + if: github.event_name == 'push' + needs: [upload_release] + steps: + - name: checkout + uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref || github.ref }} + - name: Delete older builds + run: ./.github/workflows/prune_old_builds.sh "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/prune_old_builds.sh b/.github/workflows/prune_old_builds.sh new file mode 100755 index 00000000000000..e7dc68cfba12d6 --- /dev/null +++ b/.github/workflows/prune_old_builds.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -euo pipefail + +KEEP=10 +GITHUB_TOKEN=$1 + +delete_release() { + release_id=$1 + tag_name=$2 + set -x + curl -X DELETE --header "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/tailscale/go/releases/$release_id" + curl -X DELETE --header "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/tailscale/go/git/refs/tags/$tag_name" + set +x +} + +curl https://api.github.com/repos/tailscale/go/releases 2>/dev/null |\ + jq -r '.[] | "\(.published_at) \(.id) \(.tag_name)"' |\ + egrep '[^ ]+ [^ ]+ build-[0-9a-f]{40}' |\ + sort |\ + head --lines=-${KEEP}|\ + while read date release_id tag_name; do + delete_release "$release_id" "$tag_name" + done