Skip to content

Commit

Permalink
Use mise to manage tools and tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav committed Jan 21, 2025
1 parent 25ab0a3 commit 91a2f4a
Show file tree
Hide file tree
Showing 23 changed files with 671 additions and 342 deletions.
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@

# pgregory.net/rapid should be considered generated code to reduce noise.
**/testdata/rapid/**/*.fail linguist-generated

# mise files that don't need to be seen in diffs by default.
mise.lock linguist-generated
/bin/mise lingust-generated
24 changes: 24 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Check out repository
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
mise run generate
- uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c
with:
fail-fast: true
8 changes: 4 additions & 4 deletions .github/workflows/changelog-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
with:
token: ${{ secrets.PAT }} # for push

- name: Batch changes
uses: miniscruff/changie-action@v2
with:
args: merge
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: changie merge

- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
30 changes: 10 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
GOLANGCI_LINT_VERSION: v1.62.0
GOTESTSUM_FORMAT: github-actions

jobs:

lint:
Expand All @@ -23,17 +19,10 @@ jobs:
steps:
- uses: actions/checkout@v4
name: Check out repository
- uses: actions/setup-go@v5
name: Set up Go
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v6
name: Install golangci-lint
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --help
- run: make lint
name: Lint
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: mise run lint

test:
runs-on: ${{ matrix.os }}
Expand All @@ -51,10 +40,9 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# TODO: extract into separate action
- name: Determine Git cache directory
Expand Down Expand Up @@ -99,8 +87,10 @@ jobs:
git --version

- name: Test
run: make ${{ (matrix.no-cover == true) && 'test' || 'cover' }}
run: mise run ${{ (matrix.no-cover == true) && 'test' || 'cover' }}
shell: bash
env:
GOTESTSUM_FORMAT: github-actions

- name: Upload coverage
uses: codecov/[email protected]
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ jobs:
with:
lfs: true

- name: Set up Go
uses: actions/setup-go@v5
- uses: jdx/mise-action@v2
with:
go-version-file: go.mod

# This will handle installing Python and Python dependencies.
- name: Install uv
run: |
curl -LsSf "https://astral.sh/uv/${UV_VERSION}/install.sh" | sh
working_directory: doc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: make build
working-directory: doc
run: mise run doc:build --verbose
env:
CLOUDFLARE_ANALYTICS_TOKEN: ${{ secrets.CLOUDFLARE_ANALYTICS_TOKEN }}
MAIN_BUILD: ${{ github.ref == 'refs/heads/main' }}
Expand Down
31 changes: 12 additions & 19 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,28 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Batch changes
uses: miniscruff/changie-action@v2
with:
args: batch ${{ inputs.version }}

- name: Merge changes
uses: miniscruff/changie-action@v2
with:
args: merge

