-
Notifications
You must be signed in to change notification settings - Fork 115
autoformat bot in CI #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autoformat bot in CI #437
Changes from all commits
cb4193b
5083a1e
3fc173a
fbe3372
726b7cc
7e98f7a
c213702
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. | ||
| 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 |
| 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" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the bot now have created a commit here?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: 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`. | ||
|
|
@@ -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`. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).