Skip to content

Commit f504b10

Browse files
authored
Improve formatters article (#2163)
* improve formatting article * add line
1 parent 87058c6 commit f504b10

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

source/docs/software/advanced-gradlerio/code-formatting.rst

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,27 @@ Running Spotless
7373

7474
Spotless can be ran using ``./gradlew spotlessApply`` which will apply all formatting options. You can also specify a specific task by just adding the name of formatter. An example is ``./gradlew spotlessmiscApply``.
7575

76-
Spotless can also be used as a :doc:`CI check <robot-code-ci>`. The check is ran with ``./gradlew spotlessCheck``.
76+
In addition to formatting code, Spotless can also ensure the code is correctly formatted; this can be used by running ``./gradlew spotlessCheck``. Thus, Spotless can be used as a :doc:`CI check <robot-code-ci>`, as shown in the following GitHub Actions workflow:
77+
78+
.. code-block:: yaml
79+
80+
on: [push]
81+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
82+
jobs:
83+
spotless:
84+
# The type of runner that the job will run on
85+
runs-on: ubuntu-latest
86+
# Steps represent a sequence of tasks that will be executed as part of the job
87+
steps:
88+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
89+
- uses: actions/checkout@v2
90+
with:
91+
fetch-depth: 0
92+
- uses: actions/setup-java@v3
93+
with:
94+
distribution: 'zulu'
95+
java-version: 17
96+
- run: ./gradlew spotlessCheck
7797
7898
Explanation of Options
7999
^^^^^^^^^^^^^^^^^^^^^^
@@ -191,31 +211,8 @@ An example styleguide is shown below:
191211
192212
.. note:: Teams can adapt ``.styleguide`` and ``.styleguide-license`` however they wish. It's important that these are not deleted, as they are required to run wpiformat!
193213

194-
You can turn this into a :doc:`CI check <robot-code-ci>` by running ``git --no-pager diff --exit-code HEAD``. It can be configured with a ``.clang-format`` configuration file. An example configuration file is provided below.
195-
196-
Below is an example GitHub Actions check that uses wpiformat
197-
198-
.. code-block:: yaml
214+
You can turn this into a :doc:`CI check <robot-code-ci>` by running ``git --no-pager diff --exit-code HEAD``, as shown in the example GitHub Actions workflow below:
199215

200-
wpiformat:
201-
name: "wpiformat"
202-
runs-on: ubuntu-latest
203-
steps:
204-
- uses: actions/checkout@v2
205-
- name: Fetch all history and metadata
206-
run: |
207-
git fetch --prune --unshallow
208-
git checkout -b pr
209-
git branch -f main origin/main
210-
- name: Set up Python 3.8
211-
uses: actions/setup-python@v2
212-
with:
213-
python-version: 3.8
214-
- name: Install clang-format
215-
run: sudo apt-get update -q && sudo apt-get install -y clang-format-12
216-
- name: Install wpiformat
217-
run: pip3 install wpiformat
218-
- name: Run
219-
run: wpiformat -clang 12
220-
- name: Check Output
221-
run: git --no-pager diff --exit-code HEAD
216+
.. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2023.2.1/.github/workflows/lint-format.yml
217+
:language: yaml
218+
:lines: 1-5, 12-40

0 commit comments

Comments
 (0)