Skip to content

Commit 3951d07

Browse files
Start documenting workflows (#560)
1 parent e2dc03e commit 3951d07

File tree

7 files changed

+93
-8
lines changed

7 files changed

+93
-8
lines changed

building/config.json

+6
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,12 @@
667667
"path": "building/tracks/ci/workflows.md",
668668
"title": "Workflows"
669669
},
670+
{
671+
"uuid": "753dfe68-af5f-466e-b9a1-5797b6088ab0",
672+
"slug": "tracks/ci/workflows/configlet",
673+
"path": "building/tracks/ci/workflows/configlet.md",
674+
"title": "configlet workflow"
675+
},
670676
{
671677
"uuid": "191b0fa1-96e2-48a6-ad2e-c34f57443799",
672678
"slug": "tracks/ci/migrating-from-travis",

building/configlet/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ How to generate UUIDs can be found [here](/docs/building/configlet/uuid).
5151
## Formatting
5252

5353
Configlet has a `fmt` command to help with consistent formatting of the JSON files in the track repo.
54-
The `fmt` command currently only operates on the exercise `.meta/config.json` files but it is likely to operate on all the track JSON files in the future.
54+
The `fmt` command formats the following files:
55+
56+
- `config.json`
57+
- `exercises/{concept,practice}/*/.approaches/config.json`
58+
- `exercises/{concept,practice}/*/.articles/config.json`
59+
- `exercises/{concept,practice}/*/.meta/config.json`
60+
5561
You can learn more about the format command [here](/docs/building/configlet/format).
5662

5763
## Installation

building/configlet/format.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
An Exercism track repo has many JSON files, including:
44

55
- The track `config.json` file.
6-
76
- For each concept, a `.meta/config.json` and `links.json` file.
8-
97
- For each Concept Exercise or Practice Exercise, a `.meta/config.json` file.
108

119
These files are more readable if they have a consistent formatting Exercism-wide, and so configlet has a `fmt` command for rewriting a track's JSON files in a canonical form.
1210

13-
The `fmt` command currently operates on the exercise `.meta/config.json` files and the track `config.json` file, but it is likely to operate on all the track JSON files in the future.
11+
The `fmt` command formats the following files:
12+
13+
- `config.json`
14+
- `exercises/{concept,practice}/*/.approaches/config.json`
15+
- `exercises/{concept,practice}/*/.articles/config.json`
16+
- `exercises/{concept,practice}/*/.meta/config.json`
1417

1518
## Usage
1619

building/tracks/ci/workflows.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ For information on workflows, check the following docs:
1515
## Shared workflows
1616

1717
Some workflows are shared across repositories.
18-
These workflows _should not be changed_.
18+
19+
```exercism/caution
20+
The shared workflows are automatically synced (from the [org-wide-files repo](https://github.com/exercism/org-wide-files/)).
21+
You should thus not manually change their contents.
22+
```
1923

2024
### General workflows
2125

2226
- `sync-labels.yml`: automatically syncs the repository's labels from a `labels.yml` file
2327

2428
### Track-specific workflows
2529

26-
- `configlet.yml`: runs the [configlet tool](/docs/building/configlet), which checks if a track's (configuration) files are properly structured - both syntactically and semantically
30+
- [`configlet.yml`](/docs/building/tracks/ci/workflows/configlet): runs the [configlet tool](/docs/building/configlet), which checks if a track's (configuration) files are properly structured - both syntactically and semantically
2731
- `no-important-files-changed.yml`: checks if pull requests would cause all existing solutions of one or more changes exercises to be re-run
2832
- `test.yml`: verify the track's exercises
2933

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# configlet workflow
2+
3+
The `configlet` workflow is defined in the `.github/workflows/configlet.yml` file.
4+
It uses the [configlet tool](/docs/building/configlet) to check if a track's (configuration) files are properly structured - both syntactically and semantically.
5+
It does this by running [`configlet lint`](/docs/building/configlet/lint).
6+
7+
## Enable checking file formatting
8+
9+
Tracks can use [`configlet fmt`](/docs/building/configlet/format) to format the track's various configuration files.
10+
The same command can also be used to check if all configuration files are formatted correctly.
11+
12+
The `configlet` workflow supports verifying whether the configuration files are formatted correctly, but this is optional and disabled by default.
13+
To opt-into verifying configuration files' formatting, follow these steps:
14+
15+
1. Create a `.github/org-wide-files-config.toml` file with the following contents
16+
17+
```toml
18+
[configlet]
19+
fmt = true
20+
```
21+
22+
2. After this file is merged into `main`, a PR will automatically be opened that modifies the `configlet.yml` workflow as follows:
23+
24+
```diff
25+
jobs:
26+
configlet:
27+
uses: exercism/github-actions/.github/workflows/configlet.yml@main
28+
+ with:
29+
+ fmt: true
30+
```
31+
32+
3. Once this PR is merged, the `configlet` workflow will also verify the track's configuration files' formatting.

building/tracks/new/add-first-exercise.md

+30
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,35 @@ Tip: just can copy-paste-modify the example solution.
113113
Once you're done with the exercise, please add your your GitHub username to the `"authors"` array in the exercise's `.meta/config.json` file.
114114
This will ensure we correctly credit you with having created the exercise.
115115

116+
### Linting
117+
118+
To verify that the exercise is setup correctly, you can use the [configlet tool](/docs/building/configlet)'s built-in linting functionality.
119+
120+
The first step is to fetch the `configlet` tool, for which we've created two scripts:
121+
122+
- `bin/fetch-configlet`: run this when using \*nix or macOS
123+
- `bin/fetch-configlet.ps1`: run this when using Windows
124+
125+
Running one of these scripts from the root directory of the track's repo will download the `bin/configlet` respectively `bin/configlet.exe` binary.
126+
127+
You can then check the exercise for correctness by running [`bin/configlet lint`](/docs/building/configlet/lint).
128+
129+
````exercism/note
130+
It is likely that `configlet` will report the following error:
131+
```shell
132+
The `tags` array is empty:
133+
/path/to/track/config.json
134+
```
135+
136+
This error will be fixed in the [Prepare for launch](/docs/building/tracks/new/prepare-for-launch#h-update-metadata) step, so either:
137+
138+
- ignore the error (for now), or
139+
- fix the error by adding tags
140+
````
141+
142+
```exercism/note
143+
The [`configlet` workflow](/docs/building/tracks/ci/workflows/configlet) will automatically runs `configlet lint` whenever something is pushed to `main` or to a pull request.
144+
```
145+
116146
[configlet]: /docs/building/configlet
117147
[canonical-data.json]: https://github.com/exercism/problem-specifications/blob/main/exercises/hello-world/canonical-data.json

building/tracks/new/setup-continuous-integration.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ Exercism repos (including track repos) use [GitHub Actions](https://docs.github.
88
GitHub Actions are based on _workflows_, which define scripts to run automatically whenever a specific event occurs (e.g. pushing a commit).
99
For more information on GitHub Actions workflows, check the [workflows docs](/docs/building/tracks/ci/workflows).
1010

11+
## Pre-installed workflows
12+
13+
Tracks come pre-installed with a number of workflows, most of which you should _not_ modify (they're called _shared workflows_).
14+
There is one workflow that you _should_ change though, which is the `test.yml` workflow.
15+
1116
## Test workflow
1217

13-
Each track comes with a `test.yml` workflow.
14-
The goal of this workflow is to verify that the track's exercises are in proper shape.
18+
The goal of the `test.yml` workflow is to verify that the track's exercises are in proper shape.
1519
The workflow is setup to run automatically (in GitHub Actions terminology: is _triggered_) when a push is made to the `main` branch or to a pull request's branch.
1620

1721
The workflow itself should not do much, except for:

0 commit comments

Comments
 (0)