- name: Get the latest version
id: latest
uses: miniscruff/changie-action@v2
with:
args: latest
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: run
run: |
changie batch ${{ inputs.version }}
changie merge
echo "latest=$(changie latest)" >> "$GITHUB_OUTPUT"
- name: Update unreleased references in docs
run: |
grep -rlF '<!-- gs:version unreleased -->' doc/src |
xargs perl -p -i -e \
's/<!-- gs:version unreleased -->/<!-- gs:version ${{ steps.latest.outputs.output }} -->/g'
's/<!-- gs:version unreleased -->/<!-- gs:version ${{ steps.run.outputs.latest }} -->/g'
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
title: Release ${{ steps.latest.outputs.output }}
branch: release/${{ steps.latest.outputs.output }}
title: Release ${{ steps.run.outputs.latest }}
branch: release/${{ steps.run.outputs.latest }}
labels: prepare-release
commit-message: Release ${{ steps.latest.outputs.output }}
commit-message: Release ${{ steps.run.outputs.latest }}
token: ${{ secrets.PAT }}
body: ''
35 changes: 11 additions & 24 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,15 @@ jobs:
ref: ${{ inputs.ref }}
token: ${{ secrets.PAT }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Query changie
if: inputs.version == ''
id: changie-latest
uses: miniscruff/changie-action@v2
with:
args: latest
- name: Set version (changie)
if: inputs.version == ''
run:
run: |
CHANGIE_VERSION=$(changie latest)
echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV"
env:
CHANGIE_VERSION: ${{ steps.changie-latest.outputs.output }}

- name: Set version (input)
if: inputs.version != ''
run:
Expand Down Expand Up @@ -94,19 +85,15 @@ jobs:
with:
ref: ${{ inputs.ref }}

- name: Query changie
if: inputs.version == ''
id: changie-latest
uses: miniscruff/changie-action@v2
with:
args: latest
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set version (changie)
if: inputs.version == ''
run:
run: |
CHANGIE_VERSION=$(changie latest)
echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV"
env:
CHANGIE_VERSION: ${{ steps.changie-latest.outputs.output }}

- name: Set version (input)
if: inputs.version != ''
run:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/dist
cover.out
cover.html

/.idea
/.mise
81 changes: 54 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,46 @@ We welcome contributes to the project,
but please discuss features or significant changes
in an issue before starting work on them.

## Tools

The following tools are needed to work on this project:

- [Go](https://go.dev/):
The project is written in Go, so you need the Go compiler.
- [gofumpt](https://github.com/mvdan/gofumpt):
Go code formatter used by the project.
It's a stricter version of the standard `gofmt`.
- [golangci-lint](https://golangci-lint.run/):
Bulk linter for Go code.
- [Changie](https://changie.dev/):
We use Changie to manage the changelog.
You'll need this if you make user-facing changes.
- [uv](https://docs.astral.sh/uv/):
We use uv to manage Python dependencies for documentation generation.
You'll need this to preview changes to the doc/ directory.
## Setup

We use [mise](https://mise.jdx.dev) to manage tools dependencies
and development tasks for the project.

If you already have mise set up, `cd` into this directory
and you can begin working on the project.

If you don't have mise set up, you may:

- [Install and set it up](https://mise.jdx.dev/getting-started.html), or
- Use the bootstrap script at `tools/bin/mise` to open a shell session
with mise and all tools installed.

```bash
./tools/bin/mise en
```

This is a good option if you don't want to change your setup.
It will keep mise and all its state entirely within the project directory.
### Tasks
See available tasks with `mise tasks` in the project directory.
Tasks you'll need to run regularly are:

```
# Build the project
mise run build
# Run linters
mise run lint
# Run all tests
mise run test
# Run a documentation server
mise run doc:serve
```

## Making contributions

Expand All @@ -36,21 +59,25 @@ Follow usual best practices for making changes:

More specific guidelines follow:

- For all *user-facing changes*, add a changelog entry with `changie new`.
If a change is not user-facing, add a note in the following format
to the PR description:
- For all *user-facing changes*, add a changelog entry.
We use [Changie](https://changie.dev) for this.
Run `mise run changie new` to add a changelog entry.

If a change is not user-facing,
add a note in the following format to the PR description:

```
[skip changelog]: reason why no changelog entry is needed
```

- For *documentation website changes* (changes made to the doc/ directory),
install [`uv`](https://docs.astral.sh/uv/) and run `make serve`
run `mise run doc:serve` (or just `mise run serve` in the doc/ directory)
to preview changes locally before submitting a pull request.

- For *code changes*,
format all code with [gofumpt](https://github.com/mvdan/gofumpt),
and verify lint checks pass with `make lint`.
ensure generated code is up-to-date (`mise run generate`),
code is well-formatted (`mise run fmt`)
and all lint checks pass (`mise run lint`).

### Stacking changes

Expand Down Expand Up @@ -124,16 +151,16 @@ Markdown files and code comments.
## Testing
We use standard Go testing.
Use mise to run tests:
```sh
go test ./...
mise run test
```
Use `make` to get a coverage report:
If you need to see test coverage, run:
```sh
make cover
mise run cover
```
### Test scripts
Expand Down
Loading

0 comments on commit 91a2f4a

Please sign in to comment.