Skip to content

Commit

Permalink
Prefer just fmt and paths-filter over julia-formatter action
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewilliami committed Nov 5, 2024
1 parent d4c8c74 commit 7ad9a05
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ separate_kwargs_with_semicolon = false
surround_whereop_typeparameters = true
short_circuit_to_if = false
disallow_single_arg_nesting = true
verbose = true
32 changes: 26 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: CI
# Run on master, tags, or any pull request
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC (8 PM CST)
push:
branches: [master]
tags: ["*"]
branches:
- master
tags: ['*']
pull_request:

workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
Expand Down Expand Up @@ -69,7 +73,23 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
- uses: julia-actions/julia-format@v3
- uses: extractions/setup-just@v1 # or taiki-e/install-action@just

# Adapted from:
# github.com/FluxML/Flux.jl/blob/7be1ca7a/.github/workflows/JuliaFormatter.yml
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
julia_file_change:
- added|modified: '**/*.jl'
- name: Apply JuliaFormatter
run: |
just fmt
- name: Check formatting diff
if: steps.filter.outputs.julia_file_change == 'true'
run: |
git diff --color=always --exit-code
perf:
name: Performance
Expand Down
8 changes: 7 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ bench: (instantiate-dev bench_dir)

# Check formatting with blue style
[group: 'ci']
fmt:
fmt: install-formatter
# https://github.com/invenia/BlueStyle
julia --project=@JuliaFormatter -e 'using JuliaFormatter; format("{{project_dir}}", style=BlueStyle())'

# Install JuliaFormatter
[private]
install-formatter:
julia --project=@JuliaFormatter -e 'import Pkg; Pkg.add("JuliaFormatter")'

# Instantiate main project
instantiate:
julia --project={{project_dir}} -e '{{standard_instantiate_code}}'
Expand All @@ -56,3 +61,4 @@ instantiate:
[private]
instantiate-dev dev_project_dir:
julia --project={{dev_project_dir}} -e '{{dev_instantiate_code}}'

0 comments on commit 7ad9a05

Please sign in to comment.