Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .devcontainer.json

This file was deleted.

147 changes: 89 additions & 58 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,101 @@
name: Test treefmt Action

on: [push]

on:
- push
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
arch: [x86_64, arm64]
os:
- ubuntu-latest
- macos-latest
arch:
- x86_64
- arm64
test-case:
- name: 'Default settings'
version: 'latest'
ci: 'true'
- name: 'Specify version 2.1.0'
version: '2.1.0'
ci: 'true'
- name: 'Custom config file'
config_file: 'treefmt.toml'
- name: 'Allow missing formatters'
allow_missing_formatter: 'true'
- name: 'Run in specific working directory'
working_dir: '.'
- name: 'Disable cache'
no_cache: 'true'
- name: 'Do not fail on change'
fail_on_change: 'false'
- name: 'Run specific formatters'
formatters: 'typescript,toml'
- name: 'Increase verbosity'
verbose: '2'
- name: 'Clear cache before run'
clear_cache: 'true'
- name: 'Exclude certain paths'
excludes: 'docs/**,tests/**'
- name: 'Initialize treefmt configuration'
init: 'true'
- name: Default settings
# technically should not need to specify version here since latest is default
# however, because the matrix specifies version always, if we leave it out
# the action will give an error about a missing input
# however, users can leave version out to get the default behavior
version: latest
ci: true
- name: Use system treefmt if available
version: system
ci: true
- name: Specify version 2.4.0
version: "2.4.0"
ci: true
- name: Custom config file
# has to specify version here since matrix always specifies version
version: latest
config-file: .treefmt.toml
- name: Allow missing formatters
version: system
allow-missing-formatter: true
- name: Run in specific working directory
version: system
working-dir: .
- name: Disable cache
version: system
no-cache: true
- name: Do not fail on change
version: system
fail-on-change: false
- name: Run specific formatters
version: system
formatters: biome,taplo
- name: Increase verbosity
version: system
verbose: "2"
- name: Clear cache before run
version: system
clear-cache: true
- name: Exclude certain paths
version: system
excludes: docs/**,tests/**
name: ${{ matrix.test-case.name }} on ${{ matrix.os }} ${{ matrix.arch }}
steps:
- uses: actions/checkout@v2
- uses: biomejs/setup-biome@v2.2.1
- uses: uncenter/setup-taplo@v1.0.8
- name: Run treefmt Action
uses: ./
with:
version: ${{ matrix.test-case.version }}
config_file: ${{ matrix.test-case.config_file }}
allow_missing_formatter: ${{ matrix.test-case.allow_missing_formatter }}
working_dir: ${{ matrix.test-case.working_dir }}
no_cache: ${{ matrix.test-case.no_cache }}
fail_on_change: ${{ matrix.test-case.fail_on_change }}
formatters: ${{ matrix.test-case.formatters }}
verbose: ${{ matrix.test-case.verbose }}
clear_cache: ${{ matrix.test-case.clear_cache }}
excludes: ${{ matrix.test-case.excludes }}
init: ${{ matrix.test-case.init }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v6
- uses: DeterminateSystems/nix-installer-action@v21
- uses: DeterminateSystems/magic-nix-cache-action@v13
with:
use-flakehub: false
use-gha-cache: true
- name: Install formatting tools
shell: bash
run: |
eval "$(nix print-dev-env --no-pure-eval --accept-flake-config .#ci)"
echo "PATH=$PATH" >> "$GITHUB_ENV"
- name: Run treefmt Action
uses: ./
with:
version: ${{ matrix.test-case.version }}
ci: ${{ matrix.test-case.ci }}
config-file: ${{ matrix.test-case.config-file }}
allow-missing-formatter: ${{ matrix.test-case.allow-missing-formatter }}
working-dir: ${{ matrix.test-case.working-dir }}
no-cache: ${{ matrix.test-case.no-cache }}
fail-on-change: ${{ matrix.test-case.fail-on-change }}
formatters: ${{ matrix.test-case.formatters }}
verbose: ${{ matrix.test-case.verbose }}
clear-cache: ${{ matrix.test-case.clear-cache }}
excludes: ${{ matrix.test-case.excludes }}
github-token: ${{ secrets.GITHUB_TOKEN }}
marketplace-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: biomejs/setup-biome@v2.2.1
- uses: uncenter/setup-taplo@v1.0.8
- name: Run treefmt Action from Marketplace
uses: isbecker/treefmt-action@v1.3.0
with:
version: 'latest'
github_token: ${{ secrets.GITHUB_TOKEN }}
ci: 'true'
- uses: actions/checkout@v2
- uses: biomejs/setup-biome@v2.6.0
with:
version: "2.2.6"
- uses: uncenter/setup-taplo@v1.0.8
- name: Run treefmt Action from Marketplace
uses: isbecker/treefmt-action@v1.4.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
ci: true
# TODO: update this once we push the new version
# should not need to specify, and if necessary,
# it should be "config-file" with a hyphen
config_file: .treefmt.toml
File renamed without changes.
126 changes: 71 additions & 55 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,80 +6,96 @@ branding:
color: "orange"
inputs:
version:
description: "The version of treefmt to install"
required: false
default: "latest"
github_token:
description: "GitHub token for accessing the API"
description: |
Version of treefmt to install and use.
Allowed values:
- "latest" (default): install the latest available version, determined via GitHub releases
- "system": use the system-provided version (no install), for usage with e.g., treefmt.nix
- SemVer (e.g. "1.2.3"), to install a specific version
required: true
default: latest
github-token:
description: |
GitHub token for accessing the API. Used to allow this action to download
and install treefmt releases from GitHub.
required: true
config_file:
description: "Path to the treefmt configuration file"
config-file:
description: |
Path to a treefmt configuration file. If not provided, treefmt will search
upwards for treefmt.toml or .treefmt.toml from the working directory.
Set working_dir input to change the working directory.
required: false
default: "treefmt.toml"
allow_missing_formatter:
description: "Do not exit with error if a configured formatter is missing"
allow-missing-formatter:
description: Do not exit with error if a configured formatter is missing
required: false
default: "false"
working_dir:
description: "Run as if treefmt was started in the specified working directory instead of the current working directory"
working-dir:
description: |
Run as if treefmt was started in the specified working directory instead
of the current working directory.
required: false
default: "."
ci:
description: "Runs treefmt in a CI mode, enabling --no-cache, --fail-on-change and adjusting some other settings best suited to a CI use case"
description: |
Runs treefmt in a CI mode, enabling --no-cache, --fail-on-change and
adjusting some other settings best suited to a CI use case.
Recommended when using treefmt in CI workflows, like this action.
required: false
default: "false"
no_cache:
description: "Ignore the evaluation cache entirely. Useful for CI"
default: "true"
no-cache:
description: Ignore the evaluation cache entirely. Useful for CI.
required: false
default: "false"
fail_on_change:
description: "Exit with error if any changes were made. Useful for CI"
fail-on-change:
description: Exit with error if any changes were made. Useful for CI.
required: false
default: "true"
formatters:
description: "Specify formatters to apply. Defaults to all formatters"
description: Specify formatters to apply. Defaults to all formatters.
required: false
default: ""
tree_root:
description: "The root directory from which treefmt will start walking the filesystem"
tree-root:
description: |
The root directory from which treefmt will start walking the filesystem.
Defaults to the root of the current git or jujutsu worktree. If not in
a git or jujutsu repo, defaults to the directory containing the config file.
required: false
default: ""
tree_root_file:
description: "File to search for to find the project root (if --tree_root is not passed)"
tree-root-file:
description: File to search for to find the tree root.
required: false
tree-root-cmd:
description: |
Command to run to find the tree root. It is parsed using shlex, to allow
quoting arguments that contain whitespace. If you wish to pass arguments
containing quotes, you should use nested quotes e.g. "'" or '"'.
required: false
default: ""
walk:
description: "The method used to traverse the files within --tree_root. Supports 'auto', 'git' or 'filesystem'"
description: |
The method used to traverse the files within tree root.
Allowed values:
- "auto": automatically choose the best method (default)
- "git": use git to list files
- "jujutsu": use jujutsu to list files
- "filesystem": traverse the filesystem directly
required: false
default: "auto"
verbose:
description: "Set the verbosity of logs"
description: Set the verbosity of logs.
required: false
default: "0"
on_unmatched:
description: "Log paths that did not match any formatters at the specified log level"
quiet:
description: Disable all logs except errors.
required: false
default: "warn"
clear_cache:
description: "Reset the evaluation cache. Use in case the cache is not precise enough"
on-unmatched:
description: |
Log paths that did not match any formatters at the specified log level.
Defaults to "info".
Allowed values:
- "debug"
- "info"
- "warn"
- "error"
- "fatal"
required: false
default: "false"
cpu_profile:
description: "The file into which a CPU profile will be written"
clear-cache:
description: Reset the evaluation cache. Use in case the cache is not precise enough.
required: false
default: ""
excludes:
description: "Exclude files or directories matching the specified globs"
required: false
default: ""
stdin:
description: "Format the context passed in via stdin"
required: false
default: "false"
init:
description: "Create a treefmt.toml file in the current directory"
description: Exclude files or directories matching the specified globs.
required: false
default: "false"
runs:
using: "node20"
main: "dist/index.js"
using: node20
main: dist/index.js
10 changes: 7 additions & 3 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
"organizeImports": {
"enabled": false
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"linter": {
"enabled": true,
Expand Down
Loading
Loading