Skip to content

Commit 9bca0a6

Browse files
authored
Merge pull request #1981 from dscho/describe-how-to-run-the-tests
README: describe how to run the tests
2 parents 6540655 + 9248e49 commit 9bca0a6

File tree

1 file changed

+86
-28
lines changed

1 file changed

+86
-28
lines changed

README.md

+86-28
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ This site is built with [Hugo](https://gohugo.io/) and served via GitHub Pages.
1111
> [!NOTE]
1212
> It is highly recommended to clone this repository using [`scalar`](https://git-scm.com/docs/scalar); This allows to work only on the parts of the repository relevant to your interests. You can select which directories are checked out using the [`git sparse-checkout add <directory>...`](https://git-scm.com/docs/git-sparse-checkout) command. Typically, you will want to start like this:
1313
14-
```ShellSession
14+
```console
1515
$ scalar clone https://github.com/git/git-scm.com
1616
$ cd git-scm.com/src
1717
$ git sparse-checkout set layouts content static assets hugo.yml data script
1818
```
1919

2020
If your Git installation comes without `scalar`, you can create a sparse, partial clone manually, like this:
2121

22-
```ShellSession
22+
```console
2323
$ git clone --filter=blob:none --no-checkout https://github.com/git/git-scm.com
2424
$ cd git-scm.com
2525
$ git sparse-checkout set layouts content static assets hugo.yml data script
@@ -55,97 +55,155 @@ To render the site locally, you'll need [Hugo](https://gohugo.io/)'s **extended*
5555

5656
You can verify the Hugo version like this:
5757

58-
$ hugo version
59-
hugo v0.128.0+extended linux/amd64 BuildDate=unknown
58+
```console
59+
$ hugo version
60+
hugo v0.128.0+extended linux/amd64 BuildDate=unknown
61+
```
6062

6163
You can serve the site locally via:
6264

63-
$ node script/serve-public.js
65+
```console
66+
$ node script/serve-public.js
67+
```
6468

6569
The site should be running on http://127.0.0.1:5000.
6670

6771
If you want to serve the site via Hugo's built-in mechanism, you will need to turn off ["ugly URLs"](https://gohugo.io/content-management/urls/#appearance), by running this command, which will serve the site via http://127.0.0.1:1313:
6872

69-
$ HUGO_UGLYURLS=false hugo serve -w
73+
```console
74+
$ HUGO_UGLYURLS=false hugo serve -w
75+
```
7076

7177
Side note: What _are_ "ugly URLs"? Hugo, by default, generates "pretty" URLs like https://git-scm.com/about/ (note the trailing slash) instead of what it calls "ugly" URLs like https://git-scm.com/about.html. However, since GitHub Pages auto-resolves "even prettier" URLs like https://git-scm.com/about by appending `.html` first, we _want_ the "ugly" URLs to be used here. The `serve-public.js` script emulates GitHub Pages' behavior, while `hugo serve` does not.
7278

7379
Pro-Tip: Do this in a sparse checkout that excludes large parts of `content/`, to speed up the rendering time.
7480

7581
To test the site locally _with_ the search enabled, run this instead:
7682

77-
$ hugo
78-
$ npx -y pagefind --site public
79-
$ node script/serve-public.js
83+
```console
84+
$ hugo
85+
$ npx -y pagefind --site public
86+
$ node script/serve-public.js
87+
```
8088

8189
You can also use Pagefind's built-in server (which will be running on http://127.0.0.1:1414), but again, you have to turn off "ugly URLs":
8290

83-
$ HUGO_UGLYURLS=false hugo
84-
$ npx -y pagefind --site public --serve
91+
```console
92+
$ HUGO_UGLYURLS=false hugo
93+
$ npx -y pagefind --site public --serve
94+
```
8595

8696
Note that running Pagefind will make the process about 7 times slower, and the site will not be re-rendered and live-reloaded in the browser when you change files in `content/` (unlike with `hugo serve -w`).
8797

98+
## Running the test suite
99+
100+
Believe it or not, https://git-scm.com/ has its own test suite. It uses [Playwright](https://playwright.dev/) to perform a couple of tests that verify that the site "looks right". These tests live in `tests/` and are configured via `playwright.config.js`.
101+
102+
To run these tests in your local setup, you need a working node.js installation. After that, you need to install Playwright:
103+
104+
```console
105+
$ npm install @playwright/test
106+
```
107+
108+
Since Playwright uses headless versions of popular web browsers, you most likely need to install at least one of them, e.g. via:
109+
110+
```console
111+
$ npx playwright install firefox
112+
```
113+
114+
Supported browsers include `firefox`, `chromium`, `webkit`, `chrome`. You can also simply download all of them using `npx playwright install` but please first note that they all weigh >100MB, so you might want to refrain from doing that. Side note: In GitHub Actions' hosted runners, Chrome comes pre-installed, and you might be able to use your own Chrome installation, too, if you have one.
115+
116+
By default, the Playwright tests target https://git-scm.com/, which is unlikely what you want: You probably want to run the tests to validate your local changes. To do so, the configuration has a special provision to start a tiny local web server to serve the files written to `public/` by Hugo and Pagefind:
117+
118+
```console
119+
$ PLAYWRIGHT_TEST_URL='http://localhost:5000/' npx playwright test --project=firefox
120+
```
121+
122+
For more fine-grained testing, you can pass `-g <regex>` to run only the matching test cases.
123+
88124
## Update manual pages
89125

90126
First, install the Ruby prerequisites:
91127

92-
$ bundler install
128+
```console
129+
$ bundler install
130+
```
93131

94132
Then, you can build the manual pages using a local Git source clone like this:
95133

96-
$ ruby ./script/update-docs.rb /path/to/git/.git en
134+
```console
135+
$ ruby ./script/update-docs.rb /path/to/git/.git en
136+
```
97137

98138
This will populate the manual pages for all Git versions. You can also populate them only for a specific Git version (faster):
99139

100-
$ version=v2.23.0
101-
$ REBUILD_DOC=$version ruby ./script/update-docs.rb /path/to/git/.git en
140+
```console
141+
$ version=v2.23.0
142+
$ REBUILD_DOC=$version ruby ./script/update-docs.rb /path/to/git/.git en
143+
```
102144

103145
Or you can populate the man pages from GitHub (much slower) like this:
104146

105-
$ export GITHUB_API_TOKEN=github_personal_auth_token
106-
$ REBUILD_DOC=$version ruby ./script/update-docs.rb remote en # specific version
147+
```console
148+
$ export GITHUB_API_TOKEN=github_personal_auth_token
149+
$ REBUILD_DOC=$version ruby ./script/update-docs.rb remote en # specific version
150+
```
107151

108152
Similarly, you can also populate the localized man pages. From a local clone of https://github.com/jnavila/git-html-l10n :
109153

110-
$ ruby ./script/update-docs.rb /path/to/git-html-l10n/.git l10n # all versions
111-
$ REBUILD_DOC=$version ruby ./script/update-docs.rb /path/to/git-html-l10n/.git l10n # specific version
154+
```console
155+
$ ruby ./script/update-docs.rb /path/to/git-html-l10n/.git l10n # all versions
156+
$ REBUILD_DOC=$version ruby ./script/update-docs.rb /path/to/git-html-l10n/.git l10n # specific version
157+
```
112158

113159
Or you can do it from GitHub (much slower) like this:
114160

115-
$ export GITHUB_API_TOKEN=github_personal_auth_token
116-
$ REBUILD_DOC=$version ruby ./script/update-docs.rb remote l10n # specific version
161+
```console
162+
$ export GITHUB_API_TOKEN=github_personal_auth_token
163+
$ REBUILD_DOC=$version ruby ./script/update-docs.rb remote l10n # specific version
164+
```
117165

118166
## Update the `Downloads` pages
119167

120168
Now you need to get the latest downloads for the downloads pages:
121169

122-
$ ruby ./script/update-download-data.rb
170+
```console
171+
$ ruby ./script/update-download-data.rb
172+
```
123173

124174
## Update the ProGit book
125175

126176
First, you will have to get the necessary prerequisites:
127177

128-
$ bundler install
178+
```console
179+
$ bundler install
180+
```
129181

130182
Now you'll probably want some book data.
131183

132184
You'll have to get the book content from a repository on your computer by specifying the path:
133185

134-
$ git clone https://github.com/progit/progit2-fr ../progit2-fr
135-
$ ruby ./script/update-book2.rb fr ../progit2-fr
186+
```console
187+
$ git clone https://github.com/progit/progit2-fr ../progit2-fr
188+
$ ruby ./script/update-book2.rb fr ../progit2-fr
189+
```
136190

137191
That will generate the book content from the Asciidoc files and write the files to the local tree, ready to be committed and served via Hugo.
138192

139193
Alternatively, you need to have access to the [Pro Git project on GitHub](https://github.com/progit/progit2) through the API.
140194

141-
$ export GITHUB_API_TOKEN=github_personal_auth_token
142-
$ ruby ./script/update-book2.rb en
195+
```console
196+
$ export GITHUB_API_TOKEN=github_personal_auth_token
197+
$ ruby ./script/update-book2.rb en
198+
```
143199

144200
If you have 2FA enabled, you'll need to create a [Personal Access Token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/).
145201

146202
If you want to build the book for all available languages, just omit the language code parameter:
147203

148-
$ ruby ./script/update-book2.rb
204+
```console
205+
$ ruby ./script/update-book2.rb
206+
```
149207

150208
## Contributing
151209

0 commit comments

Comments
 (0)