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
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Please make sure to leave this PR editable by maintainers of this repo.

Please make sure you have consulted [CONTRIBUTING](https://github.com/JuliaGraphs/Graphs.jl/blob/master/CONTRIBUTING.md)

The linter bot might add new commits to your PR (e.g. to take care of formatting issues). Feel free to overwrite these commits.

If the linter bot is the last one to put in a commit, **THE TESTS WILL NOT RUN**. Either lint/format your contributions yourself as described in CONTRIBUTING.md or close&reopen the PR to reset the test runner.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to have the tests run after the linter? As we have seen with JuliaFormatter v2 there is the possibility that the formatter introduces errors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible, but I do not think that would fix the main issue -- if the bot makes a commit, tests will not run afterwards because github actions do not get triggered by bots and the PR status will not report the old test (you would need to go in the actions tab and scroll to past commits).

17 changes: 7 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI
env:
JULIA_NUM_THREADS: 2
concurrency:
# group by workflow and ref; the last slightly strange component ensures that for pull
# requests, we limit to 1 concurrent job, but for the master branch we don't
group: ${{ github.workflow }}-${{ github.ref }}-${{ (github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main') || github.run_number }}
# Cancel intermediate builds, but only if it is a pull request build.
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
on:
pull_request:
branches:
Expand Down Expand Up @@ -32,16 +38,7 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/prprecommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PR Pre-Commit Bot
env:
JULIA_NUM_THREADS: 2
concurrency:
# group by workflow and ref; the last slightly strange component ensures that for pull
# requests, we limit to 1 concurrent job, but for the master branch we don't
group: ${{ github.workflow }}-${{ github.ref }}-${{ (github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main') || github.run_number }}
# Cancel intermediate builds, but only if it is a pull request build.
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
on:
pull_request:
branches: ["master", "main"]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup Julia
uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: julia-actions/cache@v2
- name: Setup JuliaFormatter
run: |
julia -e '
using Pkg
Pkg.add(name="JuliaFormatter", version="1.0.62")'
- name: Setup Python
uses: actions/setup-python@v3
- name: Run pre-commit
uses: pre-commit/[email protected]
continue-on-error: true
- name: Potentially commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: linter bot commit -- feel free to overwrite
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: "https://github.com/domluna/JuliaFormatter.jl"
rev: "v1.0.62"
hooks:
- id: "julia-formatter"
6 changes: 3 additions & 3 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ add_vertices!(g::AbstractGraph, n::Integer) = sum([add_vertex!(g) for i in 1:n])
indegree(g[, v])

Return a vector containing the indegrees of every vertex of the graph `g`, where
the indegree of a vertex is defined as the number of edges which end at that
the indegree of a vertex is defined as the number of edges which end at that
Copy link
Member

@simonschoelly simonschoelly Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the bot now have created a commit here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess not -- this was fixed by my IDE auto-save, not by JuliaFormatter.

I just checked and the repo is actually littered with trailing whitespaces:

> git checkout master; git pull
# what follows is a command that removes trailing whitespaces that I found on stack overflow
> (export LANG=C LC_CTYPE=C
find . -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | perl -0ne 'print if -T' | xargs -0 sed -Ei 's/[[:blank:]]+$//'
)
> git status
...
	modified:   Experimental/Traversals/bfs.jl
	modified:   Experimental/isomorphism.jl
	modified:   Parallel/vertexcover/random_vertex_cover.jl
	modified:   SimpleGraphs/generators/randgraphs.jl
	modified:   SimpleGraphs/simpledigraph.jl
	modified:   centrality/degree.jl
	modified:   centrality/eigenvector.jl
	modified:   centrality/pagerank.jl
	modified:   centrality/radiality.jl
	modified:   community/assortativity.jl
	modified:   community/modularity.jl
	modified:   connectivity.jl
	modified:   core.jl
	modified:   dominatingset/degree_dom_set.jl
	modified:   graphcut/karger_min_cut.jl
	modified:   independentset/degree_ind_set.jl
	modified:   independentset/maximal_ind_set.jl
	modified:   iterators/bfs.jl
	modified:   iterators/dfs.jl
	modified:   shortestpaths/bellman-ford.jl
	modified:   shortestpaths/floyd-warshall.jl
	modified:   shortestpaths/johnson.jl
	modified:   shortestpaths/yen.jl
	modified:   spanningtrees/kruskal.jl
	modified:   steinertree/steiner_tree.jl
	modified:   traversals/all_simple_paths.jl
	modified:   traversals/bfs.jl
	modified:   trees/prufer.jl
	modified:   vertexcover/random_vertex_cover.jl

I will leave this mystery of why whitespaces are not cleaned up for another PR. Seems to be a status-quo issue, not a new one introduced by this PR.

vertex. If `v` is specified and is a single vertex, only return the indegree of
`v`. If `v` is specified and is a vector of vertices, only return the indegrees
of the vertices in `v`.
Expand Down Expand Up @@ -85,7 +85,7 @@ indegree(g::AbstractGraph, vs=vertices(g)) = [indegree(g, x) for x in vs]
outdegree(g[, v])

Return a vector containing the outdegrees of every vertex of the graph `g`, where
the outdegree of a vertex is defined as the number of edges which start at that
the outdegree of a vertex is defined as the number of edges which start at that
vertex. If `v` is specified and is a single vertex, only return the outdegree of
`v`. If `v` is specified and is a vector of vertices, only return the outdegrees
of the vertices in `v`.
Expand Down Expand Up @@ -124,7 +124,7 @@ outdegree(g::AbstractGraph, vs=vertices(g)) = [outdegree(g, x) for x in vs]
Return a vector containing the degrees of every vertex of the graph `g`, where
the degree of a vertex is defined as the number of edges which start or end at
that vertex. For directed graphs, the degree of a vertex is equal to the sum of
its indegree and outdegree. If `v` is specified and is a single vertex, only
its indegree and outdegree. If `v` is specified and is a single vertex, only
return the degree of `v`. If `v` is specified and is a vector of vertices, only
return the degrees of the vertices in `v`.

Expand Down
Loading