Skip to content

Commit

Permalink
ci: Use Mise to track tools and run tasks (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav authored Feb 2, 2025
1 parent 3485167 commit 95bb67f
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 139 deletions.
29 changes: 12 additions & 17 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,26 @@ permissions:
jobs:
generate-pr:
runs-on: ubuntu-latest
name: Generate release PR

steps:
- 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
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get the latest version
id: latest
uses: miniscruff/changie-action@v2
with:
args: latest
- id: run
run: |
changie batch ${{ inputs.version }}
changie merge
echo "latest=$(changie latest)" >> "$GITHUB_OUTPUT"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
title: Release ${{ steps.latest.outputs.output }}
branch: release/${{ steps.latest.outputs.output }}
commit-message: Release ${{ steps.latest.outputs.output }}
title: Release ${{ steps.run.outputs.latest }}
branch: release/${{ steps.run.outputs.latest }}
commit-message: Release ${{ steps.run.outputs.latest }}
token: ${{ secrets.GITHUB_TOKEN }}
36 changes: 10 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
pull_request:
branches: [ '*' ]

env:
GO_VERSION: 1.22.x

jobs:

lint:
Expand All @@ -17,19 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v4
name: Check out repository
- uses: actions/setup-go@v5
name: Set up Go
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- uses: golangci/golangci-lint-action@v6
name: Install golangci-lint
with:
version: latest
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 @@ -39,20 +27,16 @@ jobs:
os: ["ubuntu-latest", "windows-latest"]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: make build
- name: Install
run: mise run install
shell: bash

- name: Test
run: make cover
env:
TEST_FLAGS: '-race'
run: mise run test:cover -race
shell: bash

- name: Upload coverage
Expand Down
36 changes: 12 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,26 @@ jobs:
with:
ref: ${{ inputs.version || github.ref }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
cache: true

- name: Install parse-changelog
uses: taiki-e/install-action@v2
with:
tool: [email protected]

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: jdx/mise-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Determine version (tagged release)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
set -eou pipefail
REF=${{ github.ref }}
echo "VERSION=${REF#refs/tags/v}" >> "$GITHUB_ENV"
- name: Determine version (manual dispatch)
if: github.event_name == 'workflow_dispatch'
- name: Set version (changie)
if: inputs.version == ''
run: |
CHANGIE_VERSION=$(changie latest)
echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV"
- name: Set version (input)
if: inputs.version != ''
run:
echo "VERSION=${INPUT_VERSION#v}" >> "$GITHUB_ENV"
env:
INPUT_VERSION: ${{ inputs.version }}

- name: Extract changelog
run: |
parse-changelog CHANGELOG.md ${{ env.VERSION }} > ${{ github.workspace }}-CHANGELOG.txt
tail -n+2 .changes/v${{ env.VERSION }}.md \
| tee ${{ github.workspace }}-CHANGELOG.txt
echo ::group::CHANGELOG
cat ${{ github.workspace }}-CHANGELOG.txt
echo ::endgroup::
Expand Down
72 changes: 0 additions & 72 deletions Makefile

This file was deleted.

64 changes: 64 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[env]
GOBIN = "{{ config_root }}/bin"
_.path = ["{{ config_root }}/bin"]

[vars]
_readme_args = '-o README.md -preface doc/preface.txt doc/README.md'

[tools]
"ubi:golangci/golangci-lint" = "latest"
"ubi:miniscruff/changie" = "latest"
go = "1.23.5"

[tasks.install]
run = "go install go.abhg.dev/stitchmd"
description = "Install the project into bin/"

[tasks.test]
description = "Run tests"
run = "go test ./..."

[tasks."test:cover"]
description = "Run tests with coverage"
run = ["go test -coverprofile=cover.out -coverpkg=./... ./..."]

[tasks."test:cover:html"]
description = "Run tests with coverage and generate HTML report"
depends = ["test:cover"]
run = "go tool cover -html=cover.out -o cover.html"

[tasks.lint]
description = "Run all linters"
depends = ["lint:*"]

[tasks.readme]
description = "Update the README"
sources = ["doc/**", "**/*.go"]
run = "go run . {{vars._readme_args}}"

[tasks."lint:tidy"]
description = "Ensure go.mod is tidy"
run = "go mod tidy -diff"

[tasks."lint:golangci"]
description = "Run golangci-lint"
run = "golangci-lint run"

[tasks."lint:readme"]
description = "Ensure that the README is up-to-date"
run = """
DIFF=$(go run . -color -d {{vars._readme_args}})
if [[ -n "$DIFF" ]]; then
echo "README.md is out of date"
echo "$DIFF"
exit 1
fi
"""

[tasks."release:prepare"]
description = "Prepare a release"
run = [
"changie batch {{arg(name='version')}}",
"changie merge",
]

0 comments on commit 95bb67f

Please sign in to comment.