diff --git a/CODEOWNERS b/.github/CODEOWNERS similarity index 100% rename from CODEOWNERS rename to .github/CODEOWNERS diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8efd5b3..b42e24f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.23 + go-version-file: 'go.mod' - name: Build run: go build -v ./... @@ -28,6 +28,13 @@ jobs: run: go test -v ./... - name: Lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v8 with: - version: v1.61 + version: v2.3.0 + + - name: Vendorcheck + shell: bash + run: | + go mod tidy + go mod vendor + git diff --exit-code diff --git a/.golangci.yaml b/.golangci.yaml index b693fce..b628721 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,29 +1,26 @@ -linters-settings: - gocyclo: - min-complexity: 25 - govet: - check-shadowing: false - misspell: - locale: "US" - +version: "2" linters: - enable-all: true + default: all disable: - - stylecheck - - gosec - - dupl - depguard - - lll - - prealloc - - gocritic - - gochecknoinits - - gochecknoglobals + - err113 - exhaustruct - - testpackage - - paralleltest - - nlreturn + - funlen + - lll + - musttag - perfsprint - # These are deprecated - - execinquery - - exportloopref - - gomnd + - testpackage + - varnamelen + - wsl + - wsl_v5 + settings: + misspell: + locale: US + exclusions: + presets: + - std-error-handling +formatters: + enable: + - gofmt + - gofumpt + - goimports diff --git a/CHECKLIST.md b/CHECKLIST.md deleted file mode 100644 index 6712295..0000000 --- a/CHECKLIST.md +++ /dev/null @@ -1,25 +0,0 @@ -# New Project Checklist - -- [ ] Clone https://github.com/letsencrypt/gorepotemplate -- [ ] Copy the `gorepotemplate` folder to a new project folder (`cp -r gorepotemplate `) -- [ ] Change into the new project folder (`cd `) -- [ ] Delete the existing `.git` folder from the template project (`rm -rf .git`) -- [ ] Initialize a new git repo (`git init`) -- [ ] Create the Github repoistory in the web UI. Do not select a project language for a `.gitignore`, or a license (these are included in `gorepotemplate`) -- [ ] Add the Github repository as a git remote (`git remote add origin git@github.com:letsencrypt/.git`) -- [ ] Set up the main repository settings (`https://github.com/letsencrypt//settings`): - - [ ] Disable Wikis, Sponsorships, Projects, and Discussions - - [ ] Only allow squash merging - - [ ] Automatically delete head branches -- [ ] Set up collaborators and teams (`https://github.com/letsencrypt//settings/branches`): - - [ ] Ensure the default branch is `main`, not `master` - - [ ] Add a branch protection rule for `main`: - - [ ] Require pull requests before merging, require 1 approval, dismiss stale approvals upon new pushes, and require review from Code Owners - - [ ] Require status checks to pass before merging - - [ ] Require linear history - - [ ] Include administrators - - [ ] Restrict who can push to "@letsencrypt/boulder-developers" -- [ ] Run `./checklist.complete.sh` diff --git a/README.md b/README.md index d40e4e8..1461053 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,41 @@ # gorepotemplate -[![Build Status](https://github.com/letsencrypt/gorepotemplate/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/letsencrypt/gorepotemplate/actions/workflows/test.yml?query=branch%3Amain) - -A short description of the project goes here. +This repository serves as a template for other small go projects started by the +Let's Encrypt team. You should replace this title and description with one +appropriate to your project. ## Usage -How to use the project, whether in source or binary form. +This section should describe how to use your project. Here's how to use this +template repo: + +1. Navigate to https://github.com/letsencrypt/gorepotemplate +2. Click "Use this template" and select "Create a new repository" +3. Select "letsencrypt" as the Owner of the repo, give it a good name, and + create it +5. Set up the correct [general settings](settings): + - Under Features, only select "Issues" and "Preserve this repository" + - Under Pull Requests, only select "Allow squash merging", and set the commit + message to "Pull request title and description" + - Select "Automatically delete head branches" +6. Set up the correct [team access](settings/teams): + - Grant both the Boulder Developers and Ops teams "write" permission +7. Set up the correct [rulesets](settings/rules): + - Create a "New branch ruleset" + - Name it "Protect main", and set the target branches to "Include default + branch" + - Restrict creation, restrict deletion, require linear history, and block + force pushes + - Require a pull request before merging, with 1 required approval, dismissing + stale approvals, requiring review from Code Owners, and requiring approval + of the most recent reviewable push + - Only allow the Squash merge method + - Require status checks to pass, and add the "test" job as a required check. +8. Create a PR updating this README file, and you're done! + - Optionally: also update the CODEOWNERS file to represent what team will own + this code. ## Contributing -How to set up a development environment, make changes, and run tests. +This section should describe how to set up a development environment, make +changes, and run tests. diff --git a/checklist.complete.sh b/checklist.complete.sh deleted file mode 100755 index 54d0f81..0000000 --- a/checklist.complete.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# -# Usage: ./checklist.complete.sh -# -# This script will replace all instances of `gorepotemplate` in README.md with -# the new project name. -# -# It will also *delete*: -# * CHECKLIST.md - you finished it already, right!? -# * hello.go - this is example cruft -# * hello_test.go - also example cruft -# -# Afterwards *you* will need to delete the `checklist.complete.sh` script. -# -set -e - -# The NEW_PROJECT_NAME is assumed to be the name of the directory that -# `checklist.complete.sh` is being run from. -NEW_PROJECT_NAME="${PWD##*/}" - -# If there is no CHECKLIST.md in the directory, fail -if [ ! -f CHECKLIST.md ]; then - echo "CHECKLIST.md not found - have you already run this script?" - exit 1 -fi -rm CHECKLIST.md - -# Replace the gorepotemplate name in the README -sed -i "s/gorepotemplate/$NEW_PROJECT_NAME/g" README.md - -# Allow the removal of the Go files to fail. It doesn't really matter if they're -# already gone. -rm hello.go 2>/dev/null || true -rm hello_test.go 2>/dev/null || true - -echo "All finished!" -echo "Please complete the new repo by removing this script:" -echo " rm $0" diff --git a/go.mod b/go.mod index 730606d..7135a43 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/letsencrypt/gorepotemplate -go 1.23 +go 1.24 diff --git a/hello_test.go b/hello_test.go index a2e9deb..461c60e 100644 --- a/hello_test.go +++ b/hello_test.go @@ -4,6 +4,8 @@ import "testing" // TestHello tests that the Hello function produces the expected greeting. func TestHello(t *testing.T) { + t.Parallel() + testCases := []struct { TestCaseName string Name string @@ -32,6 +34,8 @@ func TestHello(t *testing.T) { for _, tc := range testCases { t.Run(tc.TestCaseName, func(t *testing.T) { + t.Parallel() + if greeting := Hello(tc.Name); greeting != tc.ExpectedGreeting { t.Errorf("hello(%q) returned %q not %q", tc.Name, greeting, tc.ExpectedGreeting)