From cb4193b50b981092b45b5b8812f4accd759e2cfb Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Tue, 3 Jun 2025 07:59:22 -0400 Subject: [PATCH 1/7] draft autoformat bot --- .github/workflows/prprecommit.yml | 32 +++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 5 +++++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/prprecommit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/prprecommit.yml b/.github/workflows/prprecommit.yml new file mode 100644 index 000000000..52ad908ff --- /dev/null +++ b/.github/workflows/prprecommit.yml @@ -0,0 +1,32 @@ +name: PR Pre-Commit Bot +env: + JULIA_NUM_THREADS: 2 +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' + - 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/action@v3.0.1 + 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 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..592195822 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: +- repo: "https://github.com/domluna/JuliaFormatter.jl" + rev: "v1.0.62" + hooks: + - id: "julia-formatter" \ No newline at end of file From 5083a1e623b0fe6964c8b1e9ec750b2a4358ffe0 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Tue, 3 Jun 2025 08:09:45 -0400 Subject: [PATCH 2/7] stop CI on outdatted commits --- .github/workflows/ci.yml | 6 ++++++ .github/workflows/prprecommit.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad9eee455..f7ee2be58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/.github/workflows/prprecommit.yml b/.github/workflows/prprecommit.yml index 52ad908ff..80c10ff3c 100644 --- a/.github/workflows/prprecommit.yml +++ b/.github/workflows/prprecommit.yml @@ -1,6 +1,12 @@ 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"] From 3fc173ae5b0af39a351d6e475e46b7dcfc7d6f0a Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Tue, 3 Jun 2025 09:56:10 -0400 Subject: [PATCH 3/7] simplify the cache action --- .github/workflows/ci.yml | 11 +---------- .github/workflows/prprecommit.yml | 1 + 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7ee2be58..fdf8c4625 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,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 diff --git a/.github/workflows/prprecommit.yml b/.github/workflows/prprecommit.yml index 80c10ff3c..0df9c1bfb 100644 --- a/.github/workflows/prprecommit.yml +++ b/.github/workflows/prprecommit.yml @@ -22,6 +22,7 @@ jobs: uses: julia-actions/setup-julia@v2 with: version: '1' + - uses: julia-actions/cache@v2 - name: Setup JuliaFormatter run: | julia -e ' From fbe33729dd784306068cb5d93df50664a464f172 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Tue, 3 Jun 2025 10:06:32 -0400 Subject: [PATCH 4/7] misformat on purpose --- src/core.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core.jl b/src/core.jl index 478242bd6..28336434a 100644 --- a/src/core.jl +++ b/src/core.jl @@ -23,7 +23,7 @@ julia> is_ordered(first(edges(g))) false ``` """ -is_ordered(e::AbstractEdge) = src(e) <= dst(e) +is_ordered(e::AbstractEdge ) = src(e) <= dst(e) """ add_vertices!(g, n) @@ -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 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`. @@ -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`. @@ -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`. From 726b7cc415bf60472822ee433c3bbb4da1c947e9 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Tue, 3 Jun 2025 14:32:15 -0400 Subject: [PATCH 5/7] a PR template explaining the presence of a bot --- .github/pull_request_template.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..68fa00918 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,5 @@ +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. \ No newline at end of file From 7e98f7a4193edaf29078d2b967e6485740bbfc29 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Tue, 3 Jun 2025 14:41:25 -0400 Subject: [PATCH 6/7] mention resetting the test runner in the PR template --- .github/pull_request_template.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 68fa00918..7886926b0 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,4 +2,6 @@ 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. \ No newline at end of file +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. \ No newline at end of file From c2137023382397ccdceb987d6a614815a2d31f08 Mon Sep 17 00:00:00 2001 From: Krastanov <705248+Krastanov@users.noreply.github.com> Date: Tue, 3 Jun 2025 18:42:29 +0000 Subject: [PATCH 7/7] linter bot commit -- feel free to overwrite --- src/core.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.jl b/src/core.jl index 28336434a..cc9c1aa75 100644 --- a/src/core.jl +++ b/src/core.jl @@ -23,7 +23,7 @@ julia> is_ordered(first(edges(g))) false ``` """ -is_ordered(e::AbstractEdge ) = src(e) <= dst(e) +is_ordered(e::AbstractEdge) = src(e) <= dst(e) """ add_vertices!(g, n